diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-10 14:58:11 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-01-10 14:58:11 -0200 |
commit | 4ff55457095728b95cc5dcdbab0bca7255bd5387 (patch) | |
tree | 661c6a3b6143aa66f2171811a1c87493abb17fc8 | |
parent | 595e449537eb6ff17fa6c58742920a1a609fc5c5 (diff) | |
download | lua-4ff55457095728b95cc5dcdbab0bca7255bd5387.tar.gz lua-4ff55457095728b95cc5dcdbab0bca7255bd5387.tar.bz2 lua-4ff55457095728b95cc5dcdbab0bca7255bd5387.zip |
new macro pushliteral
-rw-r--r-- | lbaselib.c | 14 | ||||
-rw-r--r-- | ldblib.c | 4 | ||||
-rw-r--r-- | ldo.c | 4 | ||||
-rw-r--r-- | liolib.c | 4 | ||||
-rw-r--r-- | lstrlib.c | 4 | ||||
-rw-r--r-- | lua.c | 4 | ||||
-rw-r--r-- | lua.h | 6 |
7 files changed, 21 insertions, 19 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lbaselib.c,v 1.16 2000/10/31 13:10:24 roberto Exp roberto $ | 2 | ** $Id: lbaselib.c,v 1.17 2000/11/06 13:45:18 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 | */ |
@@ -38,7 +38,7 @@ static int luaB__ERRORMESSAGE (lua_State *L) { | |||
38 | lua_getglobal(L, LUA_ALERT); | 38 | lua_getglobal(L, LUA_ALERT); |
39 | if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ | 39 | if (lua_isfunction(L, -1)) { /* avoid error loop if _ALERT is not defined */ |
40 | lua_Debug ar; | 40 | lua_Debug ar; |
41 | lua_pushstring(L, "error: "); | 41 | lua_pushliteral(L, "error: "); |
42 | lua_pushvalue(L, 1); | 42 | lua_pushvalue(L, 1); |
43 | if (lua_getstack(L, 1, &ar)) { | 43 | if (lua_getstack(L, 1, &ar)) { |
44 | lua_getinfo(L, "Sl", &ar); | 44 | lua_getinfo(L, "Sl", &ar); |
@@ -49,7 +49,7 @@ static int luaB__ERRORMESSAGE (lua_State *L) { | |||
49 | lua_concat(L, 2); | 49 | lua_concat(L, 2); |
50 | } | 50 | } |
51 | } | 51 | } |
52 | lua_pushstring(L, "\n"); | 52 | lua_pushliteral(L, "\n"); |
53 | lua_concat(L, 3); | 53 | lua_concat(L, 3); |
54 | lua_rawcall(L, 1, 0); | 54 | lua_rawcall(L, 1, 0); |
55 | } | 55 | } |
@@ -327,7 +327,7 @@ static int luaB_tostring (lua_State *L) { | |||
327 | sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1)); | 327 | sprintf(buff, "userdata(%d): %p", lua_tag(L, 1), lua_touserdata(L, 1)); |
328 | break; | 328 | break; |
329 | case LUA_TNIL: | 329 | case LUA_TNIL: |
330 | lua_pushstring(L, "nil"); | 330 | lua_pushliteral(L, "nil"); |
331 | return 1; | 331 | return 1; |
332 | default: | 332 | default: |
333 | luaL_argerror(L, 1, "value expected"); | 333 | luaL_argerror(L, 1, "value expected"); |
@@ -397,7 +397,7 @@ static int luaB_tinsert (lua_State *L) { | |||
397 | pos = n+1; | 397 | pos = n+1; |
398 | else | 398 | else |
399 | pos = luaL_check_int(L, 2); /* 2nd argument is the position */ | 399 | pos = luaL_check_int(L, 2); /* 2nd argument is the position */ |
400 | lua_pushstring(L, "n"); | 400 | lua_pushliteral(L, "n"); |
401 | lua_pushnumber(L, n+1); | 401 | lua_pushnumber(L, n+1); |
402 | lua_rawset(L, 1); /* t.n = n+1 */ | 402 | lua_rawset(L, 1); /* t.n = n+1 */ |
403 | for (; n>=pos; n--) { | 403 | for (; n>=pos; n--) { |
@@ -421,7 +421,7 @@ static int luaB_tremove (lua_State *L) { | |||
421 | lua_rawgeti(L, 1, pos+1); | 421 | lua_rawgeti(L, 1, pos+1); |
422 | lua_rawseti(L, 1, pos); /* a[pos] = a[pos+1] */ | 422 | lua_rawseti(L, 1, pos); /* a[pos] = a[pos+1] */ |
423 | } | 423 | } |
424 | lua_pushstring(L, "n"); | 424 | lua_pushliteral(L, "n"); |
425 | lua_pushnumber(L, n-1); | 425 | lua_pushnumber(L, n-1); |
426 | lua_rawset(L, 1); /* t.n = n-1 */ | 426 | lua_rawset(L, 1); /* t.n = n-1 */ |
427 | lua_pushnil(L); | 427 | lua_pushnil(L); |
@@ -644,7 +644,7 @@ static const struct luaL_reg base_funcs[] = { | |||
644 | 644 | ||
645 | LUALIB_API void lua_baselibopen (lua_State *L) { | 645 | LUALIB_API void lua_baselibopen (lua_State *L) { |
646 | luaL_openl(L, base_funcs); | 646 | luaL_openl(L, base_funcs); |
647 | lua_pushstring(L, LUA_VERSION); | 647 | lua_pushliteral(L, LUA_VERSION); |
648 | lua_setglobal(L, "_VERSION"); | 648 | lua_setglobal(L, "_VERSION"); |
649 | deprecated_funcs(L); | 649 | deprecated_funcs(L); |
650 | } | 650 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldblib.c,v 1.30 2000/11/14 18:46:20 roberto Exp $ | 2 | ** $Id: ldblib.c,v 1.30 2000/11/23 13:47:39 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 | */ |
@@ -71,7 +71,7 @@ static int getinfo (lua_State *L) { | |||
71 | settabss(L, "namewhat", ar.namewhat); | 71 | settabss(L, "namewhat", ar.namewhat); |
72 | break; | 72 | break; |
73 | case 'f': | 73 | case 'f': |
74 | lua_pushstring(L, "func"); | 74 | lua_pushliteral(L, "func"); |
75 | lua_pushvalue(L, -3); | 75 | lua_pushvalue(L, -3); |
76 | lua_settable(L, -3); | 76 | lua_settable(L, -3); |
77 | break; | 77 | break; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 1.110 2000/11/24 17:39:56 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 1.111 2000/12/28 12:55:41 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -274,7 +274,7 @@ static int parse_file (lua_State *L, const char *filename) { | |||
274 | f = freopen(filename, "rb", f); /* set binary mode */ | 274 | f = freopen(filename, "rb", f); /* set binary mode */ |
275 | if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ | 275 | if (f == NULL) return LUA_ERRFILE; /* unable to reopen file */ |
276 | } | 276 | } |
277 | lua_pushstring(L, "@"); | 277 | lua_pushliteral(L, "@"); |
278 | lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); | 278 | lua_pushstring(L, (filename == NULL) ? "(stdin)" : filename); |
279 | lua_concat(L, 2); | 279 | lua_concat(L, 2); |
280 | filename = lua_tostring(L, -1); /* filename = '@'..filename */ | 280 | filename = lua_tostring(L, -1); /* filename = '@'..filename */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: liolib.c,v 1.95 2000/12/22 16:57:13 roberto Exp roberto $ | 2 | ** $Id: liolib.c,v 1.96 2000/12/22 17:32:28 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 | */ |
@@ -327,7 +327,7 @@ static int io_read (lua_State *L) { | |||
327 | if (firstarg > lastarg) { /* no arguments? */ | 327 | if (firstarg > lastarg) { /* no arguments? */ |
328 | lua_settop(L, 0); /* erase upvalue and other eventual garbage */ | 328 | lua_settop(L, 0); /* erase upvalue and other eventual garbage */ |
329 | firstarg = lastarg = 1; /* correct indices */ | 329 | firstarg = lastarg = 1; /* correct indices */ |
330 | lua_pushstring(L, "*l"); /* push default argument */ | 330 | lua_pushliteral(L, "*l"); /* push default argument */ |
331 | } | 331 | } |
332 | else /* ensure stack space for all results and for auxlib's buffer */ | 332 | else /* ensure stack space for all results and for auxlib's buffer */ |
333 | luaL_checkstack(L, lastarg-firstarg+1+LUA_MINSTACK, "too many arguments"); | 333 | luaL_checkstack(L, lastarg-firstarg+1+LUA_MINSTACK, "too many arguments"); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstrlib.c,v 1.59 2000/12/04 14:43:06 roberto Exp roberto $ | 2 | ** $Id: lstrlib.c,v 1.60 2000/12/18 13:41:41 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 | */ |
@@ -43,7 +43,7 @@ static int str_sub (lua_State *L) { | |||
43 | if (end > (sint32)l) end = l; | 43 | if (end > (sint32)l) end = l; |
44 | if (start <= end) | 44 | if (start <= end) |
45 | lua_pushlstring(L, s+start-1, end-start+1); | 45 | lua_pushlstring(L, s+start-1, end-start+1); |
46 | else lua_pushstring(L, ""); | 46 | else lua_pushliteral(L, ""); |
47 | return 1; | 47 | return 1; |
48 | } | 48 | } |
49 | 49 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.c,v 1.54 2000/10/17 13:36:24 roberto Exp roberto $ | 2 | ** $Id: lua.c,v 1.55 2000/10/20 16:36:32 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 | */ |
@@ -137,7 +137,7 @@ static void getargs (char *argv[]) { | |||
137 | lua_settable(L, -3); | 137 | lua_settable(L, -3); |
138 | } | 138 | } |
139 | /* arg.n = maximum index in table `arg' */ | 139 | /* arg.n = maximum index in table `arg' */ |
140 | lua_pushstring(L, "n"); | 140 | lua_pushliteral(L, "n"); |
141 | lua_pushnumber(L, i-1); | 141 | lua_pushnumber(L, i-1); |
142 | lua_settable(L, -3); | 142 | lua_settable(L, -3); |
143 | } | 143 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lua.h,v 1.80 2000/12/04 18:33:40 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.81 2000/12/22 16:58:41 roberto Exp roberto $ |
3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil | 4 | ** TeCGraf: Grupo de Tecnologia em Computacao Grafica, PUC-Rio, Brazil |
5 | ** e-mail: lua@tecgraf.puc-rio.br | 5 | ** e-mail: lua@tecgraf.puc-rio.br |
@@ -22,7 +22,7 @@ | |||
22 | #endif | 22 | #endif |
23 | 23 | ||
24 | 24 | ||
25 | #define LUA_VERSION "Lua 4.1(work)" | 25 | #define LUA_VERSION "Lua 4.1 (work)" |
26 | #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" | 26 | #define LUA_COPYRIGHT "Copyright (C) 1994-2000 TeCGraf, PUC-Rio" |
27 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" | 27 | #define LUA_AUTHORS "W. Celes, R. Ierusalimschy & L. H. de Figueiredo" |
28 | 28 | ||
@@ -210,6 +210,8 @@ LUA_API void *lua_newuserdata (lua_State *L, size_t size); | |||
210 | 210 | ||
211 | #define lua_getregistry(L) lua_getref(L, LUA_REFREGISTRY) | 211 | #define lua_getregistry(L) lua_getref(L, LUA_REFREGISTRY) |
212 | 212 | ||
213 | #define lua_pushliteral(L, s) lua_pushlstring(L, "" s, (sizeof(s))-1) | ||
214 | |||
213 | #endif | 215 | #endif |
214 | 216 | ||
215 | 217 | ||