From de6fc75d630b393d8b577ba03353abe527523d0f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 17 Dec 2009 10:26:09 -0200 Subject: several configuration options that do not change often moved out of luaconf.h and into more internal files --- loslib.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'loslib.c') diff --git a/loslib.c b/loslib.c index 70d5b1eb..5df75a5c 100644 --- a/loslib.c +++ b/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.26 2009/11/23 18:20:38 roberto Exp roberto $ +** $Id: loslib.c,v 1.27 2009/11/24 12:05:44 roberto Exp roberto $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -20,6 +20,28 @@ #include "lualib.h" +/* +** By default, Lua uses tmpnam except when POSIX is available, where it +** uses mkstemp. +*/ +#if defined(LUA_USE_MKSTEMP) +#include +#define LUA_TMPNAMBUFSIZE 32 +#define lua_tmpnam(b,e) { \ + strcpy(b, "/tmp/lua_XXXXXX"); \ + e = mkstemp(b); \ + if (e != -1) close(e); \ + e = (e == -1); } + +#elif !defined(lua_tmpnam) + +#define LUA_TMPNAMBUFSIZE L_tmpnam +#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); } + +#endif + + + static int os_pushresult (lua_State *L, int i, const char *filename) { int en = errno; /* calls to Lua API may change this value */ if (i) { -- cgit v1.2.3-55-g6feb