diff --git a/lbaselib.c b/lbaselib.c index e47f9e5c..3a2aea18 100644 --- a/lbaselib.c +++ b/lbaselib.c @@ -1,5 +1,5 @@ /* -** $Id: lbaselib.c,v 1.16 2000/10/31 13:10:24 roberto Exp roberto $ +** $Id: lbaselib.c,v 1.17 2000/11/06 13:45:18 roberto Exp roberto $ ** Basic library ** See Copyright Notice in lua.h */ @@ -38,7 +38,7 @@ static int luaB__ERRORMESSAGE (lua_State *L) { lua_getglobal(L, LUA_ALERT); if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ lua_Debug ar; - lua_pushstring(L, "error: "); + lua_pushliteral(L, "error: "); lua_pushvalue(L, 1); if (lua_getstack(L, 1, &ar)) { lua_getinfo(L, "Sl", &ar); @@ -49,7 +49,7 @@ static int luaB__ERRORMESSAGE (lua_State *L) { lua_concat(L, 2); } } - lua_pushstring(L, "\n"); + lua_pushliteral(L, "\n"); lua_concat(L, 3); lua_rawcall(L, 1, 0); } @@ -327,7 +327,7 @@ static int luaB_tostring (lua_State *L) { sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1)); break; case LUA_TNIL: - lua_pushstring(L, "nil"); + lua_pushliteral(L, "nil"); return 1; default: luaL_argerror(L, 1, "value expected"); @@ -397,7 +397,7 @@ static int luaB_tinsert (lua_State *L) { pos = n+1; else pos = luaL_check_int(L, 2); /* 2nd argument is the position */ - lua_pushstring(L, "n"); + lua_pushliteral(L, "n"); lua_pushnumber(L, n+1); lua_rawset(L, 1); /* t.n = n+1 */ for (; n>=pos; n--) { @@ -421,7 +421,7 @@ static int luaB_tremove (lua_State *L) { lua_rawgeti(L, 1, pos+1); lua_rawseti(L, 1, pos); /* a[pos] = a[pos+1] */ } - lua_pushstring(L, "n"); + lua_pushliteral(L, "n"); lua_pushnumber(L, n-1); lua_rawset(L, 1); /* t.n = n-1 */ lua_pushnil(L); @@ -644,7 +644,7 @@ static const struct luaL_reg base_funcs[] = { LUALIB_API void lua_baselibopen (lua_State *L) { luaL_openl(L, base_funcs); - lua_pushstring(L, LUA_VERSION); + lua_pushliteral(L, LUA_VERSION); lua_setglobal(L, "_VERSION"); deprecated_funcs(L); } diff --git a/ldblib.c b/ldblib.c index 4704017c..6898a3f9 100644 --- a/ldblib.c +++ b/ldblib.c @@ -1,5 +1,5 @@ /* -** $Id: ldblib.c,v 1.30 2000/11/14 18:46:20 roberto Exp $ +** $Id: ldblib.c,v 1.30 2000/11/23 13:47:39 roberto Exp roberto $ ** Interface from Lua to its debug API ** See Copyright Notice in lua.h */ @@ -71,7 +71,7 @@ static int getinfo (lua_State *L) { settabss(L, "namewhat", ar.namewhat); break; case 'f': - lua_pushstring(L, "func"); + lua_pushliteral(L, "func"); lua_pushvalue(L, -3); lua_settable(L, -3); break; diff --git a/ldo.c b/ldo.c index 01485165..eb6fd46e 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 1.110 2000/11/24 17:39:56 roberto Exp roberto $ +** $Id: ldo.c,v 1.111 2000/12/28 12:55:41 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -274,7 +274,7 @@ static int parse_file (lua_State *L, const char *filename) { f = freopen(filename, "rb", f); /* set binary mode */ if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ } - lua_pushstring(L, "@"); + lua_pushliteral(L, "@"); lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); lua_concat(L, 2); filename = lua_tostring(L, -1); /* filename = '@'..filename */ diff --git a/liolib.c b/liolib.c index 354dc849..2828cb5b 100644 --- a/liolib.c +++ b/liolib.c @@ -1,5 +1,5 @@ /* -** $Id: liolib.c,v 1.95 2000/12/22 16:57:13 roberto Exp roberto $ +** $Id: liolib.c,v 1.96 2000/12/22 17:32:28 roberto Exp roberto $ ** Standard I/O (and system) library ** See Copyright Notice in lua.h */ @@ -327,7 +327,7 @@ static int io_read (lua_State *L) { if (firstarg > lastarg) { /* no arguments? */ lua_settop(L, 0); /* erase upvalue and other eventual garbage */ firstarg = lastarg = 1; /* correct indices */ - lua_pushstring(L, "*l"); /* push default argument */ + lua_pushliteral(L, "*l"); /* push default argument */ } else /* ensure stack space for all results and for auxlib's buffer */ luaL_checkstack(L, lastarg-firstarg+1+LUA_MINSTACK, "too many arguments"); diff --git a/lstrlib.c b/lstrlib.c index 5db499dd..9a8823a6 100644 --- a/lstrlib.c +++ b/lstrlib.c @@ -1,5 +1,5 @@ /* -** $Id: lstrlib.c,v 1.59 2000/12/04 14:43:06 roberto Exp roberto $ +** $Id: lstrlib.c,v 1.60 2000/12/18 13:41:41 roberto Exp roberto $ ** Standard library for string operations and pattern-matching ** See Copyright Notice in lua.h */ @@ -43,7 +43,7 @@ static int str_sub (lua_State *L) { if (end > (sint32)l) end = l; if (start <= end) lua_pushlstring(L, s+start-1, end-start+1); - else lua_pushstring(L, ""); + else lua_pushliteral(L, ""); return 1; } diff --git a/lua.c b/lua.c index 47d69ecc..5b8732a4 100644 --- a/lua.c +++ b/lua.c @@ -1,5 +1,5 @@ /* -** $Id: lua.c,v 1.54 2000/10/17 13:36:24 roberto Exp roberto $ +** $Id: lua.c,v 1.55 2000/10/20 16:36:32 roberto Exp roberto $ ** Lua stand-alone interpreter ** See Copyright Notice in lua.h */ @@ -137,7 +137,7 @@ static void getargs (char *argv[]) { lua_settable(L, -3); } /* arg.n = maximum index in table `arg' */ - lua_pushstring(L, "n"); + lua_pushliteral(L, "n"); lua_pushnumber(L, i-1); lua_settable(L, -3); } diff --git a/lua.h b/lua.h index 57fb20a2..9279aa2e 100644 --- a/lua.h +++ b/lua.h @@ -1,5 +1,5 @@ /* -** $Id: lua.h,v 1.80 2000/12/04 18:33:40 roberto Exp roberto $ +** $Id: lua.h,v 1.81 2000/12/22 16:58:41 roberto Exp roberto $ ** Lua - An Extensible Extension Language ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil ** e-mail: lua@tecgraf.puc-rio.br @@ -22,7 +22,7 @@ #endif -#define LUA_VERSION "Lua 4.1(work)" +#define LUA_VERSION "Lua 4.1 (work)" #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" @@ -210,6 +210,8 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size); #define lua_getregistry(L) lua_getref(L, LUA_REFREGISTRY) +#define lua_pushliteral(L, s) lua_pushlstring(L, "" s, (sizeof(s))-1) + #endif