aboutsummaryrefslogtreecommitdiff
path: root/loslib.c
diff options
context:
space:
mode:
Diffstat (limited to 'loslib.c')
-rw-r--r--loslib.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/loslib.c b/loslib.c
index 70d5b1eb..5df75a5c 100644
--- a/loslib.c
+++ b/loslib.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: loslib.c,v 1.26 2009/11/23 18:20:38 roberto Exp roberto $ 2** $Id: loslib.c,v 1.27 2009/11/24 12:05:44 roberto Exp roberto $
3** Standard Operating System library 3** Standard Operating System library
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -20,6 +20,28 @@
20#include "lualib.h" 20#include "lualib.h"
21 21
22 22
23/*
24** By default, Lua uses tmpnam except when POSIX is available, where it
25** uses mkstemp.
26*/
27#if defined(LUA_USE_MKSTEMP)
28#include <unistd.h>
29#define LUA_TMPNAMBUFSIZE 32
30#define lua_tmpnam(b,e) { \
31 strcpy(b, "/tmp/lua_XXXXXX"); \
32 e = mkstemp(b); \
33 if (e != -1) close(e); \
34 e = (e == -1); }
35
36#elif !defined(lua_tmpnam)
37
38#define LUA_TMPNAMBUFSIZE L_tmpnam
39#define lua_tmpnam(b,e) { e = (tmpnam(b) == NULL); }
40
41#endif
42
43
44
23static int os_pushresult (lua_State *L, int i, const char *filename) { 45static int os_pushresult (lua_State *L, int i, const char *filename) {
24 int en = errno; /* calls to Lua API may change this value */ 46 int en = errno; /* calls to Lua API may change this value */
25 if (i) { 47 if (i) {