bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: temp file creation bug in diffutils 2.7


From: Solar Designer
Subject: Re: temp file creation bug in diffutils 2.7
Date: Thu, 4 Jan 2001 13:06:26 +0300
User-agent: Mutt/1.2.5i

> > This is very non-portable, but I don't think this patch was ever
> > meant to be used anywhere other than in GNU/*/Linux distributions.
> 
> ??? Why?

mkstemp(3) is not sufficiently portable for use in GNU software.
...I've just tried to find a system without mkstemp to prove this,
but it turned out that even my HP-UX 10.20 has mkstemp.  The man page
(common with mktemp) doesn't even mention mkstemp in the STANDARDS
CONFORMANCE section, though, and recommends that both mktemp and
mkstemp not be used in "applications where portability is important".

There's a portable implementation of mkstemp (called mkstemps) in
libiberty (included with gcc and binutils), derived from the code in
an older version of glibc.  It may be nice to make a public domain
one, though, to share the same code with non-GPL'ed software.

> By ``non-portable'' did you mean anything besides this snippet?
> 
>   +           asprintf (&tmpname, "%s/sdiff.XXXXXX",
>   +             getenv("TMPDIR") ?: P_tmpdir);
> 
> If this is the only non-portable stuff, then it could be made portable.

Yes, I would write this with xmalloc/sprintf and wouldn't use the ?:
if the code wasn't already non-portable.

-- 
/sd



reply via email to

[Prev in Thread] Current Thread [Next in Thread]