several small details

This commit is contained in:
Roberto Ierusalimschy
2005-05-17 16:49:15 -03:00
parent c2bb9abcec
commit 67578ec51f
20 changed files with 152 additions and 137 deletions

6
lapi.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 2.39 2005/05/05 15:34:03 roberto Exp roberto $ ** $Id: lapi.c,v 2.40 2005/05/16 19:21:11 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -846,7 +846,7 @@ LUA_API int lua_cpcall (lua_State *L, lua_CFunction func, void *ud) {
} }
LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data, LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
const char *chunkname) { const char *chunkname) {
ZIO z; ZIO z;
int status; int status;
@@ -859,7 +859,7 @@ LUA_API int lua_load (lua_State *L, lua_Chunkreader reader, void *data,
} }
LUA_API int lua_dump (lua_State *L, lua_Chunkwriter writer, void *data) { LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {
int status; int status;
TValue *o; TValue *o;
lua_lock(L); lua_lock(L);

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.131 2005/05/16 19:21:11 roberto Exp roberto $ ** $Id: lauxlib.c,v 1.132 2005/05/16 21:19:00 roberto Exp roberto $
** Auxiliary functions for building Lua libraries ** Auxiliary functions for building Lua libraries
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -47,12 +47,12 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
if (strcmp(ar.namewhat, "method") == 0) { if (strcmp(ar.namewhat, "method") == 0) {
narg--; /* do not count `self' */ narg--; /* do not count `self' */
if (narg == 0) /* error is in the self argument itself? */ if (narg == 0) /* error is in the self argument itself? */
return luaL_error(L, "calling " LUA_SM " on bad self (%s)", return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
ar.name, extramsg); ar.name, extramsg);
} }
if (ar.name == NULL) if (ar.name == NULL)
ar.name = "?"; ar.name = "?";
return luaL_error(L, "bad argument #%d to " LUA_SM " (%s)", return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)",
narg, ar.name, extramsg); narg, ar.name, extramsg);
} }
@@ -245,7 +245,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname,
luaL_setfield(L, LUA_GLOBALSINDEX, libname); luaL_setfield(L, LUA_GLOBALSINDEX, libname);
} }
else if (!lua_istable(L, -1)) else if (!lua_istable(L, -1))
luaL_error(L, "name conflict for library " LUA_SM, libname); luaL_error(L, "name conflict for library " LUA_QS, libname);
lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
lua_pushvalue(L, -2); lua_pushvalue(L, -2);
lua_setfield(L, -2, libname); /* _LOADED[modname] = new table */ lua_setfield(L, -2, libname); /* _LOADED[modname] = new table */
@@ -366,7 +366,7 @@ LUALIB_API const char *luaL_searchpath (lua_State *L, const char *name,
for (;;) { for (;;) {
const char *fname; const char *fname;
if ((p = pushnexttemplate(L, p)) == NULL) { if ((p = pushnexttemplate(L, p)) == NULL) {
lua_pushfstring(L, "no readable " LUA_SM " in path " LUA_SM "", lua_pushfstring(L, "no readable " LUA_QS " in path " LUA_QS "",
name, path); name, path);
return NULL; return NULL;
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lbaselib.c,v 1.174 2005/05/16 19:21:11 roberto Exp roberto $ ** $Id: lbaselib.c,v 1.175 2005/05/16 21:19:00 roberto Exp roberto $
** Basic library ** Basic library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -39,8 +39,8 @@ static int luaB_print (lua_State *L) {
lua_call(L, 1, 1); lua_call(L, 1, 1);
s = lua_tostring(L, -1); /* get result */ s = lua_tostring(L, -1); /* get result */
if (s == NULL) if (s == NULL)
return luaL_error(L, LUA_SM " must return a string to " LUA_SM, return luaL_error(L, LUA_QL("tostring") " must return a string to "
"tostring", "print"); LUA_QL("print"));
if (i>1) fputs("\t", stdout); if (i>1) fputs("\t", stdout);
fputs(s, stdout); fputs(s, stdout);
lua_pop(L, 1); /* pop result */ lua_pop(L, 1); /* pop result */
@@ -149,8 +149,8 @@ static int luaB_setfenv (lua_State *L) {
return 0; return 0;
} }
else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0)
luaL_error(L, LUA_SM " cannot change environment of given object", luaL_error(L,
"setfenv"); LUA_QL("setfenv") " cannot change environment of given object");
return 1; return 1;
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ldblib.c,v 1.96 2005/05/16 18:45:15 roberto Exp roberto $ ** $Id: ldblib.c,v 1.97 2005/05/16 21:19:00 roberto Exp roberto $
** Interface from Lua to its debug API ** Interface from Lua to its debug API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -48,8 +48,8 @@ static int db_setfenv (lua_State *L) {
luaL_checktype(L, 2, LUA_TTABLE); luaL_checktype(L, 2, LUA_TTABLE);
lua_settop(L, 2); lua_settop(L, 2);
if (lua_setfenv(L, 1) == 0) if (lua_setfenv(L, 1) == 0)
luaL_error(L, LUA_SM " cannot change environment of given object", luaL_error(L, LUA_QL("setfenv")
"setfenv"); " cannot change environment of given object");
return 1; return 1;
} }
@@ -348,7 +348,7 @@ static int db_errorfb (lua_State *L) {
if (ar.currentline > 0) if (ar.currentline > 0)
lua_pushfstring(L, "%d:", ar.currentline); lua_pushfstring(L, "%d:", ar.currentline);
if (*ar.namewhat != '\0') /* is there a name? */ if (*ar.namewhat != '\0') /* is there a name? */
lua_pushfstring(L, " in function " LUA_SM, ar.name); lua_pushfstring(L, " in function " LUA_QS, ar.name);
else { else {
if (*ar.what == 'm') /* main? */ if (*ar.what == 'm') /* main? */
lua_pushfstring(L, " in main chunk"); lua_pushfstring(L, " in main chunk");

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ldebug.c,v 2.18 2005/05/16 18:45:15 roberto Exp roberto $ ** $Id: ldebug.c,v 2.19 2005/05/16 21:19:00 roberto Exp roberto $
** Debug Interface ** Debug Interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -548,7 +548,7 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) {
const char *kind = (isinstack(L->ci, o)) ? const char *kind = (isinstack(L->ci, o)) ?
getobjname(L, L->ci, o - L->base, &name) : NULL; getobjname(L, L->ci, o - L->base, &name) : NULL;
if (kind) if (kind)
luaG_runerror(L, "attempt to %s %s " LUA_SM " (a %s value)", luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)",
op, kind, name, t); op, kind, name, t);
else else
luaG_runerror(L, "attempt to %s a %s value", op, t); luaG_runerror(L, "attempt to %s a %s value", op, t);

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ldump.c,v 2.4 2004/10/04 19:01:12 roberto Exp roberto $ ** $Id: ldump.c,v 2.5 2005/05/05 20:47:02 roberto Exp roberto $
** save pre-compiled Lua chunks ** save pre-compiled Lua chunks
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -21,7 +21,7 @@
typedef struct { typedef struct {
lua_State* L; lua_State* L;
lua_Chunkwriter writer; lua_Writer writer;
void* data; void* data;
int strip; int strip;
int status; int status;
@@ -164,7 +164,8 @@ static void DumpHeader(DumpState* D)
/* /*
** dump Lua function as precompiled chunk ** dump Lua function as precompiled chunk
*/ */
int luaU_dump (lua_State* L, const Proto* f, lua_Chunkwriter w, void* data, int strip) int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data,
int strip)
{ {
DumpState D; DumpState D;
D.L=L; D.L=L;

4
llex.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: llex.c,v 2.10 2005/04/27 18:37:51 roberto Exp roberto $ ** $Id: llex.c,v 2.11 2005/05/16 21:19:00 roberto Exp roberto $
** Lexical Analyzer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -102,7 +102,7 @@ void luaX_lexerror (LexState *ls, const char *msg, int token) {
luaO_chunkid(buff, getstr(ls->source), MAXSRC); luaO_chunkid(buff, getstr(ls->source), MAXSRC);
msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg);
if (token) if (token)
luaO_pushfstring(ls->L, "%s near " LUA_SM, msg, txtToken(ls, token)); luaO_pushfstring(ls->L, "%s near " LUA_QS, msg, txtToken(ls, token));
luaD_throw(ls->L, LUA_ERRSYNTAX); luaD_throw(ls->L, LUA_ERRSYNTAX);
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: loadlib.c,v 1.26 2005/04/13 17:24:20 roberto Exp roberto $ ** $Id: loadlib.c,v 1.27 2005/05/16 21:19:00 roberto Exp roberto $
** Dynamic library loader for Lua ** Dynamic library loader for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
** **
@@ -191,7 +191,7 @@ static void *ll_load (lua_State *L, const char *path) {
static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym);
if (nss == NULL) { if (nss == NULL) {
lua_pushfstring(L, "symbol " LUA_SM " not found", sym); lua_pushfstring(L, "symbol " LUA_QS " not found", sym);
return NULL; return NULL;
} }
return (lua_CFunction)NSAddressOfSymbol(nss); return (lua_CFunction)NSAddressOfSymbol(nss);
@@ -213,9 +213,9 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) {
#if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux) #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux)
#define DLMSG "'loadlib' not enabled; check your Lua installation" #define DLMSG LUA_QL("loadlib") " not enabled; check your Lua installation"
#else #else
#define DLMSG "'loadlib' not supported" #define DLMSG LUA_QL("loadlib") " not supported"
#endif #endif
static void ll_unloadlib (void *lib) { static void ll_unloadlib (void *lib) {
@@ -327,11 +327,11 @@ static int loader_Lua (lua_State *L) {
path = lua_tostring(L, -1); path = lua_tostring(L, -1);
} }
if (path == NULL) if (path == NULL)
luaL_error(L, LUA_SM " must be a string", "package.path"); luaL_error(L, LUA_QL("package.path") " must be a string");
fname = luaL_searchpath(L, fname, path); fname = luaL_searchpath(L, fname, path);
if (fname == NULL) return 0; /* library not found in this path */ if (fname == NULL) return 0; /* library not found in this path */
if (luaL_loadfile(L, fname) != 0) if (luaL_loadfile(L, fname) != 0)
luaL_error(L, "error loading package " LUA_SM " (%s)", luaL_error(L, "error loading package " LUA_QS " (%s)",
name, lua_tostring(L, -1)); name, lua_tostring(L, -1));
return 1; /* library loaded successfully */ return 1; /* library loaded successfully */
} }
@@ -345,13 +345,13 @@ static int loader_C (lua_State *L) {
lua_getfield(L, LUA_ENVIRONINDEX, "cpath"); lua_getfield(L, LUA_ENVIRONINDEX, "cpath");
path = lua_tostring(L, -1); path = lua_tostring(L, -1);
if (path == NULL) if (path == NULL)
luaL_error(L, LUA_SM " must be a string", "package.cpath"); luaL_error(L, LUA_QL("package.cpath") " must be a string");
fname = luaL_searchpath(L, fname, path); fname = luaL_searchpath(L, fname, path);
if (fname == NULL) return 0; /* library not found in this path */ if (fname == NULL) return 0; /* library not found in this path */
funcname = luaL_gsub(L, name, ".", LUA_OFSEP); funcname = luaL_gsub(L, name, ".", LUA_OFSEP);
funcname = lua_pushfstring(L, "%s%s", POF, funcname); funcname = lua_pushfstring(L, "%s%s", POF, funcname);
if (ll_loadfunc(L, fname, funcname) != 1) if (ll_loadfunc(L, fname, funcname) != 1)
luaL_error(L, "error loading package " LUA_SM " (%s)", luaL_error(L, "error loading package " LUA_QS " (%s)",
name, lua_tostring(L, -2)); name, lua_tostring(L, -2));
return 1; /* library loaded successfully */ return 1; /* library loaded successfully */
} }
@@ -360,7 +360,7 @@ static int loader_C (lua_State *L) {
static int loader_preload (lua_State *L) { static int loader_preload (lua_State *L) {
lua_getfield(L, LUA_ENVIRONINDEX, "preload"); lua_getfield(L, LUA_ENVIRONINDEX, "preload");
if (!lua_istable(L, -1)) if (!lua_istable(L, -1))
luaL_error(L, LUA_SM " must be a table", "package.preload"); luaL_error(L, LUA_QL("package.preload") " must be a table");
lua_getfield(L, -1, luaL_checkstring(L, 1)); lua_getfield(L, -1, luaL_checkstring(L, 1));
return 1; return 1;
} }
@@ -380,11 +380,11 @@ static int ll_require (lua_State *L) {
/* iterate over available loaders */ /* iterate over available loaders */
lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); lua_getfield(L, LUA_ENVIRONINDEX, "loaders");
if (!lua_istable(L, -1)) if (!lua_istable(L, -1))
luaL_error(L, LUA_SM " must be a table", "package.loaders"); luaL_error(L, LUA_QL("package.loaders") " must be a table");
for (i=1;; i++) { for (i=1;; i++) {
lua_rawgeti(L, -1, i); /* get a loader */ lua_rawgeti(L, -1, i); /* get a loader */
if (lua_isnil(L, -1)) if (lua_isnil(L, -1))
return luaL_error(L, "package " LUA_SM " not found", name); return luaL_error(L, "package " LUA_QS " not found", name);
lua_pushstring(L, name); lua_pushstring(L, name);
lua_call(L, 1, 1); /* call it */ lua_call(L, 1, 1); /* call it */
if (lua_isnil(L, -1)) lua_pop(L, 1); if (lua_isnil(L, -1)) lua_pop(L, 1);
@@ -423,7 +423,7 @@ static int ll_module (lua_State *L) {
luaL_setfield(L, LUA_GLOBALSINDEX, modname); luaL_setfield(L, LUA_GLOBALSINDEX, modname);
} }
else if (!lua_istable(L, -1)) else if (!lua_istable(L, -1))
return luaL_error(L, "name conflict for module " LUA_SM, modname); return luaL_error(L, "name conflict for module " LUA_QS, modname);
/* check whether table already has a _NAME field */ /* check whether table already has a _NAME field */
lua_getfield(L, -1, "_NAME"); lua_getfield(L, -1, "_NAME");
if (!lua_isnil(L, -1)) /* is table an initialized module? */ if (!lua_isnil(L, -1)) /* is table an initialized module? */

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: loslib.c,v 1.7 2005/03/18 18:02:04 roberto Exp roberto $ ** $Id: loslib.c,v 1.8 2005/05/16 21:19:00 roberto Exp roberto $
** Standard Operating System library ** Standard Operating System library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -113,7 +113,7 @@ static int getfield (lua_State *L, const char *key, int d) {
res = (int)lua_tointeger(L, -1); res = (int)lua_tointeger(L, -1);
else { else {
if (d < 0) if (d < 0)
return luaL_error(L, "field " LUA_SM " missing in date table", key); return luaL_error(L, "field " LUA_QS " missing in date table", key);
res = d; res = d;
} }
lua_pop(L, 1); lua_pop(L, 1);
@@ -151,7 +151,7 @@ static int io_date (lua_State *L) {
if (strftime(b, sizeof(b), s, stm)) if (strftime(b, sizeof(b), s, stm))
lua_pushstring(L, b); lua_pushstring(L, b);
else else
return luaL_error(L, LUA_SM " format too long", "date"); return luaL_error(L, LUA_QL("date") " format too long");
} }
return 1; return 1;
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lparser.c,v 2.25 2005/05/05 20:47:02 roberto Exp roberto $ ** $Id: lparser.c,v 2.26 2005/05/16 21:19:00 roberto Exp roberto $
** Lua Parser ** Lua Parser
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -82,7 +82,7 @@ static void anchor_token (LexState *ls) {
static void error_expected (LexState *ls, int token) { static void error_expected (LexState *ls, int token) {
luaX_syntaxerror(ls, luaX_syntaxerror(ls,
luaO_pushfstring(ls->L, LUA_SM " expected", luaX_token2str(ls, token))); luaO_pushfstring(ls->L, LUA_QS " expected", luaX_token2str(ls, token)));
} }
@@ -125,7 +125,7 @@ static void check_match (LexState *ls, int what, int who, int where) {
error_expected(ls, what); error_expected(ls, what);
else { else {
luaX_syntaxerror(ls, luaO_pushfstring(ls->L, luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
LUA_SM " expected (to close " LUA_SM " at line %d)", LUA_QS " expected (to close " LUA_QS " at line %d)",
luaX_token2str(ls, what), luaX_token2str(ls, who), where)); luaX_token2str(ls, what), luaX_token2str(ls, who), where));
} }
} }
@@ -577,7 +577,7 @@ static void parlist (LexState *ls) {
f->is_vararg = 1; f->is_vararg = 1;
break; break;
} }
default: luaX_syntaxerror(ls, "<name> or '...' expected"); default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
} }
} while (!f->is_vararg && testnext(ls, ',')); } while (!f->is_vararg && testnext(ls, ','));
} }
@@ -765,7 +765,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
case TK_DOTS: { /* vararg */ case TK_DOTS: { /* vararg */
FuncState *fs = ls->fs; FuncState *fs = ls->fs;
check_condition(ls, fs->f->is_vararg, check_condition(ls, fs->f->is_vararg,
"cannot use '...' outside a vararg function"); "cannot use " LUA_QL("...") " outside a vararg function");
fs->f->is_vararg = NEWSTYLEVARARG; fs->f->is_vararg = NEWSTYLEVARARG;
init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0));
break; break;
@@ -1017,7 +1017,7 @@ static void whilestat (LexState *ls, int line) {
fs->jpc = NO_JUMP; fs->jpc = NO_JUMP;
sizeexp = fs->pc - expinit; /* size of expression code */ sizeexp = fs->pc - expinit; /* size of expression code */
if (sizeexp > LUAI_MAXEXPWHILE) if (sizeexp > LUAI_MAXEXPWHILE)
luaX_syntaxerror(ls, "'while' condition too complex"); luaX_syntaxerror(ls, LUA_QL("while") " condition too complex");
for (i = 0; i < sizeexp; i++) /* save `exp' code */ for (i = 0; i < sizeexp; i++) /* save `exp' code */
codeexp[i] = fs->f->code[expinit + i]; codeexp[i] = fs->f->code[expinit + i];
fs->pc = expinit; /* remove `exp' code */ fs->pc = expinit; /* remove `exp' code */
@@ -1141,7 +1141,7 @@ static void forstat (LexState *ls, int line) {
switch (ls->t.token) { switch (ls->t.token) {
case '=': fornum(ls, varname, line); break; case '=': fornum(ls, varname, line); break;
case ',': case TK_IN: forlist(ls, varname); break; case ',': case TK_IN: forlist(ls, varname); break;
default: luaX_syntaxerror(ls, "'=' or 'in' expected"); default: luaX_syntaxerror(ls, LUA_QL("=") " or " LUA_QL("in") " expected");
} }
check_match(ls, TK_END, TK_FOR, line); check_match(ls, TK_END, TK_FOR, line);
leaveblock(fs); /* loop scope (`break' jumps to this point) */ leaveblock(fs); /* loop scope (`break' jumps to this point) */

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lstrlib.c,v 1.113 2005/05/16 19:21:11 roberto Exp roberto $ ** $Id: lstrlib.c,v 1.114 2005/05/16 21:19:00 roberto Exp roberto $
** Standard library for string operations and pattern-matching ** Standard library for string operations and pattern-matching
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -200,14 +200,14 @@ static const char *classend (MatchState *ms, const char *p) {
switch (*p++) { switch (*p++) {
case L_ESC: { case L_ESC: {
if (*p == '\0') if (*p == '\0')
luaL_error(ms->L, "malformed pattern (ends with '%%')"); luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")");
return p+1; return p+1;
} }
case '[': { case '[': {
if (*p == '^') p++; if (*p == '^') p++;
do { /* look for a `]' */ do { /* look for a `]' */
if (*p == '\0') if (*p == '\0')
luaL_error(ms->L, "malformed pattern (missing ']')"); luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")");
if (*(p++) == L_ESC && *p != '\0') if (*(p++) == L_ESC && *p != '\0')
p++; /* skip escapes (e.g. `%]') */ p++; /* skip escapes (e.g. `%]') */
} while (*p != ']'); } while (*p != ']');
@@ -382,7 +382,8 @@ static const char *match (MatchState *ms, const char *s, const char *p) {
const char *ep; char previous; const char *ep; char previous;
p += 2; p += 2;
if (*p != '[') if (*p != '[')
luaL_error(ms->L, "missing '[' after '%%f' in pattern"); luaL_error(ms->L, "missing " LUA_QL("[") " after "
LUA_QL("%%f") " in pattern");
ep = classend(ms, p); /* points to what is next */ ep = classend(ms, p); /* points to what is next */
previous = (s == ms->src_init) ? '\0' : *(s-1); previous = (s == ms->src_init) ? '\0' : *(s-1);
if (matchbracketclass(uchar(previous), p, ep-1) || if (matchbracketclass(uchar(previous), p, ep-1) ||
@@ -741,7 +742,7 @@ static int str_format (lua_State *L) {
} }
} }
default: { /* also treat cases `pnLlh' */ default: { /* also treat cases `pnLlh' */
return luaL_error(L, "invalid option to " LUA_SM, "format"); return luaL_error(L, "invalid option to " LUA_QL("format"));
} }
} }
luaL_addlstring(&b, buff, strlen(buff)); luaL_addlstring(&b, buff, strlen(buff));

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ltable.c,v 2.21 2005/05/03 19:30:17 roberto Exp roberto $ ** $Id: ltable.c,v 2.22 2005/05/16 21:19:00 roberto Exp roberto $
** Lua tables (hash) ** Lua tables (hash)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -151,7 +151,7 @@ static int findindex (lua_State *L, Table *t, StkId key) {
} }
else n = gnext(n); else n = gnext(n);
} while (n); } while (n);
luaG_runerror(L, "invalid key to " LUA_SM, "next"); /* key not found */ luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */
return 0; /* to avoid warnings */ return 0; /* to avoid warnings */
} }
} }

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: ltablib.c,v 1.29 2005/03/28 17:17:53 roberto Exp roberto $ ** $Id: ltablib.c,v 1.30 2005/05/16 21:19:00 roberto Exp roberto $
** Library for Table Manipulation ** Library for Table Manipulation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -65,7 +65,7 @@ static int setn (lua_State *L) {
#ifndef luaL_setn #ifndef luaL_setn
luaL_setn(L, 1, luaL_checkint(L, 2)); luaL_setn(L, 1, luaL_checkint(L, 2));
#else #else
luaL_error(L, LUA_SM " is obsolete", "setn"); luaL_error(L, LUA_QL("setn") " is obsolete");
#endif #endif
lua_pushvalue(L, 1); lua_pushvalue(L, 1);
return 1; return 1;

15
lua.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lua.c,v 1.142 2005/04/13 17:24:20 roberto Exp roberto $ ** $Id: lua.c,v 1.143 2005/05/16 21:19:00 roberto Exp roberto $
** Lua stand-alone interpreter ** Lua stand-alone interpreter
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -44,9 +44,9 @@ static void print_usage (void) {
"usage: %s [options] [script [args]].\n" "usage: %s [options] [script [args]].\n"
"Available options are:\n" "Available options are:\n"
" - execute stdin as a file\n" " - execute stdin as a file\n"
" -e stat execute string 'stat'\n" " -e stat execute string " LUA_QL("stat") "\n"
" -i enter interactive mode after executing 'script'\n" " -i enter interactive mode after executing " LUA_QL("script") "\n"
" -l name require library 'name'\n" " -l name require library " LUA_QL("name") "\n"
" -v show version information\n" " -v show version information\n"
" -w trap access to undefined globals\n" " -w trap access to undefined globals\n"
" -- stop handling options\n" , " -- stop handling options\n" ,
@@ -209,8 +209,9 @@ static void dotty (lua_State *L) {
lua_getglobal(L, "print"); lua_getglobal(L, "print");
lua_insert(L, 1); lua_insert(L, 1);
if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0)
l_message(progname, lua_pushfstring(L, "error calling 'print' (%s)", l_message(progname, lua_pushfstring(L,
lua_tostring(L, -1))); "error calling " LUA_QL("print") " (%s)",
lua_tostring(L, -1)));
} }
} }
lua_settop(L, 0); /* clear stack */ lua_settop(L, 0); /* clear stack */
@@ -222,7 +223,7 @@ static void dotty (lua_State *L) {
static int checkvar (lua_State *L) { static int checkvar (lua_State *L) {
const char *name = lua_tostring(L, 2); const char *name = lua_tostring(L, 2);
if (name) if (name)
luaL_error(L, "attempt to access undefined variable " LUA_SM, name); luaL_error(L, "attempt to access undefined variable " LUA_QS, name);
return 0; return 0;
} }

43
lua.h
View File

@@ -1,8 +1,8 @@
/* /*
** $Id: lua.h,v 1.206 2005/05/05 20:47:02 roberto Exp roberto $ ** $Id: lua.h,v 1.207 2005/05/16 19:21:11 roberto Exp roberto $
** Lua - An Extensible Extension Language ** Lua - An Extensible Extension Language
** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
** http://www.lua.org mailto:info@lua.org ** http://www.lua.org
** See Copyright Notice at the end of this file ** See Copyright Notice at the end of this file
*/ */
@@ -55,10 +55,9 @@ typedef int (*lua_CFunction) (lua_State *L);
/* /*
** functions that read/write blocks when loading/dumping Lua chunks ** functions that read/write blocks when loading/dumping Lua chunks
*/ */
typedef const char * (*lua_Chunkreader) (lua_State *L, void *ud, size_t *sz); typedef const char * (*lua_Reader) (lua_State *L, void *ud, size_t *sz);
typedef int (*lua_Chunkwriter) (lua_State *L, const void* p, typedef int (*lua_Writer) (lua_State *L, const void* p, size_t sz, void* ud);
size_t sz, void* ud);
/* /*
@@ -70,17 +69,17 @@ typedef void * (*lua_Alloc) (void *ud, void *ptr, size_t osize, size_t nsize);
/* /*
** basic types ** basic types
*/ */
#define LUA_TNONE (-1) #define LUA_TNONE (-1)
#define LUA_TNIL 0 #define LUA_TNIL 0
#define LUA_TBOOLEAN 1 #define LUA_TBOOLEAN 1
#define LUA_TLIGHTUSERDATA 2 #define LUA_TLIGHTUSERDATA 2
#define LUA_TNUMBER 3 #define LUA_TNUMBER 3
#define LUA_TSTRING 4 #define LUA_TSTRING 4
#define LUA_TTABLE 5 #define LUA_TTABLE 5
#define LUA_TFUNCTION 6 #define LUA_TFUNCTION 6
#define LUA_TUSERDATA 7 #define LUA_TUSERDATA 7
#define LUA_TTHREAD 8 #define LUA_TTHREAD 8
@@ -147,7 +146,6 @@ LUA_API int (lua_lessthan) (lua_State *L, int idx1, int idx2);
LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx); LUA_API lua_Number (lua_tonumber) (lua_State *L, int idx);
LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx); LUA_API lua_Integer (lua_tointeger) (lua_State *L, int idx);
LUA_API int (lua_toboolean) (lua_State *L, int idx); LUA_API int (lua_toboolean) (lua_State *L, int idx);
LUA_API const char *(lua_tostring) (lua_State *L, int idx);
LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len); LUA_API const char *(lua_tolstring) (lua_State *L, int idx, size_t *len);
LUA_API size_t (lua_objsize) (lua_State *L, int idx); LUA_API size_t (lua_objsize) (lua_State *L, int idx);
LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx); LUA_API lua_CFunction (lua_tocfunction) (lua_State *L, int idx);
@@ -202,11 +200,11 @@ LUA_API int (lua_setfenv) (lua_State *L, int idx);
*/ */
LUA_API void (lua_call) (lua_State *L, int nargs, int nresults); LUA_API void (lua_call) (lua_State *L, int nargs, int nresults);
LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc); LUA_API int (lua_pcall) (lua_State *L, int nargs, int nresults, int errfunc);
LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud); LUA_API int (lua_cpcall) (lua_State *L, lua_CFunction func, void *ud);
LUA_API int (lua_load) (lua_State *L, lua_Chunkreader reader, void *dt, LUA_API int (lua_load) (lua_State *L, lua_Reader reader, void *dt,
const char *chunkname); const char *chunkname);
LUA_API int (lua_dump) (lua_State *L, lua_Chunkwriter writer, void *data); LUA_API int (lua_dump) (lua_State *L, lua_Writer writer, void *data);
/* /*
@@ -290,7 +288,8 @@ LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
#define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0) #define lua_getgccount(L) lua_gc(L, LUA_GCCOUNT, 0)
#define lua_Chunkreader lua_Reader
#define lua_Chunkwriter lua_Writer
@@ -321,6 +320,8 @@ LUA_API lua_Alloc (lua_getallocf) (lua_State *L, void **ud);
typedef struct lua_Debug lua_Debug; /* activation record */ typedef struct lua_Debug lua_Debug; /* activation record */
/* Functions to be called by the debuger in specific events */
typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar); typedef void (*lua_Hook) (lua_State *L, lua_Debug *ar);
@@ -337,8 +338,6 @@ LUA_API int lua_gethookmask (lua_State *L);
LUA_API int lua_gethookcount (lua_State *L); LUA_API int lua_gethookcount (lua_State *L);
#define LUA_IDSIZE 60
struct lua_Debug { struct lua_Debug {
int event; int event;
const char *name; /* (n) */ const char *name; /* (n) */
@@ -358,7 +357,7 @@ struct lua_Debug {
/****************************************************************************** /******************************************************************************
* Copyright (C) 1994-2004 Tecgraf, PUC-Rio. All rights reserved. * Copyright (C) 1994-2005 Tecgraf, PUC-Rio. All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining * Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the * a copy of this software and associated documentation files (the

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: luaconf.h,v 1.47 2005/05/03 19:30:17 roberto Exp roberto $ ** $Id: luaconf.h,v 1.48 2005/05/16 21:19:00 roberto Exp roberto $
** Configuration file for Lua ** Configuration file for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -13,14 +13,12 @@
/* /*
** {================================================================== ** ==================================================================
** Index (search for keyword to find corresponding entry) ** Search for "@@" to find all configurable definitions.
** =================================================================== ** ===================================================================
*/ */
/* }================================================================== */
/* /*
@@ -67,17 +65,17 @@
/* /*
@@ LUA_PATHSEP is the character that separates templates in a path. @@ LUA_PATHSEP is the character that separates templates in a path.
** CHANGE it if for some reason your system cannot use a ** CHANGE it if for some reason your system cannot use a
** semicolon. (E.g., a semicolon may be a too common character in ** semicolon. (E.g., if a semicolon is a common character in
** file/directory names.) Probably you do not need to change this. ** file/directory names.) Probably you do not need to change this.
*/ */
#define LUA_PATHSEP ';' #define LUA_PATHSEP ';'
/* /*
@@ LUA_PATH_MARK is ths string that marks the substitution points in a @@ LUA_PATH_MARK is the string that marks the substitution points in a
@* template. @* template.
** CHANGE it if for some reason your system cannot use an interogation ** CHANGE it if for some reason your system cannot use an interrogation
** mark. (E.g., an interogation mark may be a too common character in ** mark. (E.g., if an interogation mark is a common character in
** file/directory names.) Probably you do not need to change this. ** file/directory names.) Probably you do not need to change this.
*/ */
#define LUA_PATH_MARK "?" #define LUA_PATH_MARK "?"
@@ -113,16 +111,16 @@
#endif #endif
/* more often then not the libs go together with the core */ /* more often than not the libs go together with the core */
#define LUALIB_API LUA_API #define LUALIB_API LUA_API
/* /*
@@ LUAI_FUNC is a mark for all extern functions that are not to be @@ LUAI_FUNC is a mark for all extern functions that are not to be
@* exported to outside modules. @* exported to outside modules.
** CHANGE it if you need to mark them in some special way. Gcc mark ** CHANGE it if you need to mark them in some special way. Gcc (versions
** them as "hidden" to optimize their call when Lua is compiled as a ** 3.2 and later) mark them as "hidden" to optimize their call when Lua
** shared library. ** is compiled as a shared library.
*/ */
#if defined(luaall_c) #if defined(luaall_c)
#define LUAI_FUNC static #define LUAI_FUNC static
@@ -141,10 +139,20 @@
/* /*
@@ LUA_SM describes how variable strings appear in error messages. @@ LUA_QL describes how error messages quote program elements.
** CHANGE it if you want a different appearance. ** CHANGE it if you want a different appearance.
*/ */
#define LUA_SM "'%s'" #define LUA_QL(x) "'" x "'"
#define LUA_QS LUA_QL("%s")
/*
@@ LUA_IDSIZE gives the maximum size for the description of the source
@* of a function in debug information.
** CHANGE it if you a different size.
*/
#define LUA_IDSIZE 60
/* /*
** {================================================================== ** {==================================================================
@@ -155,8 +163,8 @@
#if defined(lua_c) || defined(luaall_c) #if defined(lua_c) || defined(luaall_c)
/* /*
@@ lua_stdin_is_tty is a function to detect whether the standard input is @@ lua_stdin_is_tty detects whether the standard input is a 'tty' (that
@* a 'tty' (that is, is interactive). @* is, whether we're running lua interactively).
** CHANGE it if you have a better definition for non-POSIX/non-Windows ** CHANGE it if you have a better definition for non-POSIX/non-Windows
** systems. ** systems.
*/ */
@@ -191,7 +199,8 @@
/* /*
@@ LUA_MAXINPUT is the maximum length for an input line @@ LUA_MAXINPUT is the maximum length for an input line in the
@* stand-alone interpreter.
** CHANGE it if you need longer lines. ** CHANGE it if you need longer lines.
*/ */
#define LUA_MAXINPUT 512 #define LUA_MAXINPUT 512
@@ -200,10 +209,10 @@
/* /*
@@ lua_readline defines how to show a prompt and then read a line from @@ lua_readline defines how to show a prompt and then read a line from
@* the standard input. @* the standard input.
@@ lua_saveline defines how to "save" a read line. @@ lua_saveline defines how to "save" a read line in a "history".
@@ lua_freeline defines how to free a line read by lua_readline. @@ lua_freeline defines how to free a line read by lua_readline.
** CHANGE them if you want to improve this functionality (e.g., using GNU ** CHANGE them if you want to improve this functionality (e.g., by using
** readline and history facilities). ** GNU readline and history facilities).
*/ */
#if !defined(__STRICT_ANSI__) && defined(LUA_USE_READLINE) #if !defined(__STRICT_ANSI__) && defined(LUA_USE_READLINE)
#include <stdio.h> #include <stdio.h>
@@ -317,14 +326,14 @@
/* /*
@@ LUAI_UINT32 is an unsigned integer with at least 32 bits. @@ LUAI_UINT32 is an unsigned integer with at least 32 bits.
@@ LUAI_INT32 is an signed integer with at least 32 bits. @@ LUAI_INT32 is an signed integer with at least 32 bits.
@@ LUAI_UMEM is an an unsigned integer big enough to count the total @@ LUAI_UMEM is an unsigned integer big enough to count the total
@* memory used by Lua. @* memory used by Lua.
@@ LUAI_MEM is an a signed integer big enough to count the total memory @@ LUAI_MEM is a signed integer big enough to count the total memory
@* used by Lua. @* used by Lua.
** CHANGE here if for some weird reason the default definitions are not ** CHANGE here if for some weird reason the default definitions are not
** good enough for your machine. (The 'else' definition always works, ** good enough for your machine. (The definitions in the 'else'
** but may waste space on machines with 64-bit longs.) Probably you do ** part always works, but may waste space on machines with 64-bit
** not need to change this. ** longs.) Probably you do not need to change this.
*/ */
#if LUAI_BITSINT >= 32 #if LUAI_BITSINT >= 32
#define LUAI_UINT32 unsigned int #define LUAI_UINT32 unsigned int
@@ -352,7 +361,8 @@
/* /*
@@ LUAI_MAXCSTACK limits the number of slots that a C function can use. @@ LUAI_MAXCSTACK limits the number of Lua stack slots that a C function
@* can use.
** CHANGE it if you need lots of (Lua) stack space for your C ** CHANGE it if you need lots of (Lua) stack space for your C
** functions. This limit is arbitrary; its only purpose is to stop C ** functions. This limit is arbitrary; its only purpose is to stop C
** functions to consume unlimited stack space. ** functions to consume unlimited stack space.
@@ -379,7 +389,7 @@
@@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and @@ LUAI_MAXCCALLS is the maximum depth for nested C calls (short) and
@* syntactical nested non-terminals in a program. @* syntactical nested non-terminals in a program.
*/ */
#define LUAI_MAXCCALLS 200 #define LUAI_MAXCCALLS 200
/* /*
@@ -420,7 +430,7 @@
** in C is extremely slow, so any alternative is worth trying. ** in C is extremely slow, so any alternative is worth trying.
*/ */
/* On a GNU/Pentium, resort to assembler */ /* On a gcc/Pentium, resort to assembler */
#if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__i386) #if !defined(__STRICT_ANSI__) && defined(__GNUC__) && defined(__i386)
#define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st") #define lua_number2int(i,d) __asm__ ("fistpl %0":"=m"(i):"t"(d):"st")
@@ -433,10 +443,10 @@
/* on Pentium machines compliant with C99, you can try lrint */ /* on Pentium machines compliant with C99, you can try lrint */
#elif defined (__i386) && defined(__STDC_VERSION__) && \ #elif defined (__i386) && defined(__STDC_VERSION__) && \
(__STDC_VERSION__ >= 199900L) (__STDC_VERSION__ >= 199900L)
#define lua_number2int(i,d) ((i)=lrint(d)) #define lua_number2int(i,d) ((i)=lrint(d))
/* this option always work, but may be slow */ /* this option always works, but may be slow */
#else #else
#define lua_number2int(i,d) ((i)=(int)(d)) #define lua_number2int(i,d) ((i)=(int)(d))
@@ -447,14 +457,14 @@
@@ lua_number2integer is a macro to convert lua_Number to lua_Integer. @@ lua_number2integer is a macro to convert lua_Number to lua_Integer.
** CHANGE (see lua_number2int). ** CHANGE (see lua_number2int).
*/ */
/* On a GNU or Windows/Pentium, resort to assembler */ /* On a gcc or Windows/Pentium, resort to assembler */
#if (defined(__GNUC__) && defined(__i386)) || \ #if (defined(__GNUC__) && defined(__i386)) || \
(defined(_MSC_VER) && defined(_M_IX86)) (defined(_MSC_VER) && defined(_M_IX86))
#define lua_number2integer(i,n) lua_number2int(i, n) #define lua_number2integer(i,n) lua_number2int(i, n)
/* this option always work, but may be slow */ /* this option always works, but may be slow */
#else #else
#define lua_number2integer(i,d) ((i)=(lua_Integer)(d)) #define lua_number2integer(i,d) ((i)=(lua_Integer)(d))
#endif #endif
@@ -462,6 +472,7 @@
/* /*
** {================================================================== ** {==================================================================
@@ LUA_NUMBER is the type of numbers in Lua.
** CHANGE the following definitions only if you want to build Lua ** CHANGE the following definitions only if you want to build Lua
** with a number type different from double. You may also need to ** with a number type different from double. You may also need to
** change lua_number2int & lua_number2integer. ** change lua_number2int & lua_number2integer.
@@ -470,7 +481,6 @@
/* /*
@@ LUA_NUMBER is the type of numbers in Lua.
@@ LUAI_UACNUMBER is the result of an 'usual argument conversion' @@ LUAI_UACNUMBER is the result of an 'usual argument conversion'
@* over a number. @* over a number.
*/ */
@@ -512,9 +522,9 @@
/* /*
@@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment. @@ LUAI_USER_ALIGNMENT_T is a type that requires maximum alignment.
** CHANGE it if your system requires alignments larger than double. (For ** CHANGE it if your system requires alignments larger than double. (For
** instance, if your system supports long double and those long doubles ** instance, if your system supports long doubles and they must be
** must be aligned in 16-byte boundaries, then you should add long ** aligned in 16-byte boundaries, then you should add long double in the
** double in the union.) Probably you do not need to change this. ** union.) Probably you do not need to change this.
*/ */
#define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; } #define LUAI_USER_ALIGNMENT_T union { double u; void *s; long l; }
@@ -535,7 +545,7 @@
#define luai_jmpbuf int /* dummy variable */ #define luai_jmpbuf int /* dummy variable */
#elif !defined(__STRICT_ANSI__) && (defined(unix) || defined(__unix) || \ #elif !defined(__STRICT_ANSI__) && (defined(unix) || defined(__unix) || \
defined(__unix__)) defined(__unix__))
/* in Unix, try _longjmp/_setjmp (more efficient) */ /* in Unix, try _longjmp/_setjmp (more efficient) */
#define LUAI_THROW(L,c) _longjmp((c)->b, 1) #define LUAI_THROW(L,c) _longjmp((c)->b, 1)
#define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a } #define LUAI_TRY(L,c,a) if (_setjmp((c)->b) == 0) { a }
@@ -589,7 +599,7 @@
** dynamic-library system for your platform (either Windows' DLL, Mac's ** dynamic-library system for your platform (either Windows' DLL, Mac's
** dyld, or Unix's dlopen). If your system is some kind of Unix, there ** dyld, or Unix's dlopen). If your system is some kind of Unix, there
** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for ** is a good chance that it has dlopen, so LUA_DL_DLOPEN will work for
** it. To use dlopen you also need to adapt the makefile (probably ** it. To use dlopen you also need to adapt the src/Makefile (probably
** adding -ldl to the linker options), so Lua does not select it ** adding -ldl to the linker options), so Lua does not select it
** automatically. (When you change the makefile to add -ldl, you must ** automatically. (When you change the makefile to add -ldl, you must
** also add -DLUA_USE_DLOPEN.) ** also add -DLUA_USE_DLOPEN.)
@@ -611,7 +621,7 @@
@@ lua_lock/lua_unlock are macros for thread synchronization inside the @@ lua_lock/lua_unlock are macros for thread synchronization inside the
@* Lua core. This is an attempt to simplify the implementation of a @* Lua core. This is an attempt to simplify the implementation of a
@* multithreaded version of Lua. @* multithreaded version of Lua.
** CHANGE them only if you know what you are doing. all accesses to ** CHANGE them only if you know what you are doing. All accesses to
** the global state and to global objects are synchronized. Because ** the global state and to global objects are synchronized. Because
** threads can read the stack of other threads (when running garbage ** threads can read the stack of other threads (when running garbage
** collection), a thread must also synchronize any write-access to its ** collection), a thread must also synchronize any write-access to its
@@ -650,7 +660,10 @@
/* =================================================================== */ /* =================================================================== */
/* Local configuration */ /*
** Local configuration. You can use this space to add your redefinitions
** without modifying the main part of the file.
*/

View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lundump.h,v 1.34 2003/08/25 19:51:54 roberto Exp roberto $ ** $Id: lundump.h,v 1.35 2005/04/25 19:24:10 roberto Exp roberto $
** load pre-compiled Lua chunks ** load pre-compiled Lua chunks
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -18,7 +18,7 @@ LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff,
LUAI_FUNC int luaU_endianness (void); LUAI_FUNC int luaU_endianness (void);
/* dump one chunk; from ldump.c */ /* dump one chunk; from ldump.c */
LUAI_FUNC int luaU_dump (lua_State* L, const Proto* Main, lua_Chunkwriter w, LUAI_FUNC int luaU_dump (lua_State* L, const Proto* Main, lua_Writer w,
void* data, int strip); void* data, int strip);
/* print one chunk; from print.c */ /* print one chunk; from print.c */

8
lvm.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.42 2005/05/04 20:42:28 roberto Exp roberto $ ** $Id: lvm.c,v 2.43 2005/05/16 21:19:00 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -688,11 +688,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
const TValue *pstep = ra+2; const TValue *pstep = ra+2;
L->savedpc = pc; /* next steps may throw errors */ L->savedpc = pc; /* next steps may throw errors */
if (!tonumber(init, ra)) if (!tonumber(init, ra))
luaG_runerror(L, "'for' initial value must be a number"); luaG_runerror(L, LUA_QL("for") " initial value must be a number");
else if (!tonumber(plimit, ra+1)) else if (!tonumber(plimit, ra+1))
luaG_runerror(L, "'for' limit must be a number"); luaG_runerror(L, LUA_QL("for") " limit must be a number");
else if (!tonumber(pstep, ra+2)) else if (!tonumber(pstep, ra+2))
luaG_runerror(L, "'for' step must be a number"); luaG_runerror(L, LUA_QL("for") " step must be a number");
setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep)));
dojump(L, pc, GETARG_sBx(i)); dojump(L, pc, GETARG_sBx(i));
continue; continue;

4
lzio.c
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lzio.c,v 1.28 2003/11/18 10:44:53 roberto Exp roberto $ ** $Id: lzio.c,v 1.29 2004/04/30 20:13:38 roberto Exp roberto $
** a generic input stream interface ** a generic input stream interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -43,7 +43,7 @@ int luaZ_lookahead (ZIO *z) {
} }
void luaZ_init (lua_State *L, ZIO *z, lua_Chunkreader reader, void *data) { void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) {
z->L = L; z->L = L;
z->reader = reader; z->reader = reader;
z->data = data; z->data = data;

6
lzio.h
View File

@@ -1,5 +1,5 @@
/* /*
** $Id: lzio.h,v 1.19 2003/10/03 16:05:34 roberto Exp roberto $ ** $Id: lzio.h,v 1.20 2005/04/25 19:24:10 roberto Exp roberto $
** Buffered streams ** Buffered streams
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@@ -44,7 +44,7 @@ typedef struct Mbuffer {
LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n);
LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Chunkreader reader, LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader,
void *data); void *data);
LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */
LUAI_FUNC int luaZ_lookahead (ZIO *z); LUAI_FUNC int luaZ_lookahead (ZIO *z);
@@ -56,7 +56,7 @@ LUAI_FUNC int luaZ_lookahead (ZIO *z);
struct Zio { struct Zio {
size_t n; /* bytes still unread */ size_t n; /* bytes still unread */
const char *p; /* current position in buffer */ const char *p; /* current position in buffer */
lua_Chunkreader reader; lua_Reader reader;
void* data; /* additional data */ void* data; /* additional data */
lua_State *L; /* Lua state (for reader) */ lua_State *L; /* Lua state (for reader) */
}; };