commit ee41bc03ab0af1b1d0c4a90e172b05cda3dac38f
parent 98194db4295726069137d13b8d24fca8cbf892b6
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Thu, 22 Jun 2006 13:12:36 -0300
details
Diffstat:
6 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/lauxlib.c b/lauxlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lauxlib.c,v 1.158 2006/01/16 12:42:21 roberto Exp roberto $
+** $Id: lauxlib.c,v 1.159 2006/03/21 19:31:09 roberto Exp roberto $
** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h
*/
@@ -535,7 +535,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
return "\n";
}
if (feof(lf->f)) return NULL;
- *size = fread(lf->buff, 1, LUAL_BUFFERSIZE, lf->f);
+ *size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
return (*size > 0) ? lf->buff : NULL;
}
diff --git a/lcode.c b/lcode.c
@@ -1,5 +1,5 @@
/*
-** $Id: lcode.c,v 2.24 2005/12/22 16:19:56 roberto Exp roberto $
+** $Id: lcode.c,v 2.25 2006/03/21 19:28:49 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -221,24 +221,28 @@ static void freeexp (FuncState *fs, expdesc *e) {
}
-static int addk (FuncState *fs, TValue *k, TValue *v) {
+static int addk (FuncState *fs, TValue *key, TValue *v) {
lua_State *L = fs->L;
- TValue *idx = luaH_set(L, fs->h, k);
+ TValue *idx = luaH_set(L, fs->h, key);
Proto *f = fs->f;
- int oldsize = f->sizek;
+ int k;
if (ttisnumber(idx)) {
- lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v));
- return cast_int(nvalue(idx));
+ lua_Number n = nvalue(idx);
+ lua_number2int(k, n);
+ lua_assert(luaO_rawequalObj(&f->k[k], v));
}
else { /* constant not found; create a new entry */
- setnvalue(idx, cast_num(fs->nk));
- luaM_growvector(L, f->k, fs->nk, f->sizek, TValue,
- MAXARG_Bx, "constant table overflow");
+ int oldsize = f->sizek;
+ k = fs->nk;
+ setnvalue(idx, cast_num(k));
+ luaM_growvector(L, f->k, k, f->sizek, TValue, MAXARG_Bx,
+ "constant table overflow");
while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]);
- setobj(L, &f->k[fs->nk], v);
+ setobj(L, &f->k[k], v);
+ fs->nk++;
luaC_barrier(L, f, v);
- return fs->nk++;
}
+ return k;
}
diff --git a/liolib.c b/liolib.c
@@ -1,5 +1,5 @@
/*
-** $Id: liolib.c,v 2.72 2006/01/28 12:59:13 roberto Exp roberto $
+** $Id: liolib.c,v 2.73 2006/05/08 20:14:16 roberto Exp roberto $
** Standard I/O (and system) library
** See Copyright Notice in lua.h
*/
@@ -139,7 +139,7 @@ static int io_gc (lua_State *L) {
static int io_tostring (lua_State *L) {
FILE *f = *topfile(L);
if (f == NULL)
- lua_pushstring(L, "file (closed)");
+ lua_pushliteral(L, "file (closed)");
else
lua_pushfstring(L, "file (%p)", f);
return 1;
diff --git a/loadlib.c b/loadlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: loadlib.c,v 1.51 2005/12/29 15:32:11 roberto Exp roberto $
+** $Id: loadlib.c,v 1.52 2006/04/10 18:27:23 roberto Exp roberto $
** Dynamic library loader for Lua
** See Copyright Notice in lua.h
**
@@ -356,7 +356,7 @@ 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);
@@ -462,7 +462,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 +646,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);
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.41 2006/03/09 18:15:48 roberto Exp roberto $
+** $Id: lparser.c,v 2.42 2006/06/05 15:57:59 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -274,8 +274,8 @@ static void adjust_assign (LexState *ls, int nvars, int nexps, expdesc *e) {
static void enterlevel (LexState *ls) {
- if (++ls->L->nCcalls > LUAI_MAXCCALLS)
- luaX_lexerror(ls, "chunk has too many syntax levels", 0);
+ ++ls->L->nCcalls;
+ luaY_checklimit(ls->fs, ls->L->nCcalls, LUAI_MAXCCALLS, "syntax levels");
}
diff --git a/lstrlib.c b/lstrlib.c
@@ -1,5 +1,5 @@
/*
-** $Id: lstrlib.c,v 1.131 2006/04/12 20:13:52 roberto Exp roberto $
+** $Id: lstrlib.c,v 1.132 2006/04/26 20:41:19 roberto Exp roberto $
** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h
*/
@@ -185,7 +185,7 @@ typedef struct MatchState {
static int check_capture (MatchState *ms, int l) {
l -= '1';
if (l < 0 || l >= ms->level || ms->capture[l].len == CAP_UNFINISHED)
- return luaL_error(ms->L, "invalid capture index");
+ return luaL_error(ms->L, "invalid capture index %%%d", l + 1);
return l;
}