diff options
| -rw-r--r-- | lauxlib.c | 4 | ||||
| -rw-r--r-- | lcode.c | 26 | ||||
| -rw-r--r-- | liolib.c | 4 | ||||
| -rw-r--r-- | loadlib.c | 10 | ||||
| -rw-r--r-- | lparser.c | 6 | ||||
| -rw-r--r-- | lstrlib.c | 4 |
6 files changed, 29 insertions, 25 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp roberto $ |
| 3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -535,7 +535,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { | |||
| 535 | return "\n"; | 535 | return "\n"; |
| 536 | } | 536 | } |
| 537 | if (feof(lf->f)) return NULL; | 537 | if (feof(lf->f)) return NULL; |
| 538 | *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f); | 538 | *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f); |
| 539 | return (*size > 0) ? lf->buff : NULL; | 539 | return (*size > 0) ? lf->buff : NULL; |
| 540 | } | 540 | } |
| 541 | 541 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 2.24 2005/12/22 16:19:56 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -221,24 +221,28 @@ static void freeexp (FuncState *fs, expdesc *e) { | |||
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | 223 | ||
| 224 | static int addk (FuncState *fs, TValue *k, TValue *v) { | 224 | static int addk (FuncState *fs, TValue *key, TValue *v) { |
| 225 | lua_State *L = fs->L; | 225 | lua_State *L = fs->L; |
| 226 | TValue *idx = luaH_set(L, fs->h, k); | 226 | TValue *idx = luaH_set(L, fs->h, key); |
| 227 | Proto *f = fs->f; | 227 | Proto *f = fs->f; |
| 228 | int oldsize = f->sizek; | 228 | int k; |
| 229 | if (ttisnumber(idx)) { | 229 | if (ttisnumber(idx)) { |
| 230 | lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); | 230 | lua_Number n = nvalue(idx); |
| 231 | return cast_int(nvalue(idx)); | 231 | lua_number2int(k, n); |
| 232 | lua_assert(luaO_rawequalObj(&f->k[k], v)); | ||
| 232 | } | 233 | } |
| 233 | else { /* constant not found; create a new entry */ | 234 | else { /* constant not found; create a new entry */ |
| 234 | setnvalue(idx, cast_num(fs->nk)); | 235 | int oldsize = f->sizek; |
| 235 | luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, | 236 | k = fs->nk; |
| 236 | MAXARG_Bx, "constant table overflow"); | 237 | setnvalue(idx, cast_num(k)); |
| 238 | luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Bx, | ||
| 239 | "constant table overflow"); | ||
| 237 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); | 240 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); |
| 238 | setobj(L, &f->k[fs->nk], v); | 241 | setobj(L, &f->k[k], v); |
| 242 | fs->nk++; | ||
| 239 | luaC_barrier(L, f, v); | 243 | luaC_barrier(L, f, v); |
| 240 | return fs->nk++; | ||
| 241 | } | 244 | } |
| 245 | return k; | ||
| 242 | } | 246 | } |
| 243 | 247 | ||
| 244 | 248 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp roberto $ |
| 3 | ** Standard I/O (and system) library | 3 | ** Standard I/O (and system) library |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -139,7 +139,7 @@ static int io_gc (lua_State *L) { | |||
| 139 | static int io_tostring (lua_State *L) { | 139 | static int io_tostring (lua_State *L) { |
| 140 | FILE *f = *topfile(L); | 140 | FILE *f = *topfile(L); |
| 141 | if (f == NULL) | 141 | if (f == NULL) |
| 142 | lua_pushstring(L, "file (closed)"); | 142 | lua_pushliteral(L, "file (closed)"); |
| 143 | else | 143 | else |
| 144 | lua_pushfstring(L, "file (%p)", f); | 144 | lua_pushfstring(L, "file (%p)", f); |
| 145 | return 1; | 145 | return 1; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: loadlib.c,v 1.51 2005/12/29 15:32:11 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 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 | ** |
| @@ -356,7 +356,7 @@ static const char *findfile (lua_State *L, const char *name, | |||
| 356 | path = lua_tostring(L, -1); | 356 | path = lua_tostring(L, -1); |
| 357 | if (path == NULL) | 357 | if (path == NULL) |
| 358 | luaL_error(L, LUA_QL("package.%s") " must be a string", pname); | 358 | luaL_error(L, LUA_QL("package.%s") " must be a string", pname); |
| 359 | lua_pushstring(L, ""); /* error accumulator */ | 359 | lua_pushliteral(L, ""); /* error accumulator */ |
| 360 | while ((path = pushnexttemplate(L, path)) != NULL) { | 360 | while ((path = pushnexttemplate(L, path)) != NULL) { |
| 361 | const char *filename; | 361 | const char *filename; |
| 362 | filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); | 362 | filename = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); |
| @@ -462,7 +462,7 @@ static int ll_require (lua_State *L) { | |||
| 462 | lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); | 462 | lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); |
| 463 | if (!lua_istable(L, -1)) | 463 | if (!lua_istable(L, -1)) |
| 464 | luaL_error(L, LUA_QL("package.loaders") " must be a table"); | 464 | luaL_error(L, LUA_QL("package.loaders") " must be a table"); |
| 465 | lua_pushstring(L, ""); /* error message accumulator */ | 465 | lua_pushliteral(L, ""); /* error message accumulator */ |
| 466 | for (i=1; ; i++) { | 466 | for (i=1; ; i++) { |
| 467 | lua_rawgeti(L, -2, i); /* get a loader */ | 467 | lua_rawgeti(L, -2, i); /* get a loader */ |
| 468 | if (lua_isnil(L, -1)) | 468 | if (lua_isnil(L, -1)) |
| @@ -646,8 +646,8 @@ LUALIB_API int luaopen_package (lua_State *L) { | |||
| 646 | setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ | 646 | setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */ |
| 647 | setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ | 647 | setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */ |
| 648 | /* store config information */ | 648 | /* store config information */ |
| 649 | lua_pushstring(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" | 649 | lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n" |
| 650 | LUA_EXECDIR "\n" LUA_IGMARK); | 650 | LUA_EXECDIR "\n" LUA_IGMARK); |
| 651 | lua_setfield(L, -2, "config"); | 651 | lua_setfield(L, -2, "config"); |
| 652 | /* set field `loaded' */ | 652 | /* set field `loaded' */ |
| 653 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); | 653 | luaL_findtable(L, LUA_REGISTRYINDEX, "_LOADED", 2); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 2.41 2006/03/09 18:15:48 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.42 2006/06/05 15:57:59 roberto Exp roberto $ |
| 3 | ** Lua Parser | 3 | ** Lua Parser |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -274,8 +274,8 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) { | |||
| 274 | 274 | ||
| 275 | 275 | ||
| 276 | static void enterlevel (LexState *ls) { | 276 | static void enterlevel (LexState *ls) { |
| 277 | if (++ls->L->nCcalls > LUAI_MAXCCALLS) | 277 | ++ls->L->nCcalls; |
| 278 | luaX_lexerror(ls, "chunk has too many syntax levels", 0); | 278 | luaY_checklimit(ls->fs, ls->L->nCcalls, LUAI_MAXCCALLS, "syntax levels"); |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | 281 | ||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lstrlib.c,v 1.131 2006/04/12 20:13:52 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp roberto $ |
| 3 | ** Standard library for string operations and pattern-matching | 3 | ** Standard library for string operations and pattern-matching |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -185,7 +185,7 @@ typedef struct MatchState { | |||
| 185 | static int check_capture (MatchState *ms, int l) { | 185 | static int check_capture (MatchState *ms, int l) { |
| 186 | l -= '1'; | 186 | l -= '1'; |
| 187 | if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) | 187 | if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED) |
| 188 | return luaL_error(ms->L, "invalid capture index"); | 188 | return luaL_error(ms->L, "invalid capture index %%%d", l + 1); |
| 189 | return l; | 189 | return l; |
| 190 | } | 190 | } |
| 191 | 191 | ||
