diff options
-rw-r--r-- | lauxlib.c | 12 | ||||
-rw-r--r-- | lbaselib.c | 8 | ||||
-rw-r--r-- | ldblib.c | 7 | ||||
-rw-r--r-- | ldebug.c | 7 | ||||
-rw-r--r-- | liolib.c | 4 | ||||
-rw-r--r-- | llex.c | 4 | ||||
-rw-r--r-- | loadlib.c | 26 | ||||
-rw-r--r-- | lobject.c | 4 | ||||
-rw-r--r-- | loslib.c | 6 | ||||
-rw-r--r-- | lparser.c | 14 | ||||
-rw-r--r-- | lstrlib.c | 14 | ||||
-rw-r--r-- | ltable.c | 4 | ||||
-rw-r--r-- | ltablib.c | 4 | ||||
-rw-r--r-- | lua.c | 14 | ||||
-rw-r--r-- | luaconf.h | 27 | ||||
-rw-r--r-- | lvm.c | 8 |
16 files changed, 85 insertions, 78 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.130 2005/03/16 16:58:41 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.131 2005/05/16 19:21:11 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 | */ |
@@ -47,11 +47,12 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) { | |||
47 | if (strcmp(ar.namewhat, "method") == 0) { | 47 | if (strcmp(ar.namewhat, "method") == 0) { |
48 | narg--; /* do not count `self' */ | 48 | narg--; /* do not count `self' */ |
49 | if (narg == 0) /* error is in the self argument itself? */ | 49 | if (narg == 0) /* error is in the self argument itself? */ |
50 | return luaL_error(L, "calling `%s' on bad self (%s)", ar.name, extramsg); | 50 | return luaL_error(L, "calling " LUA_SM " on bad self (%s)", |
51 | ar.name, extramsg); | ||
51 | } | 52 | } |
52 | if (ar.name == NULL) | 53 | if (ar.name == NULL) |
53 | ar.name = "?"; | 54 | ar.name = "?"; |
54 | return luaL_error(L, "bad argument #%d to `%s' (%s)", | 55 | return luaL_error(L, "bad argument #%d to " LUA_SM " (%s)", |
55 | narg, ar.name, extramsg); | 56 | narg, ar.name, extramsg); |
56 | } | 57 | } |
57 | 58 | ||
@@ -244,7 +245,7 @@ LUALIB_API void luaL_openlib (lua_State *L, const char *libname, | |||
244 | luaL_setfield(L, LUA_GLOBALSINDEX, libname); | 245 | luaL_setfield(L, LUA_GLOBALSINDEX, libname); |
245 | } | 246 | } |
246 | else if (!lua_istable(L, -1)) | 247 | else if (!lua_istable(L, -1)) |
247 | luaL_error(L, "name conflict for library `%s'", libname); | 248 | luaL_error(L, "name conflict for library " LUA_SM, libname); |
248 | lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); | 249 | lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED"); |
249 | lua_pushvalue(L, -2); | 250 | lua_pushvalue(L, -2); |
250 | lua_setfield(L, -2, libname); /* _LOADED[modname] = new table */ | 251 | lua_setfield(L, -2, libname); /* _LOADED[modname] = new table */ |
@@ -365,7 +366,8 @@ LUALIB_API const char *luaL_searchpath (lua_State *L, const char *name, | |||
365 | for (;;) { | 366 | for (;;) { |
366 | const char *fname; | 367 | const char *fname; |
367 | if ((p = pushnexttemplate(L, p)) == NULL) { | 368 | if ((p = pushnexttemplate(L, p)) == NULL) { |
368 | lua_pushfstring(L, "no readable `%s' in path `%s'", name, path); | 369 | lua_pushfstring(L, "no readable " LUA_SM " in path " LUA_SM "", |
370 | name, path); | ||
369 | return NULL; | 371 | return NULL; |
370 | } | 372 | } |
371 | fname = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); | 373 | fname = luaL_gsub(L, lua_tostring(L, -1), LUA_PATH_MARK, name); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.173 2005/03/28 17:17:53 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.174 2005/05/16 19:21:11 roberto Exp roberto $ |
3 | ** Basic library | 3 | ** Basic library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -39,7 +39,8 @@ static int luaB_print (lua_State *L) { | |||
39 | lua_call(L, 1, 1); | 39 | lua_call(L, 1, 1); |
40 | s = lua_tostring(L, -1); /* get result */ | 40 | s = lua_tostring(L, -1); /* get result */ |
41 | if (s == NULL) | 41 | if (s == NULL) |
42 | return luaL_error(L, "`tostring' must return a string to `print'"); | 42 | return luaL_error(L, LUA_SM " must return a string to " LUA_SM, |
43 | "tostring", "print"); | ||
43 | if (i>1) fputs("\t", stdout); | 44 | if (i>1) fputs("\t", stdout); |
44 | fputs(s, stdout); | 45 | fputs(s, stdout); |
45 | lua_pop(L, 1); /* pop result */ | 46 | lua_pop(L, 1); /* pop result */ |
@@ -148,7 +149,8 @@ static int luaB_setfenv (lua_State *L) { | |||
148 | return 0; | 149 | return 0; |
149 | } | 150 | } |
150 | else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) | 151 | else if (lua_iscfunction(L, -2) || lua_setfenv(L, -2) == 0) |
151 | luaL_error(L, "`setfenv' cannot change environment of given object"); | 152 | luaL_error(L, LUA_SM " cannot change environment of given object", |
153 | "setfenv"); | ||
152 | return 1; | 154 | return 1; |
153 | } | 155 | } |
154 | 156 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.95 2005/05/05 20:47:02 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.96 2005/05/16 18:45:15 roberto Exp roberto $ |
3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -48,7 +48,8 @@ static int db_setfenv (lua_State *L) { | |||
48 | luaL_checktype(L, 2, LUA_TTABLE); | 48 | luaL_checktype(L, 2, LUA_TTABLE); |
49 | lua_settop(L, 2); | 49 | lua_settop(L, 2); |
50 | if (lua_setfenv(L, 1) == 0) | 50 | if (lua_setfenv(L, 1) == 0) |
51 | luaL_error(L, "`setfenv' cannot change environment of given object"); | 51 | luaL_error(L, LUA_SM " cannot change environment of given object", |
52 | "setfenv"); | ||
52 | return 1; | 53 | return 1; |
53 | } | 54 | } |
54 | 55 | ||
@@ -347,7 +348,7 @@ static int db_errorfb (lua_State *L) { | |||
347 | if (ar.currentline > 0) | 348 | if (ar.currentline > 0) |
348 | lua_pushfstring(L, "%d:", ar.currentline); | 349 | lua_pushfstring(L, "%d:", ar.currentline); |
349 | if (*ar.namewhat != '\0') /* is there a name? */ | 350 | if (*ar.namewhat != '\0') /* is there a name? */ |
350 | lua_pushfstring(L, " in function `%s'", ar.name); | 351 | lua_pushfstring(L, " in function " LUA_SM, ar.name); |
351 | else { | 352 | else { |
352 | if (*ar.what == 'm') /* main? */ | 353 | if (*ar.what == 'm') /* main? */ |
353 | lua_pushfstring(L, " in main chunk"); | 354 | lua_pushfstring(L, " in main chunk"); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.17 2005/05/05 20:47:02 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.18 2005/05/16 18:45:15 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -236,8 +236,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
236 | lua_lock(L); | 236 | lua_lock(L); |
237 | if (*what == '>') { | 237 | if (*what == '>') { |
238 | StkId func = L->top - 1; | 238 | StkId func = L->top - 1; |
239 | if (!ttisfunction(func)) | 239 | luai_apicheck(L, ttisfunction(func)); |
240 | luaG_runerror(L, "value for `lua_getinfo' is not a function"); | ||
241 | what++; /* skip the '>' */ | 240 | what++; /* skip the '>' */ |
242 | f = clvalue(func); | 241 | f = clvalue(func); |
243 | L->top--; /* pop function */ | 242 | L->top--; /* pop function */ |
@@ -549,7 +548,7 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { | |||
549 | const char *kind = (isinstack(L->ci, o)) ? | 548 | const char *kind = (isinstack(L->ci, o)) ? |
550 | getobjname(L, L->ci, o - L->base, &name) : NULL; | 549 | getobjname(L, L->ci, o - L->base, &name) : NULL; |
551 | if (kind) | 550 | if (kind) |
552 | luaG_runerror(L, "attempt to %s %s `%s' (a %s value)", | 551 | luaG_runerror(L, "attempt to %s %s " LUA_SM " (a %s value)", |
553 | op, kind, name, t); | 552 | op, kind, name, t); |
554 | else | 553 | else |
555 | luaG_runerror(L, "attempt to %s a %s value", op, t); | 554 | luaG_runerror(L, "attempt to %s a %s value", op, t); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 2.58 2005/02/18 12:40:02 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 2.59 2005/03/18 18:01:14 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 | */ |
@@ -319,8 +319,6 @@ static int g_read (lua_State *L, FILE *f, int first) { | |||
319 | read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ | 319 | read_chars(L, f, ~((size_t)0)); /* read MAX_SIZE_T chars */ |
320 | success = 1; /* always success */ | 320 | success = 1; /* always success */ |
321 | break; | 321 | break; |
322 | case 'w': /* word */ | ||
323 | return luaL_error(L, "obsolete option `*w' to `read'"); | ||
324 | default: | 322 | default: |
325 | return luaL_argerror(L, n, "invalid format"); | 323 | return luaL_argerror(L, n, "invalid format"); |
326 | } | 324 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.9 2004/12/03 20:54:12 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.10 2005/04/27 18:37:51 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -102,7 +102,7 @@ void luaX_lexerror (LexState *ls, const char *msg, int token) { | |||
102 | luaO_chunkid(buff, getstr(ls->source), MAXSRC); | 102 | luaO_chunkid(buff, getstr(ls->source), MAXSRC); |
103 | msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); | 103 | msg = luaO_pushfstring(ls->L, "%s:%d: %s", buff, ls->linenumber, msg); |
104 | if (token) | 104 | if (token) |
105 | luaO_pushfstring(ls->L, "%s near `%s'", msg, txtToken(ls, token)); | 105 | luaO_pushfstring(ls->L, "%s near " LUA_SM, msg, txtToken(ls, token)); |
106 | luaD_throw(ls->L, LUA_ERRSYNTAX); | 106 | luaD_throw(ls->L, LUA_ERRSYNTAX); |
107 | } | 107 | } |
108 | 108 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loadlib.c,v 1.25 2005/03/30 19:50:29 roberto Exp roberto $ | 2 | ** $Id: loadlib.c,v 1.26 2005/04/13 17:24:20 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 | ** |
@@ -191,7 +191,7 @@ static void *ll_load (lua_State *L, const char *path) { | |||
191 | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { | 191 | static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { |
192 | NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); | 192 | NSSymbol nss = NSLookupSymbolInModule((NSModule)lib, sym); |
193 | if (nss == NULL) { | 193 | if (nss == NULL) { |
194 | lua_pushfstring(L, "symbol `%s' not found", sym); | 194 | lua_pushfstring(L, "symbol " LUA_SM " not found", sym); |
195 | return NULL; | 195 | return NULL; |
196 | } | 196 | } |
197 | return (lua_CFunction)NSAddressOfSymbol(nss); | 197 | return (lua_CFunction)NSAddressOfSymbol(nss); |
@@ -213,9 +213,9 @@ static lua_CFunction ll_sym (lua_State *L, void *lib, const char *sym) { | |||
213 | 213 | ||
214 | 214 | ||
215 | #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux) | 215 | #if defined(__ELF__) || defined(__sun) || defined(sgi) || defined(__hpux) |
216 | #define DLMSG "`loadlib' not enabled; check your Lua installation" | 216 | #define DLMSG "'loadlib' not enabled; check your Lua installation" |
217 | #else | 217 | #else |
218 | #define DLMSG "`loadlib' not supported" | 218 | #define DLMSG "'loadlib' not supported" |
219 | #endif | 219 | #endif |
220 | 220 | ||
221 | static void ll_unloadlib (void *lib) { | 221 | static void ll_unloadlib (void *lib) { |
@@ -327,11 +327,12 @@ static int loader_Lua (lua_State *L) { | |||
327 | path = lua_tostring(L, -1); | 327 | path = lua_tostring(L, -1); |
328 | } | 328 | } |
329 | if (path == NULL) | 329 | if (path == NULL) |
330 | luaL_error(L, "`package.path' must be a string"); | 330 | luaL_error(L, LUA_SM " must be a string", "package.path"); |
331 | fname = luaL_searchpath(L, fname, path); | 331 | fname = luaL_searchpath(L, fname, path); |
332 | if (fname == NULL) return 0; /* library not found in this path */ | 332 | if (fname == NULL) return 0; /* library not found in this path */ |
333 | if (luaL_loadfile(L, fname) != 0) | 333 | if (luaL_loadfile(L, fname) != 0) |
334 | luaL_error(L, "error loading package `%s' (%s)", name, lua_tostring(L, -1)); | 334 | luaL_error(L, "error loading package " LUA_SM " (%s)", |
335 | name, lua_tostring(L, -1)); | ||
335 | return 1; /* library loaded successfully */ | 336 | return 1; /* library loaded successfully */ |
336 | } | 337 | } |
337 | 338 | ||
@@ -344,13 +345,14 @@ static int loader_C (lua_State *L) { | |||
344 | lua_getfield(L, LUA_ENVIRONINDEX, "cpath"); | 345 | lua_getfield(L, LUA_ENVIRONINDEX, "cpath"); |
345 | path = lua_tostring(L, -1); | 346 | path = lua_tostring(L, -1); |
346 | if (path == NULL) | 347 | if (path == NULL) |
347 | luaL_error(L, "`package.cpath' must be a string"); | 348 | luaL_error(L, LUA_SM " must be a string", "package.cpath"); |
348 | fname = luaL_searchpath(L, fname, path); | 349 | fname = luaL_searchpath(L, fname, path); |
349 | if (fname == NULL) return 0; /* library not found in this path */ | 350 | if (fname == NULL) return 0; /* library not found in this path */ |
350 | funcname = luaL_gsub(L, name, ".", LUA_OFSEP); | 351 | funcname = luaL_gsub(L, name, ".", LUA_OFSEP); |
351 | funcname = lua_pushfstring(L, "%s%s", POF, funcname); | 352 | funcname = lua_pushfstring(L, "%s%s", POF, funcname); |
352 | if (ll_loadfunc(L, fname, funcname) != 1) | 353 | if (ll_loadfunc(L, fname, funcname) != 1) |
353 | luaL_error(L, "error loading package `%s' (%s)", name, lua_tostring(L, -2)); | 354 | luaL_error(L, "error loading package " LUA_SM " (%s)", |
355 | name, lua_tostring(L, -2)); | ||
354 | return 1; /* library loaded successfully */ | 356 | return 1; /* library loaded successfully */ |
355 | } | 357 | } |
356 | 358 | ||
@@ -358,7 +360,7 @@ static int loader_C (lua_State *L) { | |||
358 | static int loader_preload (lua_State *L) { | 360 | static int loader_preload (lua_State *L) { |
359 | lua_getfield(L, LUA_ENVIRONINDEX, "preload"); | 361 | lua_getfield(L, LUA_ENVIRONINDEX, "preload"); |
360 | if (!lua_istable(L, -1)) | 362 | if (!lua_istable(L, -1)) |
361 | luaL_error(L, "`package.preload' must be a table"); | 363 | luaL_error(L, LUA_SM " must be a table", "package.preload"); |
362 | lua_getfield(L, -1, luaL_checkstring(L, 1)); | 364 | lua_getfield(L, -1, luaL_checkstring(L, 1)); |
363 | return 1; | 365 | return 1; |
364 | } | 366 | } |
@@ -378,11 +380,11 @@ static int ll_require (lua_State *L) { | |||
378 | /* iterate over available loaders */ | 380 | /* iterate over available loaders */ |
379 | lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); | 381 | lua_getfield(L, LUA_ENVIRONINDEX, "loaders"); |
380 | if (!lua_istable(L, -1)) | 382 | if (!lua_istable(L, -1)) |
381 | luaL_error(L, "`package.loaders' must be a table"); | 383 | luaL_error(L, LUA_SM " must be a table", "package.loaders"); |
382 | for (i=1;; i++) { | 384 | for (i=1;; i++) { |
383 | lua_rawgeti(L, -1, i); /* get a loader */ | 385 | lua_rawgeti(L, -1, i); /* get a loader */ |
384 | if (lua_isnil(L, -1)) | 386 | if (lua_isnil(L, -1)) |
385 | return luaL_error(L, "package `%s' not found", name); | 387 | return luaL_error(L, "package " LUA_SM " not found", name); |
386 | lua_pushstring(L, name); | 388 | lua_pushstring(L, name); |
387 | lua_call(L, 1, 1); /* call it */ | 389 | lua_call(L, 1, 1); /* call it */ |
388 | if (lua_isnil(L, -1)) lua_pop(L, 1); | 390 | if (lua_isnil(L, -1)) lua_pop(L, 1); |
@@ -421,7 +423,7 @@ static int ll_module (lua_State *L) { | |||
421 | luaL_setfield(L, LUA_GLOBALSINDEX, modname); | 423 | luaL_setfield(L, LUA_GLOBALSINDEX, modname); |
422 | } | 424 | } |
423 | else if (!lua_istable(L, -1)) | 425 | else if (!lua_istable(L, -1)) |
424 | return luaL_error(L, "name conflict for module `%s'", modname); | 426 | return luaL_error(L, "name conflict for module " LUA_SM, modname); |
425 | /* check whether table already has a _NAME field */ | 427 | /* check whether table already has a _NAME field */ |
426 | lua_getfield(L, -1, "_NAME"); | 428 | lua_getfield(L, -1, "_NAME"); |
427 | if (!lua_isnil(L, -1)) /* is table an initialized module? */ | 429 | if (!lua_isnil(L, -1)) /* is table an initialized module? */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.11 2005/03/09 16:28:07 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.12 2005/03/28 12:53:40 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -184,7 +184,7 @@ void luaO_chunkid (char *out, const char *source, int bufflen) { | |||
184 | if (*source == '@') { | 184 | if (*source == '@') { |
185 | int l; | 185 | int l; |
186 | source++; /* skip the `@' */ | 186 | source++; /* skip the `@' */ |
187 | bufflen -= sizeof(" `...' "); | 187 | bufflen -= sizeof(" '...' "); |
188 | l = strlen(source); | 188 | l = strlen(source); |
189 | strcpy(out, ""); | 189 | strcpy(out, ""); |
190 | if (l>bufflen) { | 190 | if (l>bufflen) { |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loslib.c,v 1.6 2005/03/09 16:28:07 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.7 2005/03/18 18:02:04 roberto Exp roberto $ |
3 | ** Standard Operating System library | 3 | ** Standard Operating System library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -113,7 +113,7 @@ static int getfield (lua_State *L, const char *key, int d) { | |||
113 | res = (int)lua_tointeger(L, -1); | 113 | res = (int)lua_tointeger(L, -1); |
114 | else { | 114 | else { |
115 | if (d < 0) | 115 | if (d < 0) |
116 | return luaL_error(L, "field `%s' missing in date table", key); | 116 | return luaL_error(L, "field " LUA_SM " missing in date table", key); |
117 | res = d; | 117 | res = d; |
118 | } | 118 | } |
119 | lua_pop(L, 1); | 119 | lua_pop(L, 1); |
@@ -151,7 +151,7 @@ static int io_date (lua_State *L) { | |||
151 | if (strftime(b, sizeof(b), s, stm)) | 151 | if (strftime(b, sizeof(b), s, stm)) |
152 | lua_pushstring(L, b); | 152 | lua_pushstring(L, b); |
153 | else | 153 | else |
154 | return luaL_error(L, "`date' format too long"); | 154 | return luaL_error(L, LUA_SM " format too long", "date"); |
155 | } | 155 | } |
156 | return 1; | 156 | return 1; |
157 | } | 157 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.24 2005/05/04 20:42:28 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.25 2005/05/05 20:47:02 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 | */ |
@@ -82,7 +82,7 @@ static void anchor_token (LexState *ls) { | |||
82 | 82 | ||
83 | static void error_expected (LexState *ls, int token) { | 83 | static void error_expected (LexState *ls, int token) { |
84 | luaX_syntaxerror(ls, | 84 | luaX_syntaxerror(ls, |
85 | luaO_pushfstring(ls->L, "`%s' expected", luaX_token2str(ls, token))); | 85 | luaO_pushfstring(ls->L, LUA_SM " expected", luaX_token2str(ls, token))); |
86 | } | 86 | } |
87 | 87 | ||
88 | 88 | ||
@@ -125,7 +125,7 @@ static void check_match (LexState *ls, int what, int who, int where) { | |||
125 | error_expected(ls, what); | 125 | error_expected(ls, what); |
126 | else { | 126 | else { |
127 | luaX_syntaxerror(ls, luaO_pushfstring(ls->L, | 127 | luaX_syntaxerror(ls, luaO_pushfstring(ls->L, |
128 | "`%s' expected (to close `%s' at line %d)", | 128 | LUA_SM " expected (to close " LUA_SM " at line %d)", |
129 | luaX_token2str(ls, what), luaX_token2str(ls, who), where)); | 129 | luaX_token2str(ls, what), luaX_token2str(ls, who), where)); |
130 | } | 130 | } |
131 | } | 131 | } |
@@ -577,7 +577,7 @@ static void parlist (LexState *ls) { | |||
577 | f->is_vararg = 1; | 577 | f->is_vararg = 1; |
578 | break; | 578 | break; |
579 | } | 579 | } |
580 | default: luaX_syntaxerror(ls, "<name> or `...' expected"); | 580 | default: luaX_syntaxerror(ls, "<name> or '...' expected"); |
581 | } | 581 | } |
582 | } while (!f->is_vararg && testnext(ls, ',')); | 582 | } while (!f->is_vararg && testnext(ls, ',')); |
583 | } | 583 | } |
@@ -765,7 +765,7 @@ static void simpleexp (LexState *ls, expdesc *v) { | |||
765 | case TK_DOTS: { /* vararg */ | 765 | case TK_DOTS: { /* vararg */ |
766 | FuncState *fs = ls->fs; | 766 | FuncState *fs = ls->fs; |
767 | check_condition(ls, fs->f->is_vararg, | 767 | check_condition(ls, fs->f->is_vararg, |
768 | "cannot use `...' outside a vararg function"); | 768 | "cannot use '...' outside a vararg function"); |
769 | fs->f->is_vararg = NEWSTYLEVARARG; | 769 | fs->f->is_vararg = NEWSTYLEVARARG; |
770 | init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); | 770 | init_exp(v, VVARARG, luaK_codeABC(fs, OP_VARARG, 0, 1, 0)); |
771 | break; | 771 | break; |
@@ -1017,7 +1017,7 @@ static void whilestat (LexState *ls, int line) { | |||
1017 | fs->jpc = NO_JUMP; | 1017 | fs->jpc = NO_JUMP; |
1018 | sizeexp = fs->pc - expinit; /* size of expression code */ | 1018 | sizeexp = fs->pc - expinit; /* size of expression code */ |
1019 | if (sizeexp > LUAI_MAXEXPWHILE) | 1019 | if (sizeexp > LUAI_MAXEXPWHILE) |
1020 | luaX_syntaxerror(ls, "`while' condition too complex"); | 1020 | luaX_syntaxerror(ls, "'while' condition too complex"); |
1021 | for (i = 0; i < sizeexp; i++) /* save `exp' code */ | 1021 | for (i = 0; i < sizeexp; i++) /* save `exp' code */ |
1022 | codeexp[i] = fs->f->code[expinit + i]; | 1022 | codeexp[i] = fs->f->code[expinit + i]; |
1023 | fs->pc = expinit; /* remove `exp' code */ | 1023 | fs->pc = expinit; /* remove `exp' code */ |
@@ -1141,7 +1141,7 @@ static void forstat (LexState *ls, int line) { | |||
1141 | switch (ls->t.token) { | 1141 | switch (ls->t.token) { |
1142 | case '=': fornum(ls, varname, line); break; | 1142 | case '=': fornum(ls, varname, line); break; |
1143 | case ',': case TK_IN: forlist(ls, varname); break; | 1143 | case ',': case TK_IN: forlist(ls, varname); break; |
1144 | default: luaX_syntaxerror(ls, "`=' or `in' expected"); | 1144 | default: luaX_syntaxerror(ls, "'=' or 'in' expected"); |
1145 | } | 1145 | } |
1146 | check_match(ls, TK_END, TK_FOR, line); | 1146 | check_match(ls, TK_END, TK_FOR, line); |
1147 | leaveblock(fs); /* loop scope (`break' jumps to this point) */ | 1147 | leaveblock(fs); /* loop scope (`break' jumps to this point) */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.112 2005/05/05 15:34:03 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.113 2005/05/16 19:21:11 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 | */ |
@@ -200,14 +200,14 @@ static const char *classend (MatchState *ms, const char *p) { | |||
200 | switch (*p++) { | 200 | switch (*p++) { |
201 | case L_ESC: { | 201 | case L_ESC: { |
202 | if (*p == '\0') | 202 | if (*p == '\0') |
203 | luaL_error(ms->L, "malformed pattern (ends with `%%')"); | 203 | luaL_error(ms->L, "malformed pattern (ends with '%%')"); |
204 | return p+1; | 204 | return p+1; |
205 | } | 205 | } |
206 | case '[': { | 206 | case '[': { |
207 | if (*p == '^') p++; | 207 | if (*p == '^') p++; |
208 | do { /* look for a `]' */ | 208 | do { /* look for a `]' */ |
209 | if (*p == '\0') | 209 | if (*p == '\0') |
210 | luaL_error(ms->L, "malformed pattern (missing `]')"); | 210 | luaL_error(ms->L, "malformed pattern (missing ']')"); |
211 | if (*(p++) == L_ESC && *p != '\0') | 211 | if (*(p++) == L_ESC && *p != '\0') |
212 | p++; /* skip escapes (e.g. `%]') */ | 212 | p++; /* skip escapes (e.g. `%]') */ |
213 | } while (*p != ']'); | 213 | } while (*p != ']'); |
@@ -382,7 +382,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) { | |||
382 | const char *ep; char previous; | 382 | const char *ep; char previous; |
383 | p += 2; | 383 | p += 2; |
384 | if (*p != '[') | 384 | if (*p != '[') |
385 | luaL_error(ms->L, "missing `[' after `%%f' in pattern"); | 385 | luaL_error(ms->L, "missing '[' after '%%f' in pattern"); |
386 | ep = classend(ms, p); /* points to what is next */ | 386 | ep = classend(ms, p); /* points to what is next */ |
387 | previous = (s == ms->src_init) ? '\0' : *(s-1); | 387 | previous = (s == ms->src_init) ? '\0' : *(s-1); |
388 | if (matchbracketclass(uchar(previous), p, ep-1) || | 388 | if (matchbracketclass(uchar(previous), p, ep-1) || |
@@ -705,8 +705,6 @@ static int str_format (lua_State *L) { | |||
705 | char form[MAX_FORMAT]; /* to store the format (`%...') */ | 705 | char form[MAX_FORMAT]; /* to store the format (`%...') */ |
706 | char buff[MAX_ITEM]; /* to store the formatted item */ | 706 | char buff[MAX_ITEM]; /* to store the formatted item */ |
707 | int hasprecision = 0; | 707 | int hasprecision = 0; |
708 | if (isdigit(uchar(*strfrmt)) && *(strfrmt+1) == '$') | ||
709 | return luaL_error(L, "obsolete option (d$) to `format'"); | ||
710 | arg++; | 708 | arg++; |
711 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); | 709 | strfrmt = scanformat(L, strfrmt, form, &hasprecision); |
712 | switch (*strfrmt++) { | 710 | switch (*strfrmt++) { |
@@ -725,7 +723,7 @@ static int str_format (lua_State *L) { | |||
725 | } | 723 | } |
726 | case 'q': { | 724 | case 'q': { |
727 | addquoted(L, &b, arg); | 725 | addquoted(L, &b, arg); |
728 | continue; /* skip the `addsize' at the end */ | 726 | continue; /* skip the 'addsize' at the end */ |
729 | } | 727 | } |
730 | case 's': { | 728 | case 's': { |
731 | size_t l; | 729 | size_t l; |
@@ -743,7 +741,7 @@ static int str_format (lua_State *L) { | |||
743 | } | 741 | } |
744 | } | 742 | } |
745 | default: { /* also treat cases `pnLlh' */ | 743 | default: { /* also treat cases `pnLlh' */ |
746 | return luaL_error(L, "invalid option to `format'"); | 744 | return luaL_error(L, "invalid option to " LUA_SM, "format"); |
747 | } | 745 | } |
748 | } | 746 | } |
749 | luaL_addlstring(&b, buff, strlen(buff)); | 747 | luaL_addlstring(&b, buff, strlen(buff)); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.20 2005/04/01 13:51:37 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.21 2005/05/03 19:30:17 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -151,7 +151,7 @@ static int findindex (lua_State *L, Table *t, StkId key) { | |||
151 | } | 151 | } |
152 | else n = gnext(n); | 152 | else n = gnext(n); |
153 | } while (n); | 153 | } while (n); |
154 | luaG_runerror(L, "invalid key for `next'"); /* key not found */ | 154 | luaG_runerror(L, "invalid key to " LUA_SM, "next"); /* key not found */ |
155 | return 0; /* to avoid warnings */ | 155 | return 0; /* to avoid warnings */ |
156 | } | 156 | } |
157 | } | 157 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltablib.c,v 1.28 2005/03/16 16:58:41 roberto Exp roberto $ | 2 | ** $Id: ltablib.c,v 1.29 2005/03/28 17:17:53 roberto Exp roberto $ |
3 | ** Library for Table Manipulation | 3 | ** Library for Table Manipulation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -65,7 +65,7 @@ static int setn (lua_State *L) { | |||
65 | #ifndef luaL_setn | 65 | #ifndef luaL_setn |
66 | luaL_setn(L, 1, luaL_checkint(L, 2)); | 66 | luaL_setn(L, 1, luaL_checkint(L, 2)); |
67 | #else | 67 | #else |
68 | luaL_error(L, "`setn' is obsolete"); | 68 | luaL_error(L, LUA_SM " is obsolete", "setn"); |
69 | #endif | 69 | #endif |
70 | lua_pushvalue(L, 1); | 70 | lua_pushvalue(L, 1); |
71 | return 1; | 71 | return 1; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.141 2005/04/11 18:01:35 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.142 2005/04/13 17:24:20 roberto Exp roberto $ |
3 | ** Lua stand-alone interpreter | 3 | ** Lua stand-alone interpreter |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -44,9 +44,9 @@ static void print_usage (void) { | |||
44 | "usage: %s [options] [script [args]].\n" | 44 | "usage: %s [options] [script [args]].\n" |
45 | "Available options are:\n" | 45 | "Available options are:\n" |
46 | " - execute stdin as a file\n" | 46 | " - execute stdin as a file\n" |
47 | " -e stat execute string `stat'\n" | 47 | " -e stat execute string 'stat'\n" |
48 | " -i enter interactive mode after executing `script'\n" | 48 | " -i enter interactive mode after executing 'script'\n" |
49 | " -l name require library `name'\n" | 49 | " -l name require library 'name'\n" |
50 | " -v show version information\n" | 50 | " -v show version information\n" |
51 | " -w trap access to undefined globals\n" | 51 | " -w trap access to undefined globals\n" |
52 | " -- stop handling options\n" , | 52 | " -- stop handling options\n" , |
@@ -149,7 +149,7 @@ static const char *get_prompt (lua_State *L, int firstline) { | |||
149 | 149 | ||
150 | static int incomplete (lua_State *L, int status) { | 150 | static int incomplete (lua_State *L, int status) { |
151 | if (status == LUA_ERRSYNTAX && | 151 | if (status == LUA_ERRSYNTAX && |
152 | strstr(lua_tostring(L, -1), "near `<eof>'") != NULL) { | 152 | strstr(lua_tostring(L, -1), "<eof>") != NULL) { |
153 | lua_pop(L, 1); | 153 | lua_pop(L, 1); |
154 | return 1; | 154 | return 1; |
155 | } | 155 | } |
@@ -209,7 +209,7 @@ static void dotty (lua_State *L) { | |||
209 | lua_getglobal(L, "print"); | 209 | lua_getglobal(L, "print"); |
210 | lua_insert(L, 1); | 210 | lua_insert(L, 1); |
211 | if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) | 211 | if (lua_pcall(L, lua_gettop(L)-1, 0, 0) != 0) |
212 | l_message(progname, lua_pushfstring(L, "error calling `print' (%s)", | 212 | l_message(progname, lua_pushfstring(L, "error calling 'print' (%s)", |
213 | lua_tostring(L, -1))); | 213 | lua_tostring(L, -1))); |
214 | } | 214 | } |
215 | } | 215 | } |
@@ -222,7 +222,7 @@ static void dotty (lua_State *L) { | |||
222 | static int checkvar (lua_State *L) { | 222 | static int checkvar (lua_State *L) { |
223 | const char *name = lua_tostring(L, 2); | 223 | const char *name = lua_tostring(L, 2); |
224 | if (name) | 224 | if (name) |
225 | luaL_error(L, "attempt to access undefined variable `%s'", name); | 225 | luaL_error(L, "attempt to access undefined variable " LUA_SM, name); |
226 | return 0; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: luaconf.h,v 1.46 2005/04/29 13:53:59 roberto Exp $ | 2 | ** $Id: luaconf.h,v 1.47 2005/05/03 19:30:17 roberto Exp roberto $ |
3 | ** Configuration file for Lua | 3 | ** Configuration file for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -140,6 +140,11 @@ | |||
140 | #define lua_assert(c) ((void)0) | 140 | #define lua_assert(c) ((void)0) |
141 | 141 | ||
142 | 142 | ||
143 | /* | ||
144 | @@ LUA_SM describes how variable strings appear in error messages. | ||
145 | ** CHANGE it if you want a different appearance. | ||
146 | */ | ||
147 | #define LUA_SM "'%s'" | ||
143 | 148 | ||
144 | /* | 149 | /* |
145 | ** {================================================================== | 150 | ** {================================================================== |
@@ -151,7 +156,7 @@ | |||
151 | 156 | ||
152 | /* | 157 | /* |
153 | @@ lua_stdin_is_tty is a function to detect whether the standard input is | 158 | @@ lua_stdin_is_tty is a function to detect whether the standard input is |
154 | @* a `tty' (that is, is interactive). | 159 | @* a 'tty' (that is, is interactive). |
155 | ** CHANGE it if you have a better definition for non-POSIX/non-Windows | 160 | ** CHANGE it if you have a better definition for non-POSIX/non-Windows |
156 | ** systems. | 161 | ** systems. |
157 | */ | 162 | */ |
@@ -238,7 +243,7 @@ | |||
238 | ** collection. (Higher values mean coarser collections. 0 represents | 243 | ** collection. (Higher values mean coarser collections. 0 represents |
239 | ** infinity, where each step performs a full collection.) | 244 | ** infinity, where each step performs a full collection.) |
240 | */ | 245 | */ |
241 | #define LUAI_GCMUL 200 /* GC runs `twice the speed' of memory allocation */ | 246 | #define LUAI_GCMUL 200 /* GC runs 'twice the speed' of memory allocation */ |
242 | 247 | ||
243 | 248 | ||
244 | /* | 249 | /* |
@@ -250,22 +255,22 @@ | |||
250 | 255 | ||
251 | /* | 256 | /* |
252 | @@ LUA_COMPAT_PATH controls compatibility about LUA_PATH. | 257 | @@ LUA_COMPAT_PATH controls compatibility about LUA_PATH. |
253 | ** CHANGE it to 1 if you want `require' to look for global LUA_PATH | 258 | ** CHANGE it to 1 if you want 'require' to look for global LUA_PATH |
254 | ** before checking package.path. | 259 | ** before checking package.path. |
255 | */ | 260 | */ |
256 | #define LUA_COMPAT_PATH 0 | 261 | #define LUA_COMPAT_PATH 0 |
257 | 262 | ||
258 | /* | 263 | /* |
259 | @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. | 264 | @@ LUA_COMPAT_LOADLIB controls compatibility about global loadlib. |
260 | ** CHANGE it to 1 if you want a global `loadlib' function (otherwise | 265 | ** CHANGE it to 1 if you want a global 'loadlib' function (otherwise |
261 | ** the function is only available as `package.loadlib'). | 266 | ** the function is only available as 'package.loadlib'). |
262 | */ | 267 | */ |
263 | #define LUA_COMPAT_LOADLIB 1 | 268 | #define LUA_COMPAT_LOADLIB 1 |
264 | 269 | ||
265 | /* | 270 | /* |
266 | @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. | 271 | @@ LUA_COMPAT_VARARG controls compatibility with old vararg feature. |
267 | ** CHANGE it to 1 if you want vararg functions that do not use `...' | 272 | ** CHANGE it to 1 if you want vararg functions that do not use '...' |
268 | ** to get an `arg' table with their extra arguments. | 273 | ** to get an 'arg' table with their extra arguments. |
269 | */ | 274 | */ |
270 | #define LUA_COMPAT_VARARG 1 | 275 | #define LUA_COMPAT_VARARG 1 |
271 | 276 | ||
@@ -317,7 +322,7 @@ | |||
317 | @@ LUAI_MEM is an a signed integer big enough to count the total memory | 322 | @@ LUAI_MEM is an a signed integer big enough to count the total memory |
318 | @* used by Lua. | 323 | @* used by Lua. |
319 | ** CHANGE here if for some weird reason the default definitions are not | 324 | ** CHANGE here if for some weird reason the default definitions are not |
320 | ** good enough for your machine. (The `else' definition always works, | 325 | ** good enough for your machine. (The 'else' definition always works, |
321 | ** but may waste space on machines with 64-bit longs.) Probably you do | 326 | ** but may waste space on machines with 64-bit longs.) Probably you do |
322 | ** not need to change this. | 327 | ** not need to change this. |
323 | */ | 328 | */ |
@@ -393,7 +398,7 @@ | |||
393 | 398 | ||
394 | /* | 399 | /* |
395 | @@ LUAI_MAXEXPWHILE is the maximum size of code for expressions | 400 | @@ LUAI_MAXEXPWHILE is the maximum size of code for expressions |
396 | @* controling a `while' loop. | 401 | @* controling a 'while' loop. |
397 | */ | 402 | */ |
398 | #define LUAI_MAXEXPWHILE 100 | 403 | #define LUAI_MAXEXPWHILE 100 |
399 | 404 | ||
@@ -466,7 +471,7 @@ | |||
466 | 471 | ||
467 | /* | 472 | /* |
468 | @@ LUA_NUMBER is the type of numbers in Lua. | 473 | @@ LUA_NUMBER is the type of numbers in Lua. |
469 | @@ LUAI_UACNUMBER is the result of an `usual argument conversion' | 474 | @@ LUAI_UACNUMBER is the result of an 'usual argument conversion' |
470 | @* over a number. | 475 | @* over a number. |
471 | */ | 476 | */ |
472 | #define LUA_NUMBER double | 477 | #define LUA_NUMBER double |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.41 2005/05/03 19:30:17 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.42 2005/05/04 20:42:28 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -688,11 +688,11 @@ StkId luaV_execute (lua_State *L, int nexeccalls) { | |||
688 | const TValue *pstep = ra+2; | 688 | const TValue *pstep = ra+2; |
689 | L->savedpc = pc; /* next steps may throw errors */ | 689 | L->savedpc = pc; /* next steps may throw errors */ |
690 | if (!tonumber(init, ra)) | 690 | if (!tonumber(init, ra)) |
691 | luaG_runerror(L, "`for' initial value must be a number"); | 691 | luaG_runerror(L, "'for' initial value must be a number"); |
692 | else if (!tonumber(plimit, ra+1)) | 692 | else if (!tonumber(plimit, ra+1)) |
693 | luaG_runerror(L, "`for' limit must be a number"); | 693 | luaG_runerror(L, "'for' limit must be a number"); |
694 | else if (!tonumber(pstep, ra+2)) | 694 | else if (!tonumber(pstep, ra+2)) |
695 | luaG_runerror(L, "`for' step must be a number"); | 695 | luaG_runerror(L, "'for' step must be a number"); |
696 | setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); | 696 | setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); |
697 | dojump(L, pc, GETARG_sBx(i)); | 697 | dojump(L, pc, GETARG_sBx(i)); |
698 | continue; | 698 | continue; |