aboutsummaryrefslogtreecommitdiff
path: root/loadlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'loadlib.c')
-rw-r--r--loadlib.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/loadlib.c b/loadlib.c
index bf5ca9da..6c94aa4d 100644
--- a/loadlib.c
+++ b/loadlib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loadlib.c,v 1.115 2014/07/28 17:47:53 roberto Exp roberto $ 2** $Id: loadlib.c,v 1.116 2014/07/29 16:01:00 roberto Exp roberto $
3** Dynamic library loader for Lua 3** Dynamic library loader for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5** 5**
@@ -396,7 +396,7 @@ static const char *searchpath (lua_State *L, const char *name,
396 lua_remove(L, -2); /* remove path template */ 396 lua_remove(L, -2); /* remove path template */
397 if (readable(filename)) /* does file exist and is readable? */ 397 if (readable(filename)) /* does file exist and is readable? */
398 return filename; /* return that file name */ 398 return filename; /* return that file name */
399 lua_pushfstring(L, "\n\tno file " LUA_QS, filename); 399 lua_pushfstring(L, "\n\tno file '%s'", filename);
400 lua_remove(L, -2); /* remove file name */ 400 lua_remove(L, -2); /* remove file name */
401 luaL_addvalue(&msg); /* concatenate error msg. entry */ 401 luaL_addvalue(&msg); /* concatenate error msg. entry */
402 } 402 }
@@ -426,7 +426,7 @@ static const char *findfile (lua_State *L, const char *name,
426 lua_getfield(L, lua_upvalueindex(1), pname); 426 lua_getfield(L, lua_upvalueindex(1), pname);
427 path = lua_tostring(L, -1); 427 path = lua_tostring(L, -1);
428 if (path == NULL) 428 if (path == NULL)
429 luaL_error(L, LUA_QL("package.%s") " must be a string", pname); 429 luaL_error(L, "'package.%s' must be a string", pname);
430 return searchpath(L, name, path, ".", dirsep); 430 return searchpath(L, name, path, ".", dirsep);
431} 431}
432 432
@@ -437,8 +437,7 @@ static int checkload (lua_State *L, int stat, const char *filename) {
437 return 2; /* return open function and file name */ 437 return 2; /* return open function and file name */
438 } 438 }
439 else 439 else
440 return luaL_error(L, "error loading module " LUA_QS 440 return luaL_error(L, "error loading module '%s' from file '%s':\n\t%s",
441 " from file " LUA_QS ":\n\t%s",
442 lua_tostring(L, 1), filename, lua_tostring(L, -1)); 441 lua_tostring(L, 1), filename, lua_tostring(L, -1));
443} 442}
444 443
@@ -499,8 +498,7 @@ static int searcher_Croot (lua_State *L) {
499 if (stat != ERRFUNC) 498 if (stat != ERRFUNC)
500 return checkload(L, 0, filename); /* real error */ 499 return checkload(L, 0, filename); /* real error */
501 else { /* open function not found */ 500 else { /* open function not found */
502 lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, 501 lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename);
503 name, filename);
504 return 1; 502 return 1;
505 } 503 }
506 } 504 }
@@ -524,14 +522,13 @@ static void findloader (lua_State *L, const char *name) {
524 luaL_buffinit(L, &msg); 522 luaL_buffinit(L, &msg);
525 lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */ 523 lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */
526 if (!lua_istable(L, 3)) 524 if (!lua_istable(L, 3))
527 luaL_error(L, LUA_QL("package.searchers") " must be a table"); 525 luaL_error(L, "'package.searchers' must be a table");
528 /* iterate over available searchers to find a loader */ 526 /* iterate over available searchers to find a loader */
529 for (i = 1; ; i++) { 527 for (i = 1; ; i++) {
530 if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ 528 if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */
531 lua_pop(L, 1); /* remove nil */ 529 lua_pop(L, 1); /* remove nil */
532 luaL_pushresult(&msg); /* create error message */ 530 luaL_pushresult(&msg); /* create error message */
533 luaL_error(L, "module " LUA_QS " not found:%s", 531 luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
534 name, lua_tostring(L, -1));
535 } 532 }
536 lua_pushstring(L, name); 533 lua_pushstring(L, name);
537 lua_call(L, 1, 2); /* call it */ 534 lua_call(L, 1, 2); /* call it */
@@ -589,7 +586,7 @@ static void set_env (lua_State *L) {
589 if (lua_getstack(L, 1, &ar) == 0 || 586 if (lua_getstack(L, 1, &ar) == 0 ||
590 lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ 587 lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
591 lua_iscfunction(L, -1)) 588 lua_iscfunction(L, -1))
592 luaL_error(L, LUA_QL("module") " not called from a Lua function"); 589 luaL_error(L, "'module' not called from a Lua function");
593 lua_pushvalue(L, -2); /* copy new environment table to top */ 590 lua_pushvalue(L, -2); /* copy new environment table to top */
594 lua_setupvalue(L, -2, 1); 591 lua_setupvalue(L, -2, 1);
595 lua_pop(L, 1); /* remove function */ 592 lua_pop(L, 1); /* remove function */