diff options
Diffstat (limited to 'loadlib.c')
-rw-r--r-- | loadlib.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -458,13 +458,13 @@ static const char *getnextfilename (char **path, char *end) { | |||
458 | /* | 458 | /* |
459 | ** Given a path such as ";blabla.so;blublu.so", pushes the string | 459 | ** Given a path such as ";blabla.so;blublu.so", pushes the string |
460 | ** | 460 | ** |
461 | ** no file 'blabla.so' | 461 | ** no file 'blabla.so' |
462 | ** no file 'blublu.so' | 462 | ** no file 'blublu.so' |
463 | */ | 463 | */ |
464 | static void pusherrornotfound (lua_State *L, const char *path) { | 464 | static void pusherrornotfound (lua_State *L, const char *path) { |
465 | luaL_Buffer b; | 465 | luaL_Buffer b; |
466 | luaL_buffinit(L, &b); | 466 | luaL_buffinit(L, &b); |
467 | luaL_addstring(&b, "\n\tno file '"); | 467 | luaL_addstring(&b, "no file '"); |
468 | luaL_addgsub(&b, path, LUA_PATH_SEP, "'\n\tno file '"); | 468 | luaL_addgsub(&b, path, LUA_PATH_SEP, "'\n\tno file '"); |
469 | luaL_addstring(&b, "'"); | 469 | luaL_addstring(&b, "'"); |
470 | luaL_pushresult(&b); | 470 | luaL_pushresult(&b); |
@@ -591,7 +591,7 @@ static int searcher_Croot (lua_State *L) { | |||
591 | if (stat != ERRFUNC) | 591 | if (stat != ERRFUNC) |
592 | return checkload(L, 0, filename); /* real error */ | 592 | return checkload(L, 0, filename); /* real error */ |
593 | else { /* open function not found */ | 593 | else { /* open function not found */ |
594 | lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename); | 594 | lua_pushfstring(L, "no module '%s' in file '%s'", name, filename); |
595 | return 1; | 595 | return 1; |
596 | } | 596 | } |
597 | } | 597 | } |
@@ -604,7 +604,7 @@ static int searcher_preload (lua_State *L) { | |||
604 | const char *name = luaL_checkstring(L, 1); | 604 | const char *name = luaL_checkstring(L, 1); |
605 | lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); | 605 | lua_getfield(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); |
606 | if (lua_getfield(L, -1, name) == LUA_TNIL) { /* not found? */ | 606 | if (lua_getfield(L, -1, name) == LUA_TNIL) { /* not found? */ |
607 | lua_pushfstring(L, "\n\tno field package.preload['%s']", name); | 607 | lua_pushfstring(L, "no field package.preload['%s']", name); |
608 | return 1; | 608 | return 1; |
609 | } | 609 | } |
610 | else { | 610 | else { |
@@ -623,8 +623,10 @@ static void findloader (lua_State *L, const char *name) { | |||
623 | luaL_buffinit(L, &msg); | 623 | luaL_buffinit(L, &msg); |
624 | /* iterate over available searchers to find a loader */ | 624 | /* iterate over available searchers to find a loader */ |
625 | for (i = 1; ; i++) { | 625 | for (i = 1; ; i++) { |
626 | luaL_addstring(&msg, "\n\t"); /* error-message prefix */ | ||
626 | if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ | 627 | if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ |
627 | lua_pop(L, 1); /* remove nil */ | 628 | lua_pop(L, 1); /* remove nil */ |
629 | luaL_buffsub(&msg, 2); /* remove prefix */ | ||
628 | luaL_pushresult(&msg); /* create error message */ | 630 | luaL_pushresult(&msg); /* create error message */ |
629 | luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1)); | 631 | luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1)); |
630 | } | 632 | } |
@@ -636,8 +638,10 @@ static void findloader (lua_State *L, const char *name) { | |||
636 | lua_pop(L, 1); /* remove extra return */ | 638 | lua_pop(L, 1); /* remove extra return */ |
637 | luaL_addvalue(&msg); /* concatenate error message */ | 639 | luaL_addvalue(&msg); /* concatenate error message */ |
638 | } | 640 | } |
639 | else | 641 | else { /* no error message */ |
640 | lua_pop(L, 2); /* remove both returns */ | 642 | lua_pop(L, 2); /* remove both returns */ |
643 | luaL_buffsub(&msg, 2); /* remove prefix */ | ||
644 | } | ||
641 | } | 645 | } |
642 | } | 646 | } |
643 | 647 | ||