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 /lbaselib.c | |
| parent | 595e449537eb6ff17fa6c58742920a1a609fc5c5 (diff) | |
| download | lua-4ff55457095728b95cc5dcdbab0bca7255bd5387.tar.gz lua-4ff55457095728b95cc5dcdbab0bca7255bd5387.tar.bz2 lua-4ff55457095728b95cc5dcdbab0bca7255bd5387.zip | |
new macro pushliteral
Diffstat (limited to '')
| -rw-r--r-- | lbaselib.c | 14 |
1 files changed, 7 insertions, 7 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 | } |
