diff options
Diffstat (limited to 'liolib.c')
-rw-r--r-- | liolib.c | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.30 1999/02/05 15:22:43 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.31 1999/02/22 14:17:24 roberto Exp roberto $ |
3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -455,6 +455,10 @@ static void io_debug (void) { | |||
455 | #define MESSAGESIZE 150 | 455 | #define MESSAGESIZE 150 |
456 | #define MAXMESSAGE (MESSAGESIZE*10) | 456 | #define MAXMESSAGE (MESSAGESIZE*10) |
457 | 457 | ||
458 | |||
459 | #define MAXSRC 40 | ||
460 | |||
461 | |||
458 | static void errorfb (void) { | 462 | static void errorfb (void) { |
459 | char buff[MAXMESSAGE]; | 463 | char buff[MAXMESSAGE]; |
460 | int level = 1; /* skip level 0 (it's this function) */ | 464 | int level = 1; /* skip level 0 (it's this function) */ |
@@ -464,8 +468,10 @@ static void errorfb (void) { | |||
464 | char *name; | 468 | char *name; |
465 | int currentline; | 469 | int currentline; |
466 | char *chunkname; | 470 | char *chunkname; |
471 | char buffchunk[MAXSRC]; | ||
467 | int linedefined; | 472 | int linedefined; |
468 | lua_funcinfo(func, &chunkname, &linedefined); | 473 | lua_funcinfo(func, &chunkname, &linedefined); |
474 | luaL_chunkid(buffchunk, chunkname, MAXSRC); | ||
469 | if (level == 2) strcat(buff, "Active Stack:\n"); | 475 | if (level == 2) strcat(buff, "Active Stack:\n"); |
470 | strcat(buff, "\t"); | 476 | strcat(buff, "\t"); |
471 | if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) { | 477 | if (strlen(buff) > MAXMESSAGE-MESSAGESIZE) { |
@@ -474,26 +480,24 @@ static void errorfb (void) { | |||
474 | } | 480 | } |
475 | switch (*lua_getobjname(func, &name)) { | 481 | switch (*lua_getobjname(func, &name)) { |
476 | case 'g': | 482 | case 'g': |
477 | sprintf(buff+strlen(buff), "function %.50s", name); | 483 | sprintf(buff+strlen(buff), "function `%.50s'", name); |
478 | break; | 484 | break; |
479 | case 't': | 485 | case 't': |
480 | sprintf(buff+strlen(buff), "`%.50s' tag method", name); | 486 | sprintf(buff+strlen(buff), "`%.50s' tag method", name); |
481 | break; | 487 | break; |
482 | default: { | 488 | default: { |
483 | if (linedefined == 0) | 489 | if (linedefined == 0) |
484 | sprintf(buff+strlen(buff), "main of %.50s", chunkname); | 490 | sprintf(buff+strlen(buff), "main of %.50s", buffchunk); |
485 | else if (linedefined < 0) | 491 | else if (linedefined > 0) |
486 | sprintf(buff+strlen(buff), "%.50s", chunkname); | 492 | sprintf(buff+strlen(buff), "function <%d:%.50s>", |
487 | else | 493 | linedefined, buffchunk); |
488 | sprintf(buff+strlen(buff), "function (%.50s:%d)", | ||
489 | chunkname, linedefined); | ||
490 | chunkname = NULL; | 494 | chunkname = NULL; |
491 | } | 495 | } |
492 | } | 496 | } |
493 | if ((currentline = lua_currentline(func)) > 0) | 497 | if ((currentline = lua_currentline(func)) > 0) |
494 | sprintf(buff+strlen(buff), " at line %d", currentline); | 498 | sprintf(buff+strlen(buff), " at line %d", currentline); |
495 | if (chunkname) | 499 | if (chunkname) |
496 | sprintf(buff+strlen(buff), " [in chunk %.50s]", chunkname); | 500 | sprintf(buff+strlen(buff), " [in %.50s]", buffchunk); |
497 | strcat(buff, "\n"); | 501 | strcat(buff, "\n"); |
498 | } | 502 | } |
499 | func = lua_rawgetglobal("_ALERT"); | 503 | func = lua_rawgetglobal("_ALERT"); |