diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-04 11:31:40 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-10-04 11:31:40 -0300 |
commit | fa2f1ec7bae81d43e6edd1b29ecd610e24ebb301 (patch) | |
tree | 16d2074ff2180ee7c3f049aa80a821480ce7f48b | |
parent | 829befcc4198a98412757ad8bf4f67091564b515 (diff) | |
download | lua-fa2f1ec7bae81d43e6edd1b29ecd610e24ebb301.tar.gz lua-fa2f1ec7bae81d43e6edd1b29ecd610e24ebb301.tar.bz2 lua-fa2f1ec7bae81d43e6edd1b29ecd610e24ebb301.zip |
to avoid `strerror', define itself to something else;
nil has a special, fixed reference
-rw-r--r-- | lauxlib.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -1,20 +1,16 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lauxlib.c,v 1.85 2002/09/05 19:45:42 roberto Exp roberto $ | 2 | ** $Id: lauxlib.c,v 1.86 2002/09/16 19:49:45 roberto Exp roberto $ |
3 | ** Auxiliary functions for building Lua libraries | 3 | ** Auxiliary functions for building Lua libraries |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
6 | 6 | ||
7 | 7 | ||
8 | #include <ctype.h> | 8 | #include <ctype.h> |
9 | #include <errno.h> | ||
9 | #include <stdarg.h> | 10 | #include <stdarg.h> |
10 | #include <stdio.h> | 11 | #include <stdio.h> |
11 | #include <string.h> | 12 | #include <string.h> |
12 | 13 | ||
13 | #ifndef lua_filerror | ||
14 | #include <errno.h> | ||
15 | #define lua_fileerror (strerror(errno)) | ||
16 | #endif | ||
17 | |||
18 | 14 | ||
19 | /* This file uses only the official API of Lua. | 15 | /* This file uses only the official API of Lua. |
20 | ** Any function declared here could be written as an application function. | 16 | ** Any function declared here could be written as an application function. |
@@ -292,6 +288,10 @@ LUALIB_API void luaL_buffinit (lua_State *L, luaL_Buffer *B) { | |||
292 | 288 | ||
293 | LUALIB_API int luaL_ref (lua_State *L, int t) { | 289 | LUALIB_API int luaL_ref (lua_State *L, int t) { |
294 | int ref; | 290 | int ref; |
291 | if (lua_isnil(L, -1)) { | ||
292 | lua_pop(L, 1); /* remove from stack */ | ||
293 | return LUA_REFNIL; /* `nil' has a unique fixed reference */ | ||
294 | } | ||
295 | lua_rawgeti(L, t, 0); /* get first free element */ | 295 | lua_rawgeti(L, t, 0); /* get first free element */ |
296 | ref = (int)lua_tonumber(L, -1); /* ref = t[0] */ | 296 | ref = (int)lua_tonumber(L, -1); /* ref = t[0] */ |
297 | lua_pop(L, 1); /* remove it from stack */ | 297 | lua_pop(L, 1); /* remove it from stack */ |
@@ -347,7 +347,7 @@ static const char *getF (lua_State *L, void *ud, size_t *size) { | |||
347 | 347 | ||
348 | static int errfile (lua_State *L, const char *filename) { | 348 | static int errfile (lua_State *L, const char *filename) { |
349 | if (filename == NULL) filename = "stdin"; | 349 | if (filename == NULL) filename = "stdin"; |
350 | lua_pushfstring(L, "cannot read %s: %s", filename, lua_fileerror); | 350 | lua_pushfstring(L, "cannot read %s: %s", filename, strerror(errno)); |
351 | return LUA_ERRFILE; | 351 | return LUA_ERRFILE; |
352 | } | 352 | } |
353 | 353 | ||