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
** 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) {
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? */
lua_pushliteral(L, "main chunk");
else if (*ar->what == 'C') {
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 */
}
else
@ -158,12 +158,12 @@ LUALIB_API int luaL_argerror (lua_State *L, int arg, const char *extramsg) {
if (strcmp(ar.namewhat, "method") == 0) {
arg--; /* do not count `self' */
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);
}
if (ar.name == NULL)
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);
}
@ -335,7 +335,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int arg, const char *def,
if (strcmp(lst[i], name) == 0)
return i;
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) */
lua_pushglobaltable(L);
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_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
** See Copyright Notice in lua.h
*/
@ -32,8 +32,7 @@ static int luaB_print (lua_State *L) {
lua_call(L, 1, 1);
s = lua_tolstring(L, -1, &l); /* get result */
if (s == NULL)
return luaL_error(L,
LUA_QL("tostring") " must return a string to " LUA_QL("print"));
return luaL_error(L, "'tostring' must return a string to 'print'");
if (i>1) luai_writestring("\t", 1);
luai_writestring(s, l);
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
** 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),
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
** 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) {
if (mode && strchr(mode, x[0]) == NULL) {
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);
}
}

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
** See Copyright Notice in lua.h
*/
@ -70,7 +70,7 @@
/* ANSI definitions */
#define l_popen(L,c,m) \
((void)((void)c, m), \
luaL_error(L, LUA_QL("popen") " not supported"), \
luaL_error(L, "'popen' not supported"), \
(FILE*)0)
#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);
p->f = fopen(fname, mode);
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
** See Copyright Notice in lua.h
*/
@ -79,12 +79,12 @@ void luaX_init (lua_State *L) {
const char *luaX_token2str (LexState *ls, int token) {
if (token < FIRST_RESERVED) { /* single-byte symbols? */
lua_assert(token == cast_uchar(token));
return luaO_pushfstring(ls->L, LUA_QL("%c"), token);
return luaO_pushfstring(ls->L, "'%c'", token);
}
else {
const char *s = luaX_tokens[token - FIRST_RESERVED];
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 */
return s;
}
@ -96,7 +96,7 @@ static const char *txtToken (LexState *ls, int token) {
case TK_NAME: case TK_STRING:
case TK_FLT: case TK_INT:
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:
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
** 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 */
if (readable(filename)) /* does file exist and is readable? */
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 */
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);
path = lua_tostring(L, -1);
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);
}
@ -437,8 +437,7 @@ static int checkload (lua_State *L, int stat, const char *filename) {
return 2; /* return open function and file name */
}
else
return luaL_error(L, "error loading module " LUA_QS
" from file " LUA_QS ":\n\t%s",
return luaL_error(L, "error loading module '%s' from file '%s':\n\t%s",
lua_tostring(L, 1), filename, lua_tostring(L, -1));
}
@ -499,8 +498,7 @@ static int searcher_Croot (lua_State *L) {
if (stat != ERRFUNC)
return checkload(L, 0, filename); /* real error */
else { /* open function not found */
lua_pushfstring(L, "\n\tno module " LUA_QS " in file " LUA_QS,
name, filename);
lua_pushfstring(L, "\n\tno module '%s' in file '%s'", name, filename);
return 1;
}
}
@ -524,14 +522,13 @@ static void findloader (lua_State *L, const char *name) {
luaL_buffinit(L, &msg);
lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 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 */
for (i = 1; ; i++) {
if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */
lua_pop(L, 1); /* remove nil */
luaL_pushresult(&msg); /* create error message */
luaL_error(L, "module " LUA_QS " not found:%s",
name, lua_tostring(L, -1));
luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
}
lua_pushstring(L, name);
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 ||
lua_getinfo(L, "f", &ar) == 0 || /* get calling function */
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_setupvalue(L, -2, 1);
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
** See Copyright Notice in lua.h
*/
@ -415,9 +415,8 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
break;
}
default: {
luaG_runerror(L,
"invalid option " LUA_QL("%%%c") " to " LUA_QL("lua_pushfstring"),
*(e + 1));
luaG_runerror(L, "invalid option '%%%c' to 'lua_pushfstring'",
*(e + 1));
}
}
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
** 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);
if (!isnum) {
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;
}
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
** See Copyright Notice in lua.h
*/
@ -340,7 +340,7 @@ static void closegoto (LexState *ls, int g, Labeldesc *label) {
if (gt->nactvar < label->nactvar) {
TString *vname = getlocvar(fs, gt->nactvar)->varname;
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));
semerror(ls, msg);
}
@ -457,7 +457,7 @@ static void breaklabel (LexState *ls) {
static l_noret undefgoto (LexState *ls, Labeldesc *gt) {
const char *msg = isreserved(gt->name)
? "<%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);
semerror(ls, msg);
}
@ -761,7 +761,7 @@ static void parlist (LexState *ls) {
f->is_vararg = 1;
break;
}
default: luaX_syntaxerror(ls, "<name> or " LUA_QL("...") " expected");
default: luaX_syntaxerror(ls, "<name> or '...' expected");
}
} while (!f->is_vararg && testnext(ls, ','));
}
@ -953,7 +953,7 @@ static void simpleexp (LexState *ls, expdesc *v) {
case TK_DOTS: { /* vararg */
FuncState *fs = ls->fs;
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));
break;
}
@ -1200,7 +1200,7 @@ static void checkrepeated (FuncState *fs, Labellist *ll, TString *label) {
for (i = fs->bl->firstlabel; i < ll->n; i++) {
if (eqstr(label, ll->arr[i].name)) {
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);
semerror(fs->ls, msg);
}
@ -1367,7 +1367,7 @@ static void forstat (LexState *ls, int line) {
switch (ls->t.token) {
case '=': fornum(ls, varname, line); 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);
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
** See Copyright Notice in lua.h
*/
@ -250,14 +250,14 @@ static const char *classend (MatchState *ms, const char *p) {
switch (*p++) {
case L_ESC: {
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;
}
case '[': {
if (*p == '^') p++;
do { /* look for a `]' */
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)
p++; /* skip escapes (e.g. `%]') */
} 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,
const char *p) {
if (p >= ms->p_end - 1)
luaL_error(ms->L, "malformed pattern "
"(missing arguments to " LUA_QL("%%b") ")");
luaL_error(ms->L, "malformed pattern (missing arguments to '%%b')");
if (*s != *p) return NULL;
else {
int b = *p;
@ -450,8 +449,7 @@ static const char *match (MatchState *ms, const char *s, const char *p) {
const char *ep; char previous;
p += 2;
if (*p != '[')
luaL_error(ms->L, "missing " LUA_QL("[") " after "
LUA_QL("%%f") " in pattern");
luaL_error(ms->L, "missing '[' after '%%f' in pattern");
ep = classend(ms, p); /* points to what is next */
previous = (s == ms->src_init) ? '\0' : *(s - 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 */
if (!isdigit(uchar(news[i]))) {
if (news[i] != L_ESC)
luaL_error(L, "invalid use of " LUA_QL("%c")
" in replacement string", L_ESC);
luaL_error(L, "invalid use of '%c' in replacement string", L_ESC);
luaL_addchar(b, news[i]);
}
else if (news[i] == '0')
@ -929,8 +926,8 @@ static int str_format (lua_State *L) {
}
}
default: { /* also treat cases `pnLlh' */
return luaL_error(L, "invalid option " LUA_QL("%%%c") " to "
LUA_QL("format"), *(strfrmt - 1));
return luaL_error(L, "invalid option '%%%c' to 'format'",
*(strfrmt - 1));
}
}
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)
** See Copyright Notice in lua.h
*/
@ -181,7 +181,7 @@ static unsigned int findindex (lua_State *L, Table *t, StkId key) {
}
nx = gnext(n);
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;
}
}

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
** See Copyright Notice in lua.h
*/
@ -91,7 +91,7 @@ static int tinsert (lua_State *L) {
break;
}
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 */
@ -154,8 +154,8 @@ static int tmove (lua_State *L) {
static void addfield (lua_State *L, luaL_Buffer *b, TabA *ta, lua_Integer i) {
(*ta->geti)(L, 1, i);
if (!lua_isstring(L, -1))
luaL_error(L, "invalid value (%s) at index %d in table for "
LUA_QL("concat"), luaL_typename(L, -1), i);
luaL_error(L, "invalid value (%s) at index %d in table for 'concat'",
luaL_typename(L, -1), i);
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
** See Copyright Notice in lua.h
*/
@ -134,9 +134,9 @@ static void print_usage (const char *badoption) {
luai_writestringerror(
"usage: %s [options] [script [args]]\n"
"Available options are:\n"
" -e stat execute string " LUA_QL("stat") "\n"
" -i enter interactive mode after executing " LUA_QL("script") "\n"
" -l name require library " LUA_QL("name") "\n"
" -e stat execute string 'stat'\n"
" -i enter interactive mode after executing 'script'\n"
" -l name require library 'name'\n"
" -v show version information\n"
" -E ignore environment variables\n"
" -- stop handling options\n"
@ -388,9 +388,8 @@ static void l_print (lua_State *L) {
lua_getglobal(L, "print");
lua_insert(L, 1);
if (lua_pcall(L, n, 0, 0) != LUA_OK)
l_message(progname, lua_pushfstring(L,
"error calling " LUA_QL("print") " (%s)",
lua_tostring(L, -1)));
l_message(progname, lua_pushfstring(L, "error calling 'print' (%s)",
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
** See Copyright Notice in lua.h
*/
@ -243,7 +243,8 @@
/*
@@ 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_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
** See Copyright Notice in lua.h
*/
@ -1033,13 +1033,13 @@ void luaV_execute (lua_State *L) {
else { /* try making all values floats */
lua_Number ninit; lua_Number nlimit; lua_Number nstep;
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);
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);
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));
}
ci->u.l.savedpc += GETARG_sBx(i);