new names for string formating functions
This commit is contained in:
48
lapi.c
48
lapi.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lapi.c,v 1.190 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: lapi.c,v 1.191 2002/05/15 18:57:44 roberto Exp roberto $
|
||||||
** Lua API
|
** Lua API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -355,10 +355,23 @@ LUA_API void lua_pushstring (lua_State *L, const char *s) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API void lua_vpushstr (lua_State *L, const char *fmt, va_list argp) {
|
LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
|
||||||
|
va_list argp) {
|
||||||
|
const char *ret;
|
||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
luaO_vpushstr(L, fmt, argp);
|
ret = luaO_pushvfstring(L, fmt, argp);
|
||||||
lua_unlock(L);
|
lua_unlock(L);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...) {
|
||||||
|
const char *ret;
|
||||||
|
va_list argp;
|
||||||
|
va_start(argp, fmt);
|
||||||
|
ret = lua_pushvfstring(L, fmt, argp);
|
||||||
|
va_end(argp);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -556,21 +569,16 @@ LUA_API int lua_pcall (lua_State *L, int nargs, int nresults, int errf) {
|
|||||||
|
|
||||||
static int errfile (lua_State *L, const char *filename) {
|
static int errfile (lua_State *L, const char *filename) {
|
||||||
if (filename == NULL) filename = "stdin";
|
if (filename == NULL) filename = "stdin";
|
||||||
lua_pushliteral(L, "cannot read ");
|
lua_pushfstring(L, "cannot read %s: %s", filename, lua_fileerror);
|
||||||
lua_pushstring(L, filename);
|
|
||||||
lua_pushliteral(L, ": ");
|
|
||||||
lua_pushstring(L, lua_fileerror);
|
|
||||||
lua_concat(L, 4);
|
|
||||||
return LUA_ERRFILE;
|
return LUA_ERRFILE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUA_API int lua_loadfile (lua_State *L, const char *filename) {
|
LUA_API int lua_loadfile (lua_State *L, const char *filename) {
|
||||||
ZIO z;
|
ZIO z;
|
||||||
const char *luafname; /* name used by lua */
|
int fnindex;
|
||||||
int status;
|
int status;
|
||||||
int bin; /* flag for file mode */
|
int bin; /* flag for file mode */
|
||||||
int nlevel; /* level on the stack of filename */
|
|
||||||
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
|
FILE *f = (filename == NULL) ? stdin : fopen(filename, "r");
|
||||||
if (f == NULL) return errfile(L, filename); /* unable to open file */
|
if (f == NULL) return errfile(L, filename); /* unable to open file */
|
||||||
bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]);
|
bin = (ungetc(getc(f), f) == LUA_SIGNATURE[0]);
|
||||||
@@ -580,19 +588,17 @@ LUA_API int lua_loadfile (lua_State *L, const char *filename) {
|
|||||||
if (f == NULL) return errfile(L, filename); /* unable to reopen file */
|
if (f == NULL) return errfile(L, filename); /* unable to reopen file */
|
||||||
}
|
}
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
lua_pushstring(L, "=stdin");
|
lua_pushliteral(L, "=stdin");
|
||||||
else {
|
else
|
||||||
lua_pushliteral(L, "@");
|
lua_pushfstring(L, "@%s", filename);
|
||||||
lua_pushstring(L, filename);
|
fnindex = lua_gettop(L); /* stack index of file name */
|
||||||
lua_concat(L, 2);
|
luaZ_Fopen(&z, f, lua_tostring(L, fnindex));
|
||||||
}
|
|
||||||
nlevel = lua_gettop(L);
|
|
||||||
luafname = lua_tostring(L, -1); /* luafname = `@'..filename */
|
|
||||||
luaZ_Fopen(&z, f, luafname);
|
|
||||||
status = luaD_protectedparser(L, &z, bin);
|
status = luaD_protectedparser(L, &z, bin);
|
||||||
if (ferror(f))
|
lua_remove(L, fnindex);
|
||||||
|
if (ferror(f)) {
|
||||||
|
if (status == 0) lua_pop(L, 1); /* remove chunk */
|
||||||
return errfile(L, filename);
|
return errfile(L, filename);
|
||||||
lua_remove(L, nlevel); /* remove filename */
|
}
|
||||||
if (f != stdin)
|
if (f != stdin)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
return status;
|
return status;
|
||||||
|
|||||||
21
lauxlib.c
21
lauxlib.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.c,v 1.69 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: lauxlib.c,v 1.70 2002/05/15 18:57:44 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
|
||||||
*/
|
*/
|
||||||
@@ -43,8 +43,9 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
|||||||
|
|
||||||
|
|
||||||
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
|
LUALIB_API int luaL_typerror (lua_State *L, int narg, const char *tname) {
|
||||||
luaL_vstr(L, "%s expected, got %s", tname, lua_typename(L, lua_type(L,narg)));
|
const char *msg = lua_pushfstring(L, "%s expected, got %s",
|
||||||
return luaL_argerror(L, narg, lua_tostring(L, -1));
|
tname, lua_typename(L, lua_type(L,narg)));
|
||||||
|
return luaL_argerror(L, narg, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,25 +143,17 @@ LUALIB_API void luaL_opennamedlib (lua_State *L, const char *libname,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...) {
|
|
||||||
va_list argp;
|
|
||||||
va_start(argp, fmt);
|
|
||||||
lua_vpushstr(L, fmt, argp);
|
|
||||||
va_end(argp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) {
|
LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...) {
|
||||||
lua_Debug ar;
|
lua_Debug ar;
|
||||||
|
const char *msg;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
lua_vpushstr(L, fmt, argp);
|
msg = lua_pushvfstring(L, fmt, argp);
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
if (lua_getstack(L, 1, &ar)) { /* check calling function */
|
if (lua_getstack(L, 1, &ar)) { /* check calling function */
|
||||||
lua_getinfo(L, "Snl", &ar);
|
lua_getinfo(L, "Snl", &ar);
|
||||||
if (ar.currentline > 0)
|
if (ar.currentline > 0)
|
||||||
luaL_vstr(L, "%s:%d: %s",
|
lua_pushfstring(L, "%s:%d: %s", ar.short_src, ar.currentline, msg);
|
||||||
ar.short_src, ar.currentline, lua_tostring(L, -1));
|
|
||||||
}
|
}
|
||||||
return lua_errorobj(L);
|
return lua_errorobj(L);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lauxlib.h,v 1.45 2002/05/01 20:40:42 roberto Exp roberto $
|
** $Id: lauxlib.h,v 1.46 2002/05/06 19:05:10 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
|
||||||
*/
|
*/
|
||||||
@@ -45,7 +45,6 @@ LUALIB_API void luaL_check_type (lua_State *L, int narg, int t);
|
|||||||
LUALIB_API void luaL_check_any (lua_State *L, int narg);
|
LUALIB_API void luaL_check_any (lua_State *L, int narg);
|
||||||
|
|
||||||
LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...);
|
LUALIB_API int luaL_verror (lua_State *L, const char *fmt, ...);
|
||||||
LUALIB_API void luaL_vstr (lua_State *L, const char *fmt, ...);
|
|
||||||
LUALIB_API int luaL_findstring (const char *name,
|
LUALIB_API int luaL_findstring (const char *name,
|
||||||
const char *const list[]);
|
const char *const list[]);
|
||||||
|
|
||||||
|
|||||||
25
lbaselib.c
25
lbaselib.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.72 2002/05/06 19:05:10 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.73 2002/05/13 13:10:58 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -31,28 +31,6 @@ static int luaB__ALERT (lua_State *L) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Basic implementation of _ERRORMESSAGE.
|
|
||||||
** The library `liolib' redefines _ERRORMESSAGE for better error information.
|
|
||||||
*/
|
|
||||||
static int luaB__ERRORMESSAGE (lua_State *L) {
|
|
||||||
lua_Debug ar;
|
|
||||||
luaL_check_type(L, 1, LUA_TSTRING);
|
|
||||||
lua_pushliteral(L, "error: ");
|
|
||||||
lua_pushvalue(L, 1);
|
|
||||||
if (lua_getstack(L, 1, &ar)) {
|
|
||||||
lua_getinfo(L, "Sl", &ar);
|
|
||||||
if (ar.source && ar.currentline > 0) {
|
|
||||||
luaL_vstr(L, "\n <%s: line %d>", ar.short_src, ar.currentline);
|
|
||||||
lua_concat(L, 2);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lua_pushliteral(L, "\n");
|
|
||||||
lua_concat(L, 3);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** If your system does not support `stdout', you can just remove this function.
|
** If your system does not support `stdout', you can just remove this function.
|
||||||
** If you need, you can define your own `print' function, following this
|
** If you need, you can define your own `print' function, following this
|
||||||
@@ -408,7 +386,6 @@ static int luaB_require (lua_State *L) {
|
|||||||
|
|
||||||
static const luaL_reg base_funcs[] = {
|
static const luaL_reg base_funcs[] = {
|
||||||
{LUA_ALERT, luaB__ALERT},
|
{LUA_ALERT, luaB__ALERT},
|
||||||
{"_ERRORMESSAGE", luaB__ERRORMESSAGE},
|
|
||||||
{"error", luaB_error},
|
{"error", luaB_error},
|
||||||
{"metatable", luaB_metatable},
|
{"metatable", luaB_metatable},
|
||||||
{"globals", luaB_globals},
|
{"globals", luaB_globals},
|
||||||
|
|||||||
17
ldblib.c
17
ldblib.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldblib.c,v 1.51 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: ldblib.c,v 1.52 2002/05/15 18:57:44 roberto Exp roberto $
|
||||||
** Interface from Lua to its debug API
|
** Interface from Lua to its debug API
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -41,7 +41,7 @@ static int getinfo (lua_State *L) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (lua_isfunction(L, 1)) {
|
else if (lua_isfunction(L, 1)) {
|
||||||
luaL_vstr(L, ">%s", options);
|
lua_pushfstring(L, ">%s", options);
|
||||||
options = lua_tostring(L, -1);
|
options = lua_tostring(L, -1);
|
||||||
lua_pushvalue(L, 1);
|
lua_pushvalue(L, 1);
|
||||||
}
|
}
|
||||||
@@ -207,23 +207,24 @@ static int errorfb (lua_State *L) {
|
|||||||
sprintf(buff, "%4d- ", level-1);
|
sprintf(buff, "%4d- ", level-1);
|
||||||
lua_pushstring(L, buff);
|
lua_pushstring(L, buff);
|
||||||
lua_getinfo(L, "Snl", &ar);
|
lua_getinfo(L, "Snl", &ar);
|
||||||
luaL_vstr(L, "%s:", ar.short_src);
|
lua_pushfstring(L, "%s:", ar.short_src);
|
||||||
if (ar.currentline > 0)
|
if (ar.currentline > 0)
|
||||||
luaL_vstr(L, "%d:", ar.currentline);
|
lua_pushfstring(L, "%d:", ar.currentline);
|
||||||
switch (*ar.namewhat) {
|
switch (*ar.namewhat) {
|
||||||
case 'g': /* global */
|
case 'g': /* global */
|
||||||
case 'l': /* local */
|
case 'l': /* local */
|
||||||
case 'f': /* field */
|
case 'f': /* field */
|
||||||
case 'm': /* method */
|
case 'm': /* method */
|
||||||
luaL_vstr(L, " in function `%s'", ar.name);
|
lua_pushfstring(L, " in function `%s'", ar.name);
|
||||||
break;
|
break;
|
||||||
default: {
|
default: {
|
||||||
if (*ar.what == 'm') /* main? */
|
if (*ar.what == 'm') /* main? */
|
||||||
luaL_vstr(L, " in main chunk");
|
lua_pushfstring(L, " in main chunk");
|
||||||
else if (*ar.what == 'C') /* C function? */
|
else if (*ar.what == 'C') /* C function? */
|
||||||
luaL_vstr(L, "%s", ar.short_src);
|
lua_pushfstring(L, "%s", ar.short_src);
|
||||||
else
|
else
|
||||||
luaL_vstr(L, " in function <%s:%d>", ar.short_src, ar.linedefined);
|
lua_pushfstring(L, " in function <%s:%d>",
|
||||||
|
ar.short_src, ar.linedefined);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lua_pushliteral(L, "\n");
|
lua_pushliteral(L, "\n");
|
||||||
|
|||||||
6
ldebug.c
6
ldebug.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldebug.c,v 1.115 2002/05/14 17:52:22 roberto Exp roberto $
|
** $Id: ldebug.c,v 1.116 2002/05/15 18:57:44 roberto Exp roberto $
|
||||||
** Debug Interface
|
** Debug Interface
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -517,13 +517,13 @@ void luaG_runerror (lua_State *L, const char *fmt, ...) {
|
|||||||
const char *msg;
|
const char *msg;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
msg = luaO_vpushstr(L, fmt, argp);
|
msg = luaO_pushvfstring(L, fmt, argp);
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
if (isLmark(L->ci)) {
|
if (isLmark(L->ci)) {
|
||||||
char buff[LUA_IDSIZE];
|
char buff[LUA_IDSIZE];
|
||||||
int line = currentline(L, L->ci);
|
int line = currentline(L, L->ci);
|
||||||
luaO_chunkid(buff, getstr(getluaproto(L->ci)->source), LUA_IDSIZE);
|
luaO_chunkid(buff, getstr(getluaproto(L->ci)->source), LUA_IDSIZE);
|
||||||
msg = luaO_pushstr(L, "%s:%d: %s", buff, line, msg);
|
msg = luaO_pushfstring(L, "%s:%d: %s", buff, line, msg);
|
||||||
}
|
}
|
||||||
luaD_error(L, msg, LUA_ERRRUN);
|
luaD_error(L, msg, LUA_ERRRUN);
|
||||||
}
|
}
|
||||||
|
|||||||
4
ldo.c
4
ldo.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 1.174 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: ldo.c,v 1.175 2002/05/15 18:57:44 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
|
||||||
*/
|
*/
|
||||||
@@ -424,7 +424,7 @@ int luaD_protectedparser (lua_State *L, ZIO *z, int bin) {
|
|||||||
lua_lock(L);
|
lua_lock(L);
|
||||||
p.z = z; p.bin = bin;
|
p.z = z; p.bin = bin;
|
||||||
/* before parsing, give a (good) chance to GC */
|
/* before parsing, give a (good) chance to GC */
|
||||||
if (G(L)->nblocks/8 >= G(L)->GCthreshold/10)
|
if (G(L)->nblocks + G(L)->nblocks/4 >= G(L)->GCthreshold)
|
||||||
luaC_collectgarbage(L);
|
luaC_collectgarbage(L);
|
||||||
old_blocks = G(L)->nblocks;
|
old_blocks = G(L)->nblocks;
|
||||||
setnilvalue(&p.err);
|
setnilvalue(&p.err);
|
||||||
|
|||||||
16
llex.c
16
llex.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 1.100 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: llex.c,v 1.101 2002/05/15 18:57:44 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +51,7 @@ void luaX_init (lua_State *L) {
|
|||||||
|
|
||||||
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
|
void luaX_checklimit (LexState *ls, int val, int limit, const char *msg) {
|
||||||
if (val > limit) {
|
if (val > limit) {
|
||||||
msg = luaO_pushstr(ls->L, "too many %s (limit=%d)", msg, limit);
|
msg = luaO_pushfstring(ls->L, "too many %s (limit=%d)", msg, limit);
|
||||||
luaX_syntaxerror(ls, msg);
|
luaX_syntaxerror(ls, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ static void luaX_error (LexState *ls, const char *s, const char *token) {
|
|||||||
lua_State *L = ls->L;
|
lua_State *L = ls->L;
|
||||||
char buff[MAXSRC];
|
char buff[MAXSRC];
|
||||||
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
luaO_chunkid(buff, getstr(ls->source), MAXSRC);
|
||||||
luaO_pushstr(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token);
|
luaO_pushfstring(L, "%s:%d: %s near `%s'", buff, ls->linenumber, s, token);
|
||||||
luaD_errorobj(L, L->top - 1, LUA_ERRSYNTAX);
|
luaD_errorobj(L, L->top - 1, LUA_ERRSYNTAX);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,13 +70,13 @@ void luaX_syntaxerror (LexState *ls, const char *msg) {
|
|||||||
const char *lasttoken;
|
const char *lasttoken;
|
||||||
switch (ls->t.token) {
|
switch (ls->t.token) {
|
||||||
case TK_NAME:
|
case TK_NAME:
|
||||||
lasttoken = luaO_pushstr(ls->L, "%s", getstr(ls->t.seminfo.ts));
|
lasttoken = luaO_pushfstring(ls->L, "%s", getstr(ls->t.seminfo.ts));
|
||||||
break;
|
break;
|
||||||
case TK_STRING:
|
case TK_STRING:
|
||||||
lasttoken = luaO_pushstr(ls->L, "\"%s\"", getstr(ls->t.seminfo.ts));
|
lasttoken = luaO_pushfstring(ls->L, "\"%s\"", getstr(ls->t.seminfo.ts));
|
||||||
break;
|
break;
|
||||||
case TK_NUMBER:
|
case TK_NUMBER:
|
||||||
lasttoken = luaO_pushstr(ls->L, "%f", ls->t.seminfo.r);
|
lasttoken = luaO_pushfstring(ls->L, "%f", ls->t.seminfo.r);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
lasttoken = luaX_token2str(ls, ls->t.token);
|
lasttoken = luaX_token2str(ls, ls->t.token);
|
||||||
@@ -89,7 +89,7 @@ void luaX_syntaxerror (LexState *ls, const char *msg) {
|
|||||||
const char *luaX_token2str (LexState *ls, int token) {
|
const char *luaX_token2str (LexState *ls, int token) {
|
||||||
if (token < FIRST_RESERVED) {
|
if (token < FIRST_RESERVED) {
|
||||||
lua_assert(token == (char)token);
|
lua_assert(token == (char)token);
|
||||||
return luaO_pushstr(ls->L, "%c", token);
|
return luaO_pushfstring(ls->L, "%c", token);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return token2string[token-FIRST_RESERVED];
|
return token2string[token-FIRST_RESERVED];
|
||||||
@@ -397,7 +397,7 @@ int luaX_lex (LexState *LS, SemInfo *seminfo) {
|
|||||||
int c = LS->current;
|
int c = LS->current;
|
||||||
if (iscntrl(c))
|
if (iscntrl(c))
|
||||||
luaX_error(LS, "invalid control char",
|
luaX_error(LS, "invalid control char",
|
||||||
luaO_pushstr(LS->L, "char(%d)", c));
|
luaO_pushfstring(LS->L, "char(%d)", c));
|
||||||
next(LS);
|
next(LS);
|
||||||
return c; /* single-char tokens (+ - / ...) */
|
return c; /* single-char tokens (+ - / ...) */
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.c,v 1.79 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: lobject.c,v 1.80 2002/05/15 18:57:44 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
|
||||||
*/
|
*/
|
||||||
@@ -99,7 +99,7 @@ static void pushstr (lua_State *L, const char *str) {
|
|||||||
|
|
||||||
|
|
||||||
/* this function handles only `%d', `%c', %f, and `%s' formats */
|
/* this function handles only `%d', `%c', %f, and `%s' formats */
|
||||||
const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp) {
|
const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) {
|
||||||
int n = 1;
|
int n = 1;
|
||||||
pushstr(L, "");
|
pushstr(L, "");
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@@ -141,11 +141,11 @@ const char *luaO_vpushstr (lua_State *L, const char *fmt, va_list argp) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char *luaO_pushstr (lua_State *L, const char *fmt, ...) {
|
const char *luaO_pushfstring (lua_State *L, const char *fmt, ...) {
|
||||||
const char *msg;
|
const char *msg;
|
||||||
va_list argp;
|
va_list argp;
|
||||||
va_start(argp, fmt);
|
va_start(argp, fmt);
|
||||||
msg = luaO_vpushstr(L, fmt, argp);
|
msg = luaO_pushvfstring(L, fmt, argp);
|
||||||
va_end(argp);
|
va_end(argp);
|
||||||
return msg;
|
return msg;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lobject.h,v 1.131 2002/05/07 17:36:56 roberto Exp roberto $
|
** $Id: lobject.h,v 1.132 2002/05/15 18:57:44 roberto Exp roberto $
|
||||||
** Type definitions for Lua objects
|
** Type definitions for Lua objects
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -250,8 +250,8 @@ void *luaO_openspaceaux (lua_State *L, size_t n);
|
|||||||
int luaO_equalObj (const TObject *t1, const TObject *t2);
|
int luaO_equalObj (const TObject *t1, const TObject *t2);
|
||||||
int luaO_str2d (const char *s, lua_Number *result);
|
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_pushvfstring (lua_State *L, const char *fmt, va_list argp);
|
||||||
const char *luaO_pushstr (lua_State *L, const char *fmt, ...);
|
const char *luaO_pushfstring (lua_State *L, const char *fmt, ...);
|
||||||
void luaO_chunkid (char *out, const char *source, int len);
|
void luaO_chunkid (char *out, const char *source, int len);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 1.182 2002/05/13 13:09:00 roberto Exp roberto $
|
** $Id: lparser.c,v 1.183 2002/05/14 17:52:22 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -70,7 +70,7 @@ static void lookahead (LexState *ls) {
|
|||||||
|
|
||||||
static void error_expected (LexState *ls, int token) {
|
static void error_expected (LexState *ls, int token) {
|
||||||
luaX_syntaxerror(ls,
|
luaX_syntaxerror(ls,
|
||||||
luaO_pushstr(ls->L, "`%s' expected", luaX_token2str(ls, token)));
|
luaO_pushfstring(ls->L, "`%s' expected", luaX_token2str(ls, token)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ static void check_match (LexState *ls, int what, int who, int where) {
|
|||||||
if (where == ls->linenumber)
|
if (where == ls->linenumber)
|
||||||
error_expected(ls, what);
|
error_expected(ls, what);
|
||||||
else {
|
else {
|
||||||
luaX_syntaxerror(ls, luaO_pushstr(ls->L,
|
luaX_syntaxerror(ls, luaO_pushfstring(ls->L,
|
||||||
"`%s' expected (to close `%s' at line %d)",
|
"`%s' expected (to close `%s' at line %d)",
|
||||||
luaX_token2str(ls, what), luaX_token2str(ls, who), where));
|
luaX_token2str(ls, what), luaX_token2str(ls, who), where));
|
||||||
}
|
}
|
||||||
|
|||||||
18
lua.h
18
lua.h
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lua.h,v 1.131 2002/05/06 19:05:10 roberto Exp roberto $
|
** $Id: lua.h,v 1.132 2002/05/07 17:36:56 roberto Exp roberto $
|
||||||
** Lua - An Extensible Extension Language
|
** Lua - An Extensible Extension Language
|
||||||
** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
** Tecgraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil
|
||||||
** e-mail: info@lua.org
|
** e-mail: info@lua.org
|
||||||
** www: http://www.lua.org
|
** www: http://www.lua.org
|
||||||
** See Copyright Notice at the end of this file
|
** See Copyright Notice at the end of this file
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#define LUA_VERSION "Lua 5.0 (alpha)"
|
#define LUA_VERSION "Lua 5.0 (alpha)"
|
||||||
#define LUA_COPYRIGHT "Copyright (C) 1994-2002 TeCGraf, PUC-Rio"
|
#define LUA_COPYRIGHT "Copyright (C) 1994-2002 Tecgraf, PUC-Rio"
|
||||||
#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
|
#define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo"
|
||||||
|
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ LUA_API int lua_lessthan (lua_State *L, int index1, int index2);
|
|||||||
|
|
||||||
LUA_API lua_Number lua_tonumber (lua_State *L, int index);
|
LUA_API lua_Number lua_tonumber (lua_State *L, int index);
|
||||||
LUA_API int lua_toboolean (lua_State *L, int index);
|
LUA_API int lua_toboolean (lua_State *L, int index);
|
||||||
LUA_API const char *lua_tostring (lua_State *L, int index);
|
LUA_API const char *lua_tostring (lua_State *L, int index);
|
||||||
LUA_API size_t lua_strlen (lua_State *L, int index);
|
LUA_API size_t lua_strlen (lua_State *L, int index);
|
||||||
LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index);
|
LUA_API lua_CFunction lua_tocfunction (lua_State *L, int index);
|
||||||
LUA_API void *lua_touserdata (lua_State *L, int index);
|
LUA_API void *lua_touserdata (lua_State *L, int index);
|
||||||
@@ -144,7 +144,9 @@ LUA_API void lua_pushnil (lua_State *L);
|
|||||||
LUA_API void lua_pushnumber (lua_State *L, lua_Number n);
|
LUA_API void lua_pushnumber (lua_State *L, lua_Number n);
|
||||||
LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len);
|
LUA_API void lua_pushlstring (lua_State *L, const char *s, size_t len);
|
||||||
LUA_API void lua_pushstring (lua_State *L, const char *s);
|
LUA_API void lua_pushstring (lua_State *L, const char *s);
|
||||||
LUA_API void lua_vpushstr (lua_State *L, const char *fmt, va_list argp);
|
LUA_API const char *lua_pushvfstring (lua_State *L, const char *fmt,
|
||||||
|
va_list argp);
|
||||||
|
LUA_API const char *lua_pushfstring (lua_State *L, const char *fmt, ...);
|
||||||
LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
|
LUA_API void lua_pushcclosure (lua_State *L, lua_CFunction fn, int n);
|
||||||
LUA_API void lua_pushboolean (lua_State *L, int b);
|
LUA_API void lua_pushboolean (lua_State *L, int b);
|
||||||
LUA_API void lua_pushudataval (lua_State *L, void *p);
|
LUA_API void lua_pushudataval (lua_State *L, void *p);
|
||||||
@@ -319,7 +321,7 @@ LUA_API int lua_pushupvalues (lua_State *L);
|
|||||||
|
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Copyright (C) 1994-2001 TeCGraf, PUC-Rio. All rights reserved.
|
* Copyright (C) 1994-2001 Tecgraf, PUC-Rio. All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, without written agreement and without license
|
* Permission is hereby granted, without written agreement and without license
|
||||||
* or royalty fees, to use, copy, modify, and distribute this software and its
|
* or royalty fees, to use, copy, modify, and distribute this software and its
|
||||||
@@ -341,14 +343,14 @@ LUA_API int lua_pushupvalues (lua_State *L);
|
|||||||
* to, the implied warranties of merchantability and fitness for a particular
|
* to, the implied warranties of merchantability and fitness for a particular
|
||||||
* purpose. The software provided hereunder is on an "as is" basis, and the
|
* purpose. The software provided hereunder is on an "as is" basis, and the
|
||||||
* authors have no obligation to provide maintenance, support, updates,
|
* authors have no obligation to provide maintenance, support, updates,
|
||||||
* enhancements, or modifications. In no event shall TeCGraf, PUC-Rio, or the
|
* enhancements, or modifications. In no event shall Tecgraf, PUC-Rio, or the
|
||||||
* authors be held liable to any party for direct, indirect, special,
|
* authors be held liable to any party for direct, indirect, special,
|
||||||
* incidental, or consequential damages arising out of the use of this software
|
* incidental, or consequential damages arising out of the use of this software
|
||||||
* and its documentation.
|
* and its documentation.
|
||||||
*
|
*
|
||||||
* The Lua language and this implementation have been entirely designed and
|
* The Lua language and this implementation have been entirely designed and
|
||||||
* written by Waldemar Celes Filho, Roberto Ierusalimschy and
|
* written by Waldemar Celes Filho, Roberto Ierusalimschy and
|
||||||
* Luiz Henrique de Figueiredo at TeCGraf, PUC-Rio.
|
* Luiz Henrique de Figueiredo at Tecgraf, PUC-Rio.
|
||||||
*
|
*
|
||||||
* This implementation contains no third-party code.
|
* This implementation contains no third-party code.
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user