From b7a0503c1d72603b8f7e480f2abecbc05348cb69 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 15 May 2002 15:57:44 -0300 Subject: [PATCH] new format for error messages --- lapi.c | 7 ++++--- lauxlib.c | 9 ++++++++- ldblib.c | 26 +++++++++++--------------- ldebug.c | 30 +++++++++++++++++++++++------- ldebug.h | 3 ++- ldo.c | 17 ++++++----------- ldo.h | 3 +-- llex.c | 5 ++--- lmem.c | 7 ++++--- lobject.c | 30 ++++++++++-------------------- lobject.h | 3 +-- ltable.c | 9 +++++---- lua.c | 24 ++++++++++++++++++------ lundump.c | 20 ++++++++++---------- lvm.c | 16 ++++++++-------- 15 files changed, 113 insertions(+), 96 deletions(-) diff --git a/lapi.c b/lapi.c index 87a2abbe..eae26308 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 1.189 2002/05/06 19:05:10 roberto Exp roberto $ +** $Id: lapi.c,v 1.190 2002/05/07 17:36:56 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -11,6 +11,7 @@ #include "lua.h" #include "lapi.h" +#include "ldebug.h" #include "ldo.h" #include "lfunc.h" #include "lgc.h" @@ -521,8 +522,8 @@ LUA_API void lua_setmetatable (lua_State *L, int objindex) { uvalue(obj)->uv.metatable = hvalue(mt); break; default: - luaO_verror(L, "cannot change the meta table of a %s", - luaT_typenames[ttype(obj)]); + luaG_runerror(L, "cannot change the meta table of a %s", + luaT_typenames[ttype(obj)]); } lua_unlock(L); } diff --git a/lauxlib.c b/lauxlib.c index 2537ca8c..ecaa6c8f 100644 --- a/lauxlib.c +++ b/lauxlib.c @@ -1,5 +1,5 @@ /* -** $Id: lauxlib.c,v 1.68 2002/05/06 19:05:10 roberto Exp roberto $ +** $Id: lauxlib.c,v 1.69 2002/05/07 17:36:56 roberto Exp roberto $ ** Auxiliary functions for building Lua libraries ** See Copyright Notice in lua.h */ @@ -151,10 +151,17 @@ LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) { LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) { + lua_Debug ar; va_list argp; va_start(argp, fmt); lua_vpushstr(L, fmt, argp); va_end(argp); + if (lua_getstack(L, 1, &ar)) { /* check calling function */ + lua_getinfo(L, "Snl", &ar); + if (ar.currentline > 0) + luaL_vstr(L, "%s:%d: %s", + ar.short_src, ar.currentline, lua_tostring(L, -1)); + } return lua_errorobj(L); } diff --git a/ldblib.c b/ldblib.c index 8fe60179..da0a90f5 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.50 2002/05/06 19:05:10 roberto Exp roberto $ +** $Id: ldblib.c,v 1.51 2002/05/07 17:36:56 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -54,8 +54,7 @@ static int getinfo (lua_State *L) { switch (*options) { case 'S': settabss(L, "source", ar.source); - if (ar.source) - settabss(L, "short_src", ar.short_src); + settabss(L, "short_src", ar.short_src); settabsi(L, "linedefined", ar.linedefined); settabss(L, "what", ar.what); break; @@ -205,31 +204,28 @@ static int errorfb (lua_State *L) { firstpart = 0; continue; } - sprintf(buff, "%4d: ", level-1); + sprintf(buff, "%4d- ", level-1); lua_pushstring(L, buff); lua_getinfo(L, "Snl", &ar); + luaL_vstr(L, "%s:", ar.short_src); + if (ar.currentline > 0) + luaL_vstr(L, "%d:", ar.currentline); switch (*ar.namewhat) { - case 'g': case 'l': /* global, local */ - luaL_vstr(L, "function `%s'", ar.name); - break; + case 'g': /* global */ + case 'l': /* local */ case 'f': /* field */ case 'm': /* method */ - luaL_vstr(L, "method `%s'", ar.name); + luaL_vstr(L, " in function `%s'", ar.name); break; default: { if (*ar.what == 'm') /* main? */ - luaL_vstr(L, "main of %s", ar.short_src); + luaL_vstr(L, " in main chunk"); else if (*ar.what == 'C') /* C function? */ luaL_vstr(L, "%s", ar.short_src); else - luaL_vstr(L, "function <%d:%s>", ar.linedefined, ar.short_src); - ar.source = NULL; /* do not print source again */ + luaL_vstr(L, " in function <%s:%d>", ar.short_src, ar.linedefined); } } - if (ar.currentline > 0) - luaL_vstr(L, " at line %d", ar.currentline); - if (ar.source) - luaL_vstr(L, " [%s]", ar.short_src); lua_pushliteral(L, "\n"); lua_concat(L, lua_gettop(L)); } diff --git a/ldebug.c b/ldebug.c index 601190e7..eb2aa527 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 1.114 2002/05/13 13:09:00 roberto Exp roberto $ +** $Id: ldebug.c,v 1.115 2002/05/14 17:52:22 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -144,11 +144,11 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) { if (ttype(func) == LUA_TFUNCTION) cl = clvalue(func); else { - luaD_runerror(L, "value for `lua_getinfo' is not a function"); + luaG_runerror(L, "value for `lua_getinfo' is not a function"); cl = NULL; /* to avoid warnings */ } if (cl->c.isC) { - ar->source = "=C"; + ar->source = "=[C]"; ar->linedefined = -1; ar->what = "C"; } @@ -481,10 +481,10 @@ void luaG_typeerror (lua_State *L, const TObject *o, const char *op) { if (isinstack(L->ci, o)) kind = getobjname(L, L->ci, o - L->ci->base, &name); if (kind) - luaO_verror(L, "attempt to %s %s `%s' (a %s value)", + luaG_runerror(L, "attempt to %s %s `%s' (a %s value)", op, kind, name, t); else - luaO_verror(L, "attempt to %s a %s value", op, t); + luaG_runerror(L, "attempt to %s a %s value", op, t); } @@ -507,8 +507,24 @@ void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { const char *t1 = luaT_typenames[ttype(p1)]; const char *t2 = luaT_typenames[ttype(p2)]; if (t1[2] == t2[2]) - luaO_verror(L, "attempt to compare two %s values", t1); + luaG_runerror(L, "attempt to compare two %s values", t1); else - luaO_verror(L, "attempt to compare %s with %s", t1, t2); + luaG_runerror(L, "attempt to compare %s with %s", t1, t2); +} + + +void luaG_runerror (lua_State *L, const char *fmt, ...) { + const char *msg; + va_list argp; + va_start(argp, fmt); + msg = luaO_vpushstr(L, fmt, argp); + va_end(argp); + if (isLmark(L->ci)) { + char buff[LUA_IDSIZE]; + int line = currentline(L, L->ci); + luaO_chunkid(buff, getstr(getluaproto(L->ci)->source), LUA_IDSIZE); + msg = luaO_pushstr(L, "%s:%d: %s", buff, line, msg); + } + luaD_error(L, msg, LUA_ERRRUN); } diff --git a/ldebug.h b/ldebug.h index 1aafbb72..ef0a046f 100644 --- a/ldebug.h +++ b/ldebug.h @@ -1,5 +1,5 @@ /* -** $Id: ldebug.h,v 1.19 2002/04/10 12:11:07 roberto Exp roberto $ +** $Id: ldebug.h,v 1.20 2002/05/02 13:06:20 roberto Exp roberto $ ** Auxiliary functions from Debug Interface module ** See Copyright Notice in lua.h */ @@ -20,6 +20,7 @@ void luaG_typeerror (lua_State *L, const TObject *o, const char *opname); void luaG_concaterror (lua_State *L, StkId p1, StkId p2); void luaG_aritherror (lua_State *L, StkId p1, const TObject *p2); void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2); +void luaG_runerror (lua_State *L, const char *fmt, ...); int luaG_checkcode (const Proto *pt); diff --git a/ldo.c b/ldo.c index 87a78ed8..5b5bad8d 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.173 2002/05/01 20:40:42 roberto Exp roberto $ +** $Id: ldo.c,v 1.174 2002/05/07 17:36:56 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -113,7 +113,7 @@ static void luaD_growCI (lua_State *L) { else { luaD_reallocCI(L, 2*L->size_ci); if (L->size_ci > LUA_MAXCALLS) - luaD_runerror(L, "stack overflow"); + luaG_runerror(L, "stack overflow"); } L->ci++; } @@ -279,7 +279,7 @@ void luaD_call (lua_State *L, StkId func, int nResults) { firstResult = luaV_execute(L); /* call it */ if (firstResult == NULL) { luaD_poscall(L, 0, L->top); - luaD_runerror(L, "attempt to `yield' across tag-method/C-call boundary"); + luaG_runerror(L, "attempt to `yield' across tag-method/C-call boundary"); } } luaD_poscall(L, nResults, firstResult); @@ -335,9 +335,9 @@ LUA_API int lua_resume (lua_State *L, lua_State *co) { lua_lock(L); ci = co->ci; if (ci == co->base_ci) /* no activation record? ?? */ - luaD_runerror(L, "thread is dead - cannot be resumed"); + luaG_runerror(L, "thread is dead - cannot be resumed"); if (co->errorJmp != NULL) /* ?? */ - luaD_runerror(L, "thread is active - cannot be resumed"); + luaG_runerror(L, "thread is active - cannot be resumed"); if (L->errorJmp) { setobj(&ud.err, L->errorJmp->err); } @@ -359,7 +359,7 @@ LUA_API int lua_yield (lua_State *L, int nresults) { lua_lock(L); ci = L->ci; if (ci_func(ci-1)->c.isC) - luaD_runerror(L, "cannot `yield' a C function"); + luaG_runerror(L, "cannot `yield' a C function"); ci->yield_results = nresults; lua_unlock(L); return -1; @@ -492,11 +492,6 @@ void luaD_error (lua_State *L, const char *s, int errcode) { } -void luaD_runerror (lua_State *L, const char *s) { - luaD_error(L, s, LUA_ERRRUN); -} - - int luaD_runprotected (lua_State *L, Pfunc f, TObject *ud) { struct lua_longjmp lj; lj.ci = L->ci; diff --git a/ldo.h b/ldo.h index 0c4dfbca..914eddaa 100644 --- a/ldo.h +++ b/ldo.h @@ -1,5 +1,5 @@ /* -** $Id: ldo.h,v 1.43 2002/04/22 14:40:50 roberto Exp roberto $ +** $Id: ldo.h,v 1.44 2002/05/01 20:40:42 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -43,7 +43,6 @@ void luaD_growstack (lua_State *L, int n); void luaD_error (lua_State *L, const char *s, int errcode); void luaD_errorobj (lua_State *L, const TObject *s, int errcode); -void luaD_runerror (lua_State *L, const char *s); int luaD_runprotected (lua_State *L, Pfunc f, TObject *ud); diff --git a/llex.c b/llex.c index 91dd6379..90e6698b 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 1.99 2002/03/08 19:25:24 roberto Exp roberto $ +** $Id: llex.c,v 1.100 2002/05/07 17:36:56 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -61,8 +61,7 @@ static void luaX_error (LexState *ls, const char *s, const char *token) { lua_State *L = ls->L; char buff[MAXSRC]; luaO_chunkid(buff, getstr(ls->source), MAXSRC); - luaO_pushstr(L, "%s;\n last token read: `%s' at line %d in %s", - s, token, ls->linenumber, buff); + luaO_pushstr(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token); luaD_errorobj(L, L->top - 1, LUA_ERRSYNTAX); } diff --git a/lmem.c b/lmem.c index f3d4d309..99b0dafc 100644 --- a/lmem.c +++ b/lmem.c @@ -1,5 +1,5 @@ /* -** $Id: lmem.c,v 1.53 2002/04/22 14:40:23 roberto Exp roberto $ +** $Id: lmem.c,v 1.54 2002/05/01 20:40:42 roberto Exp roberto $ ** Interface to Memory Manager ** See Copyright Notice in lua.h */ @@ -9,6 +9,7 @@ #include "lua.h" +#include "ldebug.h" #include "ldo.h" #include "lmem.h" #include "lobject.h" @@ -34,7 +35,7 @@ void *luaM_growaux (lua_State *L, void *block, int *size, int size_elems, else if (*size >= limit/2) { /* cannot double it? */ if (*size < limit - MINSIZEARRAY) /* try something smaller... */ newsize = limit; /* still have at least MINSIZEARRAY free places */ - else luaD_runerror(L, errormsg); + else luaG_runerror(L, errormsg); } newblock = luaM_realloc(L, block, cast(lu_mem, *size)*cast(lu_mem, size_elems), @@ -53,7 +54,7 @@ void *luaM_realloc (lua_State *L, void *block, lu_mem oldsize, lu_mem size) { block = NULL; } else if (size >= MAX_SIZET) - luaD_runerror(L, "memory allocation error: block too big"); + luaG_runerror(L, "memory allocation error: block too big"); else { block = l_realloc(block, oldsize, size); if (block == NULL) { diff --git a/lobject.c b/lobject.c index 96590aa5..52e81205 100644 --- a/lobject.c +++ b/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 1.78 2002/05/06 15:51:41 roberto Exp roberto $ +** $Id: lobject.c,v 1.79 2002/05/07 17:36:56 roberto Exp roberto $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -100,7 +100,8 @@ static void pushstr (lua_State *L, const char *str) { /* this function handles only `%d', `%c', %f, and `%s' formats */ const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp) { - int n = 0; + int n = 1; + pushstr(L, ""); for (;;) { const char *e = strchr(fmt, '%'); if (e == NULL) break; @@ -150,47 +151,36 @@ const char *luaO_pushstr (lua_State *L, const char *fmt, ...) { } -void luaO_verror (lua_State *L, const char *fmt, ...) { - const char *msg; - va_list argp; - va_start(argp, fmt); - msg = luaO_vpushstr(L, fmt, argp); - va_end(argp); - luaD_runerror(L, msg); -} - - void luaO_chunkid (char *out, const char *source, int bufflen) { if (*source == '=') { strncpy(out, source+1, bufflen); /* remove first char */ out[bufflen-1] = '\0'; /* ensures null termination */ } - else { /* out = "file `source'", or "file `...source'" */ + else { /* out = "source", or "...source" */ if (*source == '@') { int l; source++; /* skip the `@' */ - bufflen -= sizeof(" file `...' "); + bufflen -= sizeof(" `...' "); l = strlen(source); - strcpy(out, "file `"); + strcpy(out, ""); if (l>bufflen) { source += (l-bufflen); /* get last part of file name */ strcat(out, "..."); } strcat(out, source); - strcat(out, "'"); } - else { + else { /* out = [string "string"] */ int len = strcspn(source, "\n"); /* stop at first newline */ - bufflen -= sizeof(" string \"...\" "); + bufflen -= sizeof(" [string \"...\"] "); if (len > bufflen) len = bufflen; - strcpy(out, "string \""); + strcpy(out, "[string \""); if (source[len] != '\0') { /* must truncate? */ strncat(out, source, len); strcat(out, "..."); } else strcat(out, source); - strcat(out, "\""); + strcat(out, "\"]"); } } } diff --git a/lobject.h b/lobject.h index ad3233f6..fbf57adc 100644 --- a/lobject.h +++ b/lobject.h @@ -1,5 +1,5 @@ /* -** $Id: lobject.h,v 1.130 2002/05/06 15:51:41 roberto Exp roberto $ +** $Id: lobject.h,v 1.131 2002/05/07 17:36:56 roberto Exp roberto $ ** Type definitions for Lua objects ** See Copyright Notice in lua.h */ @@ -252,7 +252,6 @@ int luaO_str2d (const char *s, lua_Number *result); const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp); const char *luaO_pushstr (lua_State *L, const char *fmt, ...); -void luaO_verror (lua_State *L, const char *fmt, ...); void luaO_chunkid (char *out, const char *source, int len); diff --git a/ltable.c b/ltable.c index 546e3527..fdd15b66 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 1.106 2002/05/08 17:34:00 roberto Exp roberto $ +** $Id: ltable.c,v 1.107 2002/05/13 13:38:59 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -25,6 +25,7 @@ #include "lua.h" +#include "ldebug.h" #include "ldo.h" #include "lmem.h" #include "lobject.h" @@ -111,7 +112,7 @@ static int luaH_index (lua_State *L, Table *t, const TObject *key) { else { const TObject *v = luaH_get(t, key); if (v == &luaO_nilobject) - luaD_runerror(L, "invalid key for `next'"); + luaG_runerror(L, "invalid key for `next'"); i = cast(int, (cast(const lu_byte *, v) - cast(const lu_byte *, val(node(t, 0)))) / sizeof(Node)); return i + t->sizearray; /* hash elements are numbered after array ones */ @@ -214,7 +215,7 @@ static void setnodevector (lua_State *L, Table *t, int lsize) { int i; int size = twoto(lsize); if (lsize > MAXBITS) - luaD_runerror(L, "table overflow"); + luaG_runerror(L, "table overflow"); if (lsize == 0) { /* no elements to hash part? */ t->node = G(L)->dummynode; /* use common `dummynode' */ lua_assert(ttype(key(t->node)) == LUA_TNIL); /* assert invariants: */ @@ -449,7 +450,7 @@ void luaH_set (lua_State *L, Table *t, const TObject *key, const TObject *val) { settableval(p, val); } else { - if (ttype(key) == LUA_TNIL) luaD_runerror(L, "table index is nil"); + if (ttype(key) == LUA_TNIL) luaG_runerror(L, "table index is nil"); newkey(L, t, key, val); } t->flags = 0; diff --git a/lua.c b/lua.c index 7508c4aa..344b3a02 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.84 2002/04/23 14:59:22 roberto Exp roberto $ +** $Id: lua.c,v 1.85 2002/05/01 20:40:42 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -71,7 +71,7 @@ static void report (int status) { else { const char *msg = lua_tostring(L, -1); if (msg == NULL) msg = "(no message)"; - fprintf(stderr, "error: %s\n", msg); + fprintf(stderr, "%s\n", msg); lua_pop(L, 1); } } @@ -152,8 +152,8 @@ static int file_input (const char *name) { } -static int dostring (const char *s) { - int status = lua_loadbuffer(L, s, strlen(s), s); +static int dostring (const char *s, const char *name) { + int status = lua_loadbuffer(L, s, strlen(s), name); if (status == 0) status = lcall(1); report(status); return status; @@ -198,7 +198,7 @@ static const char *get_prompt (int firstline) { static int incomplete (int status) { if (status == LUA_ERRSYNTAX && - strstr(lua_tostring(L, -1), "last token read: `'") != NULL) { + strstr(lua_tostring(L, -1), "near `'") != NULL) { lua_pop(L, 1); return 1; } @@ -289,7 +289,7 @@ static int handle_argv (char *argv[], int *toclose) { print_usage(); return EXIT_FAILURE; } - if (dostring(argv[i]) != 0) { + if (dostring(argv[i], "=prog. argument") != 0) { fprintf(stderr, "%s: error running argument `%.99s'\n", LUA_PROGNAME, argv[i]); return EXIT_FAILURE; @@ -340,6 +340,16 @@ static void openstdlibs (lua_State *l) { } +static int handle_luainit (void) { + const char *init = getenv("LUA_INIT"); + if (init == NULL) return 0; /* status OK */ + else if (init[0] == '@') + return file_input(init+1); + else + return dostring(init, "=LUA_INIT"); +} + + int main (int argc, char *argv[]) { int status; int toclose = 0; @@ -347,6 +357,8 @@ int main (int argc, char *argv[]) { L = lua_open(); /* create state */ LUA_USERINIT(L); /* open libraries */ register_getargs(argv); /* create `getargs' function */ + status = handle_luainit(); + if (status != 0) return status; status = handle_argv(argv+1, &toclose); if (toclose) lua_close(L); diff --git a/lundump.c b/lundump.c index b9b7b505..78f36ad8 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 1.45 2002/03/25 17:47:14 roberto Exp roberto $ +** $Id: lundump.c,v 1.46 2002/05/07 17:36:56 roberto Exp roberto $ ** load pre-compiled Lua chunks ** See Copyright Notice in lua.h */ @@ -27,7 +27,7 @@ static const char* ZNAME (ZIO* Z) static void unexpectedEOZ (lua_State* L, ZIO* Z) { - luaO_verror(L,"unexpected end of file in `%s'",ZNAME(Z)); + luaG_runerror(L,"unexpected end of file in `%s'",ZNAME(Z)); } static int ezgetc (lua_State* L, ZIO* Z) @@ -157,7 +157,7 @@ static void LoadConstants (lua_State* L, Proto* f, ZIO* Z, int swap) tsvalue(o)=LoadString(L,Z,swap); break; default: - luaO_verror(L,"bad constant type (%d) in `%s'",ttype(o),ZNAME(Z)); + luaG_runerror(L,"bad constant type (%d) in `%s'",ttype(o),ZNAME(Z)); break; } } @@ -181,7 +181,7 @@ static Proto* LoadFunction (lua_State* L, TString* p, ZIO* Z, int swap) LoadConstants(L,f,Z,swap); LoadCode(L,f,Z,swap); #ifndef TRUST_BINARIES - if (!luaG_checkcode(f)) luaO_verror(L,"bad code in `%s'",ZNAME(Z)); + if (!luaG_checkcode(f)) luaG_runerror(L,"bad code in `%s'",ZNAME(Z)); #endif return f; } @@ -191,14 +191,14 @@ static void LoadSignature (lua_State* L, ZIO* Z) const char* s=LUA_SIGNATURE; while (*s!=0 && ezgetc(L,Z)==*s) ++s; - if (*s!=0) luaO_verror(L,"bad signature in `%s'",ZNAME(Z)); + if (*s!=0) luaG_runerror(L,"bad signature in `%s'",ZNAME(Z)); } static void TestSize (lua_State* L, int s, const char* what, ZIO* Z) { int r=LoadByte(L,Z); if (r!=s) - luaO_verror(L,"virtual machine mismatch in `%s':\n" + luaG_runerror(L,"virtual machine mismatch in `%s':\n" " size of %.20s is %d but read %d",ZNAME(Z),what,s,r); } @@ -212,11 +212,11 @@ static int LoadHeader (lua_State* L, ZIO* Z) LoadSignature(L,Z); version=LoadByte(L,Z); if (version>VERSION) - luaO_verror(L,"`%s' too new:\n" + luaG_runerror(L,"`%s' too new:\n" " read version %d.%d; expected at most %d.%d", ZNAME(Z),V(version),V(VERSION)); if (versiontsv.len; n++; } - if (tl > MAX_SIZET) luaD_runerror(L, "string size overflow"); + if (tl > MAX_SIZET) luaG_runerror(L, "string size overflow"); buffer = luaO_openspace(L, tl, char); tl = 0; for (i=n; i>0; i--) { /* concat all strings */ @@ -276,7 +276,7 @@ static void powOp (lua_State *L, StkId ra, StkId rb, StkId rc) { setsvalue(&o, luaS_newliteral(L, "pow")); luaV_gettable(L, gt(L), &o, &f); if (ttype(&f) != LUA_TFUNCTION) - luaD_runerror(L, "`pow' (for `^' operator) is not a function"); + luaG_runerror(L, "`pow' (for `^' operator) is not a function"); callTMres(L, &f, b, c, ra); } else @@ -527,11 +527,11 @@ StkId luaV_execute (lua_State *L) { const TObject *plimit = ra+1; const TObject *pstep = ra+2; if (ttype(ra) != LUA_TNUMBER) - luaD_runerror(L, "`for' initial value must be a number"); + luaG_runerror(L, "`for' initial value must be a number"); if (!tonumber(plimit, ra+1)) - luaD_runerror(L, "`for' limit must be a number"); + luaG_runerror(L, "`for' limit must be a number"); if (!tonumber(pstep, ra+2)) - luaD_runerror(L, "`for' step must be a number"); + luaG_runerror(L, "`for' step must be a number"); step = nvalue(pstep); index = nvalue(ra) + step; /* increment index */ limit = nvalue(plimit);