[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Portability issue with `putenv'
From: |
James Youngman |
Subject: |
Re: Portability issue with `putenv' |
Date: |
Tue, 22 Feb 2005 16:20:16 +0000 |
User-agent: |
Mutt/1.3.28i |
On Tue, Feb 22, 2005 at 04:45:42PM +0100, Sam Lauber wrote:
> [ James Youngman wrote: ]
>
> > You're right, I hadn't thought of that. According to the POSIX
> > standard (IEEE Std 1003.1, 2003 Edition),
> >
> > | The 'string' argument should point to a string of the form " name=
> > | value ". The putenv() function shall make the value of the
> > | environment variable 'name' equal to 'value' by altering an
> > | existing variable or creating a new one. In either case, the
> > | string pointed to by 'string' shall become part of the
> > | environment, so altering the string shall change the environment.
>
> According to the DJGPP C Library manual, it seems to say
> things are the other way around. It says that the string
> is _supposed_ to be copied.
Yes, but the DJGPP library intends to be a C library for DOS systems,
and does not intend, as far as I know, to provide a POSIX compilation
environment. Therefore there is no need for it to comply with POSIX
and so it can do whatever it wants (putenv is not part of the standard
C library).
> But if there's at least one C library or compiler that's
> not standards compliant, someone has to cater to them or
> risk that construct being nonportable without anyone
> knowing it, everyone using it, only to break on a platform
> like DJGPP. (I can justify that it's the job of Autoconf
> to track down those things.).
It's an open question as to whether Autoconf should replace an
OS-specific putenv() function just because it doesn't fully comply
with POSIX.
> P.S. Nowadays, I've noticed a lot of free software is
> impolite to DOS systems.
Well, the semantics of environment segments in DOS are baroque. See
http://excession.spiral-arm.org/jay/programs/envset.c for an example
of the full horror of these things.
Regards,
James.