This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Bogus putenv?


Ralf Corsepius wrote:
Hi,

newlib's stdlib.h declares
int putenv( const char* );

According to SUSv3, Linux and Solaris, this should be (without const)
int putenv( char* );

FreeBSD, however has the same declaration as newlib (with const).

At least I am in favor of following SUSv3 and to ignore BSD's behaviour,
i.e. I vote for changing newlib's putenv to match with SUSv3.

Ralf



You have to take into account how putenv is implemented. The reason putenv has a non-const parameter for those situations is that those functions use the input strings directly. Modification to the string after the call directly changes the environment. Newlib's implementation does not do this. It makes a copy of the string and passes it to setenv. Modifying the input string does not affect subsequent getenv calls for newlib.


If you are willing to change putenv to work by using the strings directly, I am ok with such a change.

-- Jeff J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]