aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lauxlib.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lauxlib.c b/lauxlib.c
index 3f863602..3f34db03 100644
--- a/lauxlib.c
+++ b/lauxlib.c
@@ -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
293LUALIB_API int luaL_ref (lua_State *L, int t) { 289LUALIB_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
348static int errfile (lua_State *L, const char *filename) { 348static 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