template for 'mkstemp' is configurable (via LUA_TMPNAMTEMPLATE)

This commit is contained in:
Roberto Ierusalimschy 2014-04-29 14:05:13 -03:00
parent 68616c6669
commit a0d4f0fc8a
1 changed files with 8 additions and 2 deletions

View File

@ -1,5 +1,5 @@
/* /*
** $Id: loslib.c,v 1.44 2014/03/12 20:57:40 roberto Exp roberto $ ** $Id: loslib.c,v 1.45 2014/03/20 19:18:54 roberto Exp roberto $
** Standard Operating System library ** Standard Operating System library
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -59,9 +59,15 @@
#if defined(LUA_USE_POSIX) /* { */ #if defined(LUA_USE_POSIX) /* { */
#include <unistd.h> #include <unistd.h>
#define LUA_TMPNAMBUFSIZE 32 #define LUA_TMPNAMBUFSIZE 32
#if !defined(LUA_TMPNAMTEMPLATE)
#define LUA_TMPNAMTEMPLATE "/tmp/lua_XXXXXX"
#endif
#define lua_tmpnam(b,e) { \ #define lua_tmpnam(b,e) { \
strcpy(b, "/tmp/lua_XXXXXX"); \ strcpy(b, LUA_TMPNAMTEMPLATE); \
e = mkstemp(b); \ e = mkstemp(b); \
if (e != -1) close(e); \ if (e != -1) close(e); \
e = (e == -1); } e = (e == -1); }