diff options
author | Lua Team <team@lua.org> | 2007-03-26 12:00:00 +0000 |
---|---|---|
committer | repogen <> | 2007-03-26 12:00:00 +0000 |
commit | d368f86a9d2a03bd5c3c0fae7f626ea8e2e6dc59 (patch) | |
tree | ae37b73d0b2f8224eb6c1cdbe5d474b511266acc /src | |
parent | cf61d326a6adbeb4ea9467af3fe4da1af8784f01 (diff) | |
download | lua-github-5.1.2-rc3.tar.gz |
Lua 5.1.2-rc35.1.2-rc3
Diffstat (limited to 'src')
-rw-r--r-- | src/loadlib.c | 27 | ||||
-rw-r--r-- | src/lvm.c | 4 | ||||
-rw-r--r-- | src/print.c | 3 |
3 files changed, 17 insertions, 17 deletions
diff --git a/src/loadlib.c b/src/loadlib.c index 08722e18..767383df 100644 --- a/src/loadlib.c +++ b/src/loadlib.c @@ -1,5 +1,5 @@ /* -** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp $ +** $Id: loadlib.c,v 1.54a 2006/07/03 20:16:49 roberto Exp $ ** Dynamic library loader for Lua ** See Copyright Notice in lua.h ** @@ -16,9 +16,9 @@ #define loadlib_c #define LUA_LIB -#include "lauxlib.h" -#include "lobject.h" #include "lua.h" + +#include "lauxlib.h" #include "lualib.h" @@ -356,15 +356,16 @@ static const char *findfile (lua_State *L, const char *name, path = lua_tostring(L, -1); if (path == NULL) luaL_error(L, LUA_QL("package.%s") " must be a string", pname); - lua_pushstring(L, ""); /* error accumulator */ + lua_pushliteral(L, ""); /* error accumulator */ while ((path = pushnexttemplate(L, path)) != NULL) { const char *filename; filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); + lua_remove(L, -2); /* remove path template */ if (readable(filename)) /* does file exist and is readable? */ return filename; /* return that file name */ - lua_pop(L, 2); /* remove path template and file name */ - luaO_pushfstring(L, "\n\tno file " LUA_QS, filename); - lua_concat(L, 2); + lua_pushfstring(L, "\n\tno file " LUA_QS, filename); + lua_remove(L, -2); /* remove file name */ + lua_concat(L, 2); /* add entry to possible error message */ } return NULL; /* not found */ } @@ -423,8 +424,8 @@ static int loader_Croot (lua_State *L) { funcname = mkfuncname(L, name); if ((stat = ll_loadfunc(L, filename, funcname)) != 0) { if (stat != ERRFUNC) loaderror(L, filename); /* real error */ - luaO_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, - name, filename); + lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, + name, filename); return 1; /* function not found */ } return 1; @@ -438,7 +439,7 @@ static int loader_preload (lua_State *L) { luaL_error(L, LUA_QL("package.preload") " must be a table"); lua_getfield(L, -1, name); if (lua_isnil(L, -1)) /* not found? */ - luaO_pushfstring(L, "\n\tno field package.preload['%s']", name); + lua_pushfstring(L, "\n\tno field package.preload['%s']", name); return 1; } @@ -462,7 +463,7 @@ static int ll_require (lua_State *L) { lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); if (!lua_istable(L, -1)) luaL_error(L, LUA_QL("package.loaders") " must be a table"); - lua_pushstring(L, ""); /* error message accumulator */ + lua_pushliteral(L, ""); /* error message accumulator */ for (i=1; ; i++) { lua_rawgeti(L, -2, i); /* get a loader */ if (lua_isnil(L, -1)) @@ -646,8 +647,8 @@ LUALIB_API int luaopen_package (lua_State *L) { setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ /* store config information */ - lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" - LUA_EXECDIR "\n" LUA_IGMARK); + lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" + LUA_EXECDIR "\n" LUA_IGMARK); lua_setfield(L, -2, "config"); /* set field `loaded' */ luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); @@ -165,7 +165,7 @@ static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2, const TValue *tm = luaT_gettmbyobj(L, p1, event); /* try first operand */ if (ttisnil(tm)) tm = luaT_gettmbyobj(L, p2, event); /* try second operand */ - if (!ttisfunction(tm)) return 0; + if (ttisnil(tm)) return 0; callTMres(L, res, tm, p1, p2); return 1; } @@ -285,7 +285,7 @@ void luaV_concat (lua_State *L, int total, int last) { if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT)) luaG_concaterror(L, top-2, top-1); } else if (tsvalue(top-1)->len == 0) /* second op is empty? */ - tostring(L, top - 2); /* result is first op (as string) */ + (void)tostring(L, top - 2); /* result is first op (as string) */ else { /* at least two string values; get as many as possible */ size_t tl = tsvalue(top-1)->len; diff --git a/src/print.c b/src/print.c index 430af836..e240cfc3 100644 --- a/src/print.c +++ b/src/print.c @@ -23,8 +23,7 @@ static void PrintString(const TString* ts) { const char* s=getstr(ts); - int n=ts->tsv.len; - int i; + size_t i,n=ts->tsv.len; putchar('"'); for (i=0; i<n; i++) { |