@@ -458,13 +458,13 @@ static const char *getnextfilename (char **path, char *end) {
458458/*
459459** Given a path such as ";blabla.so;blublu.so", pushes the string
460460**
461- ** no file 'blabla.so'
461+ ** no file 'blabla.so'
462462** no file 'blublu.so'
463463*/
464464static void pusherrornotfound (lua_State * L , const char * path ) {
465465 luaL_Buffer b ;
466466 luaL_buffinit (L , & b );
467- luaL_addstring (& b , "\n\tno file '" );
467+ luaL_addstring (& b , "no file '" );
468468 luaL_addgsub (& b , path , LUA_PATH_SEP , "'\n\tno file '" );
469469 luaL_addstring (& b , "'" );
470470 luaL_pushresult (& b );
@@ -591,7 +591,7 @@ static int searcher_Croot (lua_State *L) {
591591 if (stat != ERRFUNC )
592592 return checkload (L , 0 , filename ); /* real error */
593593 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 );
595595 return 1 ;
596596 }
597597 }
@@ -604,7 +604,7 @@ static int searcher_preload (lua_State *L) {
604604 const char * name = luaL_checkstring (L , 1 );
605605 lua_getfield (L , LUA_REGISTRYINDEX , LUA_PRELOAD_TABLE );
606606 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 );
608608 return 1 ;
609609 }
610610 else {
@@ -623,8 +623,10 @@ static void findloader (lua_State *L, const char *name) {
623623 luaL_buffinit (L , & msg );
624624 /* iterate over available searchers to find a loader */
625625 for (i = 1 ; ; i ++ ) {
626+ luaL_addstring (& msg , "\n\t" ); /* error-message prefix */
626627 if (lua_rawgeti (L , 3 , i ) == LUA_TNIL ) { /* no more searchers? */
627628 lua_pop (L , 1 ); /* remove nil */
629+ luaL_buffsub (& msg , 2 ); /* remove prefix */
628630 luaL_pushresult (& msg ); /* create error message */
629631 luaL_error (L , "module '%s' not found:%s" , name , lua_tostring (L , -1 ));
630632 }
@@ -636,8 +638,10 @@ static void findloader (lua_State *L, const char *name) {
636638 lua_pop (L , 1 ); /* remove extra return */
637639 luaL_addvalue (& msg ); /* concatenate error message */
638640 }
639- else
641+ else { /* no error message */
640642 lua_pop (L , 2 ); /* remove both returns */
643+ luaL_buffsub (& msg , 2 ); /* remove prefix */
644+ }
641645 }
642646}
643647
0 commit comments