Boost logo

Boost :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2005-04-26 08:22:10


On 4/26/05, Martin Wille <mw8329_at_[hidden]> wrote:
> Caleb Epstein wrote:
> > http://tinyurl.com/72sj8
> >
> > This test is failing on numerous platforms, some for the fact that
> > "putenv" takes a non-const char* (Linux, Solaris, perhaps others).
> >
> > Attached is a patch for environment.ipp which changes it to use the
> > setenv function on non-Windows systems. I believe this is a POSIX
> > standard function (via BSD).
> >
> > I think this cleans up the code a bit, removing the raising of
> > getenv/putenv into namespace std, when they are I think clearly
> > non-std functions.
>
> setenv() is a very recent addition to POSIX, IIRC. Older Unix versions
> might not support it.

OK, would you know of a better way to determine which "type" of putenv
is available instead? E.g. is it the one that takes a const char* and
copies, or the one that takes a char* and inserts it into the
environment in-place. Using the wrong semantic will lead to either
memory leak (bad) or undefined behavior (worse).

> POSIX setenv() takes three arguments, your patch passes only two.

Whoops. Lets try that again. See attached. I even compiled and ran
the test programs on Linux (gcc 3.3.5) and Windows (VC 7.1) this time
:-)

> Your patch doesn't check the value returned by setenv() or putenv().

Nor did the original. I'm just trying to get this code working in
order to clear up some of the test failures.

-- 
Caleb Epstein
caleb dot epstein at gmail dot com



Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk