nmh-workers
[Top] [All Lists]

Re: Working on the install-mh change questions

2002-11-19 00:24:35
Eric Gillespie <epg(_at_)pretzelnet(_dot_)org> writes:

I just checked Harbison & Steele, and according to them ISO C
does not allow calls to putenv to modify the getenv return
value, and as seen above, nor does POSIX (though the XSI
extension does).  Maybe i'm just not very imaginative at this
late hour, but i don't see another way to implement the
environment without putenv modifying it, so i find it strange
that the two important standards don't allow for it.

Just thought of one, though perhaps not the most obvious.  POSIX
and ISO C *do* mention static buffers; a getenv implementation
can copy from the environment array into its own static buffer,
extending it if necessary (subsequent getenv buffers may
invalidate old ones, i.e. return addresses of newly allocated
buffers).  Then putenv calls wouldn't invalidate the getenv
return value.

--  
Eric Gillespie <*> epg(_at_)pretzelnet(_dot_)org

Build a fire for a man, and he'll be warm for a day.  Set a man on
fire, and he'll be warm for the rest of his life. -Terry Pratchett


<Prev in Thread] Current Thread [Next in Thread>