delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1997/04/11/12:09:28

From: estes AT smarts DOT com (Ken Estes)
Subject: Re: Sorting environment
11 Apr 1997 12:09:28 -0700 :
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <199704111327.JAA29905.cygnus.gnu-win32@just.smarts.com>
Original-To: gnu-win32 AT cygnus DOT com
In-reply-to: <334D1255.7FFA@netcom.com> (message from Jim Balter on Thu, 10
Apr 1997 09: 16:21 -0700)
Original-Sender: owner-gnu-win32 AT cygnus DOT com


<J Q B> wrote: 


>> This parenthetical comment about what these systems "use" is not
>> part of the win32 specification.  If there really is Windows NT and
>> Windows 95 software that depends upon sorting, then that is a bug.
>> Not that that has any bearing on the real world, where practical
>> software must accommodate MS's bugs.

The parenthetical comment is quite important. (remember I posted this
bug several months ago). The problem is the way getenv(), _putenv()
handles unsorted environments.  This will give unexpected results if
there is no sorting performed.


When I used _putenv() to modify an unsorted list of env variables the
same variable remained in the environmental array in different places
with different values.  This caused strange problems where Perl
inherits a different environment then C programs spawned from the same
application.  This is because Perl loads the env array into a hash
table manually.  So Perl will remember the LAST environmental setting
of the variable while getenv() returns the FIRST setting of the
variable.


This is not a question of user coding style or real world compromises.

1) Applications must be able to use OS functions when desired.

2) Duplicate environmental settings should not occur as a result of
   using OS functions


 To ensure that these simple conditions are met the environment must
be sorted or then environment will enter an inconsistent state as a
result of OS interfaces.  This means that the quotation from the
manual is correct:


>   To do so, the application must explicitly create the =X environment
>   variable strings, get them into alphabetical order (because
>   Windows NT and Windows 95 use a sorted environment), and then put
>   them into the environment block specified by

The application MUST get them into alphabetical order.



Ken Estes



-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019