Mail Archives: djgpp-workers/2001/10/02/10:02:56
Tim Van Holder wrote:
> On Tue, 2001-10-02 at 05:39, Charles Sandmann wrote:
> > I don't have a posix standard, so a simple question ...
> >
> > putenv in 2.03 took a const char * argument
> >
> > When it was moved to the posix section in cvs it is no longer const
> > When I passed the const strings "lfn=" in mntent I had to unconst
> > the strings to avoid warnings. Is it against the standard or some
> > other way bad for this to be const in the headers? Just wondering.
>
> Since the POSIX draft standard listed putenv's argument as a non-const
> char*, I changed our implementation to match (and added a note about
> this to wc204.txi).
> I don't really see why it can't be const, but I felt it would be best to
> follow the standard.
Perhaps is related to the fact that not all implementations makes a copy (as
djgpp does) and hence a const could generate problems.
What is supposed to return getenv() according to the standard? is it a char
*?
The djgpp's help clearly states the behavior of putenv and warns about what
other implementations does, but I felt victim of a stupid bug anyways:
void function()
{
char buffer[xx];
strcpy(buffer,...);
putenv(buffer);
}
;-)
Of course it generates really bizarre things with GNU libc (which doesn't
copy the string).
SET
--
Salvador Eduardo Tropea (SET). (Electronics Engineer)
Visit my home page: http://welcome.to/SetSoft or
http://www.geocities.com/SiliconValley/Vista/6552/
Alternative e-mail: set AT computer DOT org set AT ieee DOT org
Address: Curapaligue 2124, Caseros, 3 de Febrero
Buenos Aires, (1678), ARGENTINA Phone: +(5411) 4759 0013
- Raw text -