macros 'LUA_QL'/'LUA_QL' deprecated

This commit is contained in:
Roberto Ierusalimschy 2014-10-17 13:28:21 -03:00
parent ea3155e380
commit f97c64d7bf
16 changed files with 67 additions and 75 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lauxlib.c,v 1.267 2014/07/19 14:37:09 roberto Exp roberto $ ** $Id: lauxlib.c,v 1.268 2014/09/22 06:42:15 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
*/ */
@ -82,12 +82,12 @@ static int pushglobalfuncname (lua_State *L, lua_Debug *ar) {
static void pushfuncname (lua_State *L, lua_Debug *ar) { static void pushfuncname (lua_State *L, lua_Debug *ar) {
if (*ar->namewhat != '\0') /* is there a name? */ if (*ar->namewhat != '\0') /* is there a name? */
lua_pushfstring(L, "function " LUA_QS, ar->name); lua_pushfstring(L, "function '%s'", ar->name);
else if (*ar->what == 'm') /* main? */ else if (*ar->what == 'm') /* main? */
lua_pushliteral(L, "main chunk"); lua_pushliteral(L, "main chunk");
else if (*ar->what == 'C') { else if (*ar->what == 'C') {
if (pushglobalfuncname(L, ar)) { if (pushglobalfuncname(L, ar)) {
lua_pushfstring(L, "function " LUA_QS, lua_tostring(L, -1)); lua_pushfstring(L, "function '%s'", lua_tostring(L, -1));
lua_remove(L, -2); /* remove name */ lua_remove(L, -2); /* remove name */
} }
else else
@ -158,12 +158,12 @@ LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) {
if (strcmp(ar.namewhat, "method") == 0) { if (strcmp(ar.namewhat, "method") == 0) {
arg--; /* do not count `self' */ arg--; /* do not count `self' */
if (arg == 0) /* error is in the self argument itself? */ if (arg == 0) /* error is in the self argument itself? */
return luaL_error(L, "calling " LUA_QS " on bad self (%s)", return luaL_error(L, "calling '%s' on bad self (%s)",
ar.name, extramsg); ar.name, extramsg);
} }
if (ar.name == NULL) if (ar.name == NULL)
ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?"; ar.name = (pushglobalfuncname(L, &ar)) ? lua_tostring(L, -1) : "?";
return luaL_error(L, "bad argument #%d to " LUA_QS " (%s)", return luaL_error(L, "bad argument #%d to '%s' (%s)",
arg, ar.name, extramsg); arg, ar.name, extramsg);
} }
@ -335,7 +335,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def,
if (strcmp(lst[i], name) == 0) if (strcmp(lst[i], name) == 0)
return i; return i;
return luaL_argerror(L, arg, return luaL_argerror(L, arg,
lua_pushfstring(L, "invalid option " LUA_QS, name)); lua_pushfstring(L, "invalid option '%s'", name));
} }
@ -823,7 +823,7 @@ LUALIB_API void luaL_pushmodule (lua_State *L, const char *modname,
/* try global variable (and create one if it does not exist) */ /* try global variable (and create one if it does not exist) */
lua_pushglobaltable(L); lua_pushglobaltable(L);
if (luaL_findtable(L, 0, modname, sizehint) != NULL) if (luaL_findtable(L, 0, modname, sizehint) != NULL)
luaL_error(L, "name conflict for module " LUA_QS, modname); luaL_error(L, "name conflict for module '%s'", modname);
lua_pushvalue(L, -1); lua_pushvalue(L, -1);
lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */ lua_setfield(L, -3, modname); /* _LOADED[modname] = new table */
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lbaselib.c,v 1.300 2014/10/07 18:29:13 roberto Exp roberto $ ** $Id: lbaselib.c,v 1.301 2014/10/15 14:27:40 roberto Exp roberto $
** Basic library ** Basic library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -32,8 +32,7 @@ static int luaB_print (lua_State *L) {
lua_call(L, 1, 1); lua_call(L, 1, 1);
s = lua_tolstring(L, -1, &l); /* get result */ s = lua_tolstring(L, -1, &l); /* get result */
if (s == NULL) if (s == NULL)
return luaL_error(L, return luaL_error(L, "'tostring' must return a string to 'print'");
LUA_QL("tostring") " must return a string to " LUA_QL("print"));
if (i>1) luai_writestring("\t", 1); if (i>1) luai_writestring("\t", 1);
luai_writestring(s, l); luai_writestring(s, l);
lua_pop(L, 1); /* pop result */ lua_pop(L, 1); /* pop result */

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ldebug.c,v 2.99 2014/07/17 12:30:53 roberto Exp roberto $ ** $Id: ldebug.c,v 2.100 2014/07/30 14:00:14 roberto Exp roberto $
** Debug Interface ** Debug Interface
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -515,7 +515,7 @@ static const char *varinfo (lua_State *L, const TValue *o) {
kind = getobjname(ci_func(ci)->p, currentpc(ci), kind = getobjname(ci_func(ci)->p, currentpc(ci),
cast_int(o - ci->u.l.base), &name); cast_int(o - ci->u.l.base), &name);
} }
return (kind) ? luaO_pushfstring(L, " (%s " LUA_QS ")", kind, name) : ""; return (kind) ? luaO_pushfstring(L, " (%s '%s')", kind, name) : "";
} }

4
ldo.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: ldo.c,v 2.128 2014/10/07 18:29:13 roberto Exp roberto $ ** $Id: ldo.c,v 2.129 2014/10/08 12:20:26 roberto Exp roberto $
** Stack and Call structure of Lua ** Stack and Call structure of Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -662,7 +662,7 @@ struct SParser { /* data to `f_parser' */
static void checkmode (lua_State *L, const char *mode, const char *x) { static void checkmode (lua_State *L, const char *mode, const char *x) {
if (mode && strchr(mode, x[0]) == NULL) { if (mode && strchr(mode, x[0]) == NULL) {
luaO_pushfstring(L, luaO_pushfstring(L,
"attempt to load a %s chunk (mode is " LUA_QS ")", x, mode); "attempt to load a %s chunk (mode is '%s')", x, mode);
luaD_throw(L, LUA_ERRSYNTAX); luaD_throw(L, LUA_ERRSYNTAX);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: liolib.c,v 2.131 2014/10/03 12:54:57 roberto Exp roberto $ ** $Id: liolib.c,v 2.132 2014/10/15 14:27:40 roberto Exp roberto $
** Standard I/O (and system) library ** Standard I/O (and system) library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -70,7 +70,7 @@
/* ANSI definitions */ /* ANSI definitions */
#define l_popen(L,c,m) \ #define l_popen(L,c,m) \
((void)((void)c, m), \ ((void)((void)c, m), \
luaL_error(L, LUA_QL("popen") " not supported"), \ luaL_error(L, "'popen' not supported"), \
(FILE*)0) (FILE*)0)
#define l_pclose(L,file) ((void)L, (void)file, -1) #define l_pclose(L,file) ((void)L, (void)file, -1)
@ -244,7 +244,7 @@ static void opencheck (lua_State *L, const char *fname, const char *mode) {
LStream *p = newfile(L); LStream *p = newfile(L);
p->f = fopen(fname, mode); p->f = fopen(fname, mode);
if (p->f == NULL) if (p->f == NULL)
luaL_error(L, "cannot open file " LUA_QS " (%s)", fname, strerror(errno)); luaL_error(L, "cannot open file '%s' (%s)", fname, strerror(errno));
} }

8
llex.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: llex.c,v 2.81 2014/10/01 11:52:33 roberto Exp roberto $ ** $Id: llex.c,v 2.82 2014/10/10 22:23:04 roberto Exp roberto $
** Lexical Analyzer ** Lexical Analyzer
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -79,12 +79,12 @@ void luaX_init (lua_State *L) {
const char *luaX_token2str (LexState *ls, int token) { const char *luaX_token2str (LexState *ls, int token) {
if (token < FIRST_RESERVED) { /* single-byte symbols? */ if (token < FIRST_RESERVED) { /* single-byte symbols? */
lua_assert(token == cast_uchar(token)); lua_assert(token == cast_uchar(token));
return luaO_pushfstring(ls->L, LUA_QL("%c"), token); return luaO_pushfstring(ls->L, "'%c'", token);
} }
else { else {
const char *s = luaX_tokens[token - FIRST_RESERVED]; const char *s = luaX_tokens[token - FIRST_RESERVED];
if (token < TK_EOS) /* fixed format (symbols and reserved words)? */ if (token < TK_EOS) /* fixed format (symbols and reserved words)? */
return luaO_pushfstring(ls->L, LUA_QS, s); return luaO_pushfstring(ls->L, "'%s'", s);
else /* names, strings, and numerals */ else /* names, strings, and numerals */
return s; return s;
} }
@ -96,7 +96,7 @@ static const char *txtToken (LexState *ls, int token) {
case TK_NAME: case TK_STRING: case TK_NAME: case TK_STRING:
case TK_FLT: case TK_INT: case TK_FLT: case TK_INT:
save(ls, '\0'); save(ls, '\0');
return luaO_pushfstring(ls->L, LUA_QS, luaZ_buffer(ls->buff)); return luaO_pushfstring(ls->L, "'%s'", luaZ_buffer(ls->buff));
default: default:
return luaX_token2str(ls, token); return luaX_token2str(ls, token);
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: loadlib.c,v 1.115 2014/07/28 17:47:53 roberto Exp roberto $ ** $Id: loadlib.c,v 1.116 2014/07/29 16:01: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
** **
@ -396,7 +396,7 @@ static const char *searchpath (lua_State *L, const char *name,
lua_remove(L, -2); /* remove path template */ lua_remove(L, -2); /* remove path template */
if (readable(filename)) /* does file exist and is readable? */ if (readable(filename)) /* does file exist and is readable? */
return filename; /* return that file name */ return filename; /* return that file name */
lua_pushfstring(L, "\n\tno file " LUA_QS, filename); lua_pushfstring(L, "\n\tno file '%s'", filename);
lua_remove(L, -2); /* remove file name */ lua_remove(L, -2); /* remove file name */
luaL_addvalue(&msg); /* concatenate error msg. entry */ luaL_addvalue(&msg); /* concatenate error msg. entry */
} }
@ -426,7 +426,7 @@ static const char *findfile (lua_State *L, const char *name,
lua_getfield(L, lua_upvalueindex(1), pname); lua_getfield(L, lua_upvalueindex(1), pname);
path = lua_tostring(L, -1); path = lua_tostring(L, -1);
if (path == NULL) if (path == NULL)
luaL_error(L, LUA_QL("package.%s") " must be a string", pname); luaL_error(L, "'package.%s' must be a string", pname);
return searchpath(L, name, path, ".", dirsep); return searchpath(L, name, path, ".", dirsep);
} }
@ -437,8 +437,7 @@ static int checkload (lua_State *L, int stat, const char *filename) {
return 2; /* return open function and file name */ return 2; /* return open function and file name */
} }
else else
return luaL_error(L, "error loading module " LUA_QS return luaL_error(L, "error loading module '%s' from file '%s':\n\t%s",
" from file " LUA_QS ":\n\t%s",
lua_tostring(L, 1), filename, lua_tostring(L, -1)); lua_tostring(L, 1), filename, lua_tostring(L, -1));
} }
@ -499,8 +498,7 @@ static int searcher_Croot (lua_State *L) {
if (stat != ERRFUNC) if (stat != ERRFUNC)
return checkload(L, 0, filename); /* real error */ return checkload(L, 0, filename); /* real error */
else { /* open function not found */ else { /* open function not found */
lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS, lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename);
name, filename);
return 1; return 1;
} }
} }
@ -524,14 +522,13 @@ static void findloader (lua_State *L, const char *name) {
luaL_buffinit(L, &msg); luaL_buffinit(L, &msg);
lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */ lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */
if (!lua_istable(L, 3)) if (!lua_istable(L, 3))
luaL_error(L, LUA_QL("package.searchers") " must be a table"); luaL_error(L, "'package.searchers' must be a table");
/* iterate over available searchers to find a loader */ /* iterate over available searchers to find a loader */
for (i = 1; ; i++) { for (i = 1; ; i++) {
if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */ if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */
lua_pop(L, 1); /* remove nil */ lua_pop(L, 1); /* remove nil */
luaL_pushresult(&msg); /* create error message */ luaL_pushresult(&msg); /* create error message */
luaL_error(L, "module " LUA_QS " not found:%s", luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
name, lua_tostring(L, -1));
} }
lua_pushstring(L, name); lua_pushstring(L, name);
lua_call(L, 1, 2); /* call it */ lua_call(L, 1, 2); /* call it */
@ -589,7 +586,7 @@ static void set_env (lua_State *L) {
if (lua_getstack(L, 1, &ar) == 0 || if (lua_getstack(L, 1, &ar) == 0 ||
lua_getinfo(L, "f", &ar) == 0 || /* get calling function */ lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
lua_iscfunction(L, -1)) lua_iscfunction(L, -1))
luaL_error(L, LUA_QL("module") " not called from a Lua function"); luaL_error(L, "'module' not called from a Lua function");
lua_pushvalue(L, -2); /* copy new environment table to top */ lua_pushvalue(L, -2); /* copy new environment table to top */
lua_setupvalue(L, -2, 1); lua_setupvalue(L, -2, 1);
lua_pop(L, 1); /* remove function */ lua_pop(L, 1); /* remove function */

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lobject.c,v 2.91 2014/10/04 22:57:10 roberto Exp roberto $ ** $Id: lobject.c,v 2.92 2014/10/10 22:23:04 roberto Exp roberto $
** Some generic functions over Lua objects ** Some generic functions over Lua objects
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -415,9 +415,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
break; break;
} }
default: { default: {
luaG_runerror(L, luaG_runerror(L, "invalid option '%%%c' to 'lua_pushfstring'",
"invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"), *(e + 1));
*(e + 1));
} }
} }
n += 2; n += 2;

View File

@ -1,5 +1,5 @@
/* /*
** $Id: loslib.c,v 1.47 2014/10/01 11:54:56 roberto Exp roberto $ ** $Id: loslib.c,v 1.48 2014/10/08 19:57:31 roberto Exp roberto $
** Standard Operating System library ** Standard Operating System library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -189,7 +189,7 @@ static int getfield (lua_State *L, const char *key, int d) {
res = (int)lua_tointegerx(L, -1, &isnum); res = (int)lua_tointegerx(L, -1, &isnum);
if (!isnum) { if (!isnum) {
if (d < 0) if (d < 0)
return luaL_error(L, "field " LUA_QS " missing in date table", key); return luaL_error(L, "field '%s' missing in date table", key);
res = d; res = d;
} }
lua_pop(L, 1); lua_pop(L, 1);

View File

@ -1,5 +1,5 @@
/* /*
** $Id: lparser.c,v 2.141 2014/07/18 13:36:14 roberto Exp roberto $ ** $Id: lparser.c,v 2.142 2014/07/21 16:02:10 roberto Exp roberto $
** Lua Parser ** Lua Parser
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -340,7 +340,7 @@ static void closegoto (LexState *ls, int g, Labeldesc *label) {
if (gt->nactvar < label->nactvar) { if (gt->nactvar < label->nactvar) {
TString *vname = getlocvar(fs, gt->nactvar)->varname; TString *vname = getlocvar(fs, gt->nactvar)->varname;
const char *msg = luaO_pushfstring(ls->L, const char *msg = luaO_pushfstring(ls->L,
"<goto %s> at line %d jumps into the scope of local " LUA_QS, "<goto %s> at line %d jumps into the scope of local '%s'",
getstr(gt->name), gt->line, getstr(vname)); getstr(gt->name), gt->line, getstr(vname));
semerror(ls, msg); semerror(ls, msg);
} }
@ -457,7 +457,7 @@ static void breaklabel (LexState *ls) {
static l_noret undefgoto (LexState *ls, Labeldesc *gt) { static l_noret undefgoto (LexState *ls, Labeldesc *gt) {
const char *msg = isreserved(gt->name) const char *msg = isreserved(gt->name)
? "<%s> at line %d not inside a loop" ? "<%s> at line %d not inside a loop"
: "no visible label " LUA_QS " for <goto> at line %d"; : "no visible label '%s' for <goto> at line %d";
msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line); msg = luaO_pushfstring(ls->L, msg, getstr(gt->name), gt->line);
semerror(ls, msg); semerror(ls, msg);
} }
@ -761,7 +761,7 @@ static void parlist (LexState *ls) {
f->is_vararg = 1; f->is_vararg = 1;
break; break;
} }
default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected"); default: luaX_syntaxerror(ls, "<name> or '...' expected");
} }
} while (!f->is_vararg && testnext(ls, ',')); } while (!f->is_vararg && testnext(ls, ','));
} }
@ -953,7 +953,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 " LUA_QL("...") " outside a vararg function"); "cannot use '...' outside a vararg function");
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;
} }
@ -1200,7 +1200,7 @@ static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) {
for (i = fs->bl->firstlabel; i < ll->n; i++) { for (i = fs->bl->firstlabel; i < ll->n; i++) {
if (eqstr(label, ll->arr[i].name)) { if (eqstr(label, ll->arr[i].name)) {
const char *msg = luaO_pushfstring(fs->ls->L, const char *msg = luaO_pushfstring(fs->ls->L,
"label " LUA_QS " already defined on line %d", "label '%s' already defined on line %d",
getstr(label), ll->arr[i].line); getstr(label), ll->arr[i].line);
semerror(fs->ls, msg); semerror(fs->ls, msg);
} }
@ -1367,7 +1367,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, LUA_QL("=") " or " LUA_QL("in") " expected"); default: luaX_syntaxerror(ls, "'=' or '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.202 2014/10/01 11:54:56 roberto Exp roberto $ ** $Id: lstrlib.c,v 1.203 2014/10/17 10:55:28 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
*/ */
@ -250,14 +250,14 @@ static const char *classend (MatchState *ms, const char *p) {
switch (*p++) { switch (*p++) {
case L_ESC: { case L_ESC: {
if (p == ms->p_end) if (p == ms->p_end)
luaL_error(ms->L, "malformed pattern (ends with " LUA_QL("%%") ")"); luaL_error(ms->L, "malformed pattern (ends with '%%')");
return p+1; return p+1;
} }
case '[': { case '[': {
if (*p == '^') p++; if (*p == '^') p++;
do { /* look for a `]' */ do { /* look for a `]' */
if (p == ms->p_end) if (p == ms->p_end)
luaL_error(ms->L, "malformed pattern (missing " LUA_QL("]") ")"); luaL_error(ms->L, "malformed pattern (missing ']')");
if (*(p++) == L_ESC && p < ms->p_end) if (*(p++) == L_ESC && p < ms->p_end)
p++; /* skip escapes (e.g. `%]') */ p++; /* skip escapes (e.g. `%]') */
} while (*p != ']'); } while (*p != ']');
@ -332,8 +332,7 @@ static int singlematch (MatchState *ms, const char *s, const char *p,
static const char *matchbalance (MatchState *ms, const char *s, static const char *matchbalance (MatchState *ms, const char *s,
const char *p) { const char *p) {
if (p >= ms->p_end - 1) if (p >= ms->p_end - 1)
luaL_error(ms->L, "malformed pattern " luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')");
"(missing arguments to " LUA_QL("%%b") ")");
if (*s != *p) return NULL; if (*s != *p) return NULL;
else { else {
int b = *p; int b = *p;
@ -450,8 +449,7 @@ 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 " LUA_QL("[") " after " luaL_error(ms->L, "missing '[' after '%%f' in pattern");
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) &&
@ -694,8 +692,7 @@ static void add_s (MatchState *ms, luaL_Buffer *b, const char *s,
i++; /* skip ESC */ i++; /* skip ESC */
if (!isdigit(uchar(news[i]))) { if (!isdigit(uchar(news[i]))) {
if (news[i] != L_ESC) if (news[i] != L_ESC)
luaL_error(L, "invalid use of " LUA_QL("%c") luaL_error(L, "invalid use of '%c' in replacement string", L_ESC);
" in replacement string", L_ESC);
luaL_addchar(b, news[i]); luaL_addchar(b, news[i]);
} }
else if (news[i] == '0') else if (news[i] == '0')
@ -929,8 +926,8 @@ static int str_format (lua_State *L) {
} }
} }
default: { /* also treat cases `pnLlh' */ default: { /* also treat cases `pnLlh' */
return luaL_error(L, "invalid option " LUA_QL("%%%c") " to " return luaL_error(L, "invalid option '%%%c' to 'format'",
LUA_QL("format"), *(strfrmt - 1)); *(strfrmt - 1));
} }
} }
luaL_addsize(&b, nb); luaL_addsize(&b, nb);

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltable.c,v 2.94 2014/08/01 17:24:02 roberto Exp roberto $ ** $Id: ltable.c,v 2.95 2014/09/04 18:15:29 roberto Exp roberto $
** Lua tables (hash) ** Lua tables (hash)
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -181,7 +181,7 @@ static unsigned int findindex (lua_State *L, Table *t, StkId key) {
} }
nx = gnext(n); nx = gnext(n);
if (nx == 0) if (nx == 0)
luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ luaG_runerror(L, "invalid key to 'next'"); /* key not found */
else n += nx; else n += nx;
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: ltablib.c,v 1.75 2014/08/21 20:07:56 roberto Exp roberto $ ** $Id: ltablib.c,v 1.76 2014/09/22 06:42:15 roberto Exp roberto $
** Library for Table Manipulation ** Library for Table Manipulation
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -91,7 +91,7 @@ static int tinsert (lua_State *L) {
break; break;
} }
default: { default: {
return luaL_error(L, "wrong number of arguments to " LUA_QL("insert")); return luaL_error(L, "wrong number of arguments to 'insert'");
} }
} }
(*ta.seti)(L, 1, pos); /* t[pos] = v */ (*ta.seti)(L, 1, pos); /* t[pos] = v */
@ -154,8 +154,8 @@ static int tmove (lua_State *L) {
static void addfield (lua_State *L, luaL_Buffer *b, TabA *ta, lua_Integer i) { static void addfield (lua_State *L, luaL_Buffer *b, TabA *ta, lua_Integer i) {
(*ta->geti)(L, 1, i); (*ta->geti)(L, 1, i);
if (!lua_isstring(L, -1)) if (!lua_isstring(L, -1))
luaL_error(L, "invalid value (%s) at index %d in table for " luaL_error(L, "invalid value (%s) at index %d in table for 'concat'",
LUA_QL("concat"), luaL_typename(L, -1), i); luaL_typename(L, -1), i);
luaL_addvalue(b); luaL_addvalue(b);
} }

13
lua.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lua.c,v 1.213 2014/06/30 19:48:08 roberto Exp roberto $ ** $Id: lua.c,v 1.214 2014/09/25 14:20:37 roberto Exp roberto $
** Lua stand-alone interpreter ** Lua stand-alone interpreter
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -134,9 +134,9 @@ static void print_usage (const char *badoption) {
luai_writestringerror( luai_writestringerror(
"usage: %s [options] [script [args]]\n" "usage: %s [options] [script [args]]\n"
"Available options are:\n" "Available options are:\n"
" -e stat execute string " LUA_QL("stat") "\n" " -e stat execute string 'stat'\n"
" -i enter interactive mode after executing " LUA_QL("script") "\n" " -i enter interactive mode after executing 'script'\n"
" -l name require library " LUA_QL("name") "\n" " -l name require library 'name'\n"
" -v show version information\n" " -v show version information\n"
" -E ignore environment variables\n" " -E ignore environment variables\n"
" -- stop handling options\n" " -- stop handling options\n"
@ -388,9 +388,8 @@ static void l_print (lua_State *L) {
lua_getglobal(L, "print"); lua_getglobal(L, "print");
lua_insert(L, 1); lua_insert(L, 1);
if (lua_pcall(L, n, 0, 0) != LUA_OK) if (lua_pcall(L, n, 0, 0) != LUA_OK)
l_message(progname, lua_pushfstring(L, l_message(progname, lua_pushfstring(L, "error calling 'print' (%s)",
"error calling " LUA_QL("print") " (%s)", lua_tostring(L, -1)));
lua_tostring(L, -1)));
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
** $Id: luaconf.h,v 1.216 2014/10/08 20:32:50 roberto Exp roberto $ ** $Id: luaconf.h,v 1.217 2014/10/15 14:53:20 roberto Exp roberto $
** Configuration file for Lua ** Configuration file for Lua
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -243,7 +243,8 @@
/* /*
@@ LUA_QL describes how error messages quote program elements. @@ LUA_QL describes how error messages quote program elements.
** CHANGE it if you want a different appearance. ** Lua does not use these macros anymore; they are here for
** compatibility only.
*/ */
#define LUA_QL(x) "'" x "'" #define LUA_QL(x) "'" x "'"
#define LUA_QS LUA_QL("%s") #define LUA_QS LUA_QL("%s")

8
lvm.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 2.222 2014/07/30 14:42:44 roberto Exp roberto $ ** $Id: lvm.c,v 2.223 2014/09/04 18:15:29 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -1033,13 +1033,13 @@ void luaV_execute (lua_State *L) {
else { /* try making all values floats */ else { /* try making all values floats */
lua_Number ninit; lua_Number nlimit; lua_Number nstep; lua_Number ninit; lua_Number nlimit; lua_Number nstep;
if (!tonumber(plimit, &nlimit)) if (!tonumber(plimit, &nlimit))
luaG_runerror(L, LUA_QL("for") " limit must be a number"); luaG_runerror(L, "'for' limit must be a number");
setfltvalue(plimit, nlimit); setfltvalue(plimit, nlimit);
if (!tonumber(pstep, &nstep)) if (!tonumber(pstep, &nstep))
luaG_runerror(L, LUA_QL("for") " step must be a number"); luaG_runerror(L, "'for' step must be a number");
setfltvalue(pstep, nstep); setfltvalue(pstep, nstep);
if (!tonumber(init, &ninit)) if (!tonumber(init, &ninit))
luaG_runerror(L, LUA_QL("for") " initial value must be a number"); luaG_runerror(L, "'for' initial value must be a number");
setfltvalue(init, luai_numsub(L, ninit, nstep)); setfltvalue(init, luai_numsub(L, ninit, nstep));
} }
ci->u.l.savedpc += GETARG_sBx(i); ci->u.l.savedpc += GETARG_sBx(i);