Subject: Re: bug#19874: 25.0.50; encode-time not working as expected

From: Wolfgang Jenkner <[email-masked]>
Date: Sun, 01 Mar 2015 23:49:29 +0100

On Sun, Mar 01 2015, Paul Eggert wrote:

>> I was simply thinking about something like
>>
>> 	q = environ_tmp;
>> 	for (p = environ; *p; p++, q++)
>> 		*q = strdup(*p);
>> 	environ = environ_tmp;
>
> The behavior of getenv, setenv, etc. are undefined after a program
> modifies environ[0], environ[1], etc.  See POSIX 8.1
> <http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08_01>. So,
> although a POSIX-conforming program can do the above, it can't use
> getenv etc. afterwards.

The parenthetical remark in the getenv RATIONALE section is about what
the *implementation* may do.

    the implementation can at that point reinitialize based on the new
    environment. (This may include copying the environment strings into
    a new array and assigning environ to point to it.)

The code snippet above just illustrates a possible interpretation of the
parenthetical remark above.