On Sun, Nov 09, 2008, Jeff Johnson wrote:
> - jbj: lua: bind mkdtemp(3) in lposix.c
> - jbj: macros: add %{mkdtemp:...} primitive (consistent leading whitespace too).
> [...]
> Index: lua/local/lposix.c
> ============================================================================
> $ cvs diff -u -r1.10 -r1.11 lposix.c
> --- lua/local/lposix.c 27 Oct 2008 23:57:34 -0000 1.10
> +++ lua/local/lposix.c 9 Nov 2008 16:12:36 -0000 1.11
> @@ -538,6 +538,24 @@
> return pushresult(L, mkdir(path, 0777), path);
> }
>
> +static int Pmkdtemp(lua_State *L) /** mkdtemp(template) */
> + /*@globals fileSystem @*/
> + /*@modifies L, fileSystem @*/
> +{
> + const char *template = luaL_checkstring(L, 1);
> + const char *path;
> + char buf[MYBUFSIZ];
> + (void) strncpy(buf, template, sizeof(buf));
> + buf[sizeof(buf)-1] = '\0';
> + if ((path = mkdtemp(buf)) == NULL)
> + return pusherror(L, template);
> + else
> + {
> + lua_pushstring(L, path);
> + return 1;
> + }
> +}
> +
In rpmio/macro.c you are using HAVE_MKDTEMP for portability reasons, but
here in lposix.c you are not using it. This let's lposix.c to break on
some platforms as mkdtemp(3) is a BSD/Linux thing. It for instance is
not available under Solaris...
Ralf S. Engelschall
rse@engelschall.com
www.engelschall.com
Received on Mon Nov 10 21:30:08 2008