aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-10-24 10:49:44 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-10-24 10:49:44 -0300
commitba9cd0d25a022cf61c0b747d8e26f9ba81201112 (patch)
treea07ae4d2d273ab438d3c7db9b61f157af5fc17cd /loadlib.c
parentb93f3b00bb76cddbf600eb399849fb0c01d197fd (diff)
downloadlua-ba9cd0d25a022cf61c0b747d8e26f9ba81201112.tar.gz
lua-ba9cd0d25a022cf61c0b747d8e26f9ba81201112.tar.bz2
lua-ba9cd0d25a022cf61c0b747d8e26f9ba81201112.zip
Change in the prefix of messages from searchers
The initial "\n\t" to properly indent a searcher message is being added by 'findloader' when building the error message, instead of being included in the original message by each searcher itself.
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/loadlib.c b/loadlib.c
index 689767f3..56167f64 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -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*/
464static void pusherrornotfound (lua_State *L, const char *path) { 464static 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