mirror of
https://github.com/lua/lua
synced 2024-11-21 20:31:22 +03:00
Small simplification in 'findloader'
Instead of allways adding a prefix for the next message, and then removing it if there is no message, add the prefix after each message.
This commit is contained in:
parent
88a50ffa71
commit
3507c3380f
@ -621,12 +621,12 @@ static void findloader (lua_State *L, const char *name) {
|
||||
!= LUA_TTABLE))
|
||||
luaL_error(L, "'package.searchers' must be a table");
|
||||
luaL_buffinit(L, &msg);
|
||||
luaL_addstring(&msg, "\n\t"); /* error-message prefix for first message */
|
||||
/* iterate over available searchers to find a loader */
|
||||
for (i = 1; ; i++) {
|
||||
luaL_addstring(&msg, "\n\t"); /* error-message prefix */
|
||||
if (l_unlikely(lua_rawgeti(L, 3, i) == LUA_TNIL)) { /* no more searchers? */
|
||||
lua_pop(L, 1); /* remove nil */
|
||||
luaL_buffsub(&msg, 2); /* remove prefix */
|
||||
luaL_buffsub(&msg, 2); /* remove last prefix */
|
||||
luaL_pushresult(&msg); /* create error message */
|
||||
luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
|
||||
}
|
||||
@ -637,11 +637,10 @@ static void findloader (lua_State *L, const char *name) {
|
||||
else if (lua_isstring(L, -2)) { /* searcher returned error message? */
|
||||
lua_pop(L, 1); /* remove extra return */
|
||||
luaL_addvalue(&msg); /* concatenate error message */
|
||||
luaL_addstring(&msg, "\n\t"); /* prefix for next message */
|
||||
}
|
||||
else { /* no error message */
|
||||
else /* no error message */
|
||||
lua_pop(L, 2); /* remove both returns */
|
||||
luaL_buffsub(&msg, 2); /* remove prefix */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user