On Wed, Jun 05, 2013 at 06:13:50AM -0600, Eric Blake wrote:
> On 06/05/2013 03:10 AM, Colin Watson wrote:
> > I've had multiple reports (https://savannah.nongnu.org/bugs/?36848,
> > https://bugs.gentoo.org/show_bug.cgi?id=244517) telling me that FreeBSD
> > is missing the clearenv function, even though it has setenv.  It would
> > be very helpful if Gnulib could handle this.  Is "environ = NULL;"
> > portable, or does it need something cleverer?
> 
> clearenv() is non-standard (it is a glibc extension); but yes, glibc
> documents that "environ = NULL" is a portable alternative.

Hm, that's not in my libc.info.  Do you just mean the code?

> And yes, it is probably quite easy to write a gnulib module that would
> provide clearenv everywhere, although I fail to see why applications
> need the overhead of a function call when an assignment would do.

I was wary about other C libraries that might assume that the environ
pointer can always be dereferenced; and e.g.
http://hg.dovecot.org/dovecot-2.0/file/74d9f61e224d/src/lib/env-util.c#l56
has some specific portability notes which indicate that "environ = NULL"
isn't an adequate replacement everywhere.  This is the kind of reason I
like to use Gnulib so that it can shield me from this nonsense,
especially if somebody discovers another OS with some newer crazy
requirement. :-)

-- 
Colin Watson                                       [cjwat...@debian.org]

Reply via email to