Thread overview
[phobos] getenv, setenv and unsetenv implemented for Windows
Aug 13, 2010
Walter Bright
Aug 13, 2010
David Simcha
Aug 13, 2010
Walter Bright
August 13, 2010
Today, I noticed that the std.process functions setenv() and unsetenv()
only have POSIX implementations.  So I wrote Windows implementations for
them:

http://github.com/kyllingstad/ltk/blob/master/ltk/system.d

You'll also note a new Windows implementation of getEnv() and a new
function allEnv().

Seeing as this is my first foray into Windows API land ever, I thought I'd post it here before incorporating anything into Phobos.  Please comment -- in particular I'm curious about whether it is correct to use the UTF-16 functions.

-Lars

August 13, 2010

Lars Tandle Kyllingstad wrote:
> Today, I noticed that the std.process functions setenv() and unsetenv()
> only have POSIX implementations.  So I wrote Windows implementations for
> them:
>
> http://github.com/kyllingstad/ltk/blob/master/ltk/system.d
>
> You'll also note a new Windows implementation of getEnv() and a new
> function allEnv().
> 

Great!

> Seeing as this is my first foray into Windows API land ever, I thought I'd post it here before incorporating anything into Phobos.  Please comment -- in particular I'm curious about whether it is correct to use the UTF-16 functions.
>
> 

It is correct to use the "A" functions for Win9x, and the "W" functions for all the other Windows versions. To see how to accomplish this, see std\file.d and grep for useWfuncs.
August 13, 2010
Just as a general reference since I've been meaning to ask for awhile and this reminded me, do we really still care about supporting '9x/ME?  The last version in this line was released an entire decade ago and hasn't been supported by Microsoft in 4 years.  Also, according to this link ( http://www.w3counter.com/globalstats.php) none of the '9x/ME versions of Windows even register on the market share meter anymore.  I'm not saying we should go out of our way to cripple '9x/ME support, but I certainly don't think it's worth any serious effort.

On Fri, Aug 13, 2010 at 3:32 PM, Walter Bright <walter at digitalmars.com>wrote:

>
>
> Lars Tandle Kyllingstad wrote:
>
>> Today, I noticed that the std.process functions setenv() and unsetenv()
>> only have POSIX implementations.  So I wrote Windows implementations for
>> them:
>>
>> http://github.com/kyllingstad/ltk/blob/master/ltk/system.d
>>
>> You'll also note a new Windows implementation of getEnv() and a new
>> function allEnv().
>>
>>
>
> Great!
>
>
>  Seeing as this is my first foray into Windows API land ever, I thought
>> I'd post it here before incorporating anything into Phobos.  Please comment -- in particular I'm curious about whether it is correct to use the UTF-16 functions.
>>
>>
>>
>
> It is correct to use the "A" functions for Win9x, and the "W" functions for all the other Windows versions. To see how to accomplish this, see std\file.d and grep for useWfuncs.
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/phobos/attachments/20100813/cc0c9f6f/attachment.html>
August 13, 2010

David Simcha wrote:
> Just as a general reference since I've been meaning to ask for awhile and this reminded me, do we really still care about supporting '9x/ME?  The last version in this line was released an entire decade ago and hasn't been supported by Microsoft in 4 years.  Also, according to this link (http://www.w3counter.com/globalstats.php) none of the '9x/ME versions of Windows even register on the market share meter anymore.  I'm not saying we should go out of our way to cripple '9x/ME support, but I certainly don't think it's worth any serious effort.
>

No, I don't think we really care, but in many cases it's trivial to support it (like in std.file), and so why not?
August 14, 2010
All right, I'll have a look at std.file.  Thanks for the tip!

Also, I'd like to camelCase the functions' names (while keeping deprecated aliases to preserve backwards compatibility for a while). It's not crucial to me, but I think we really should try to keep a consistent style in Phobos, and since these functions have so far been POSIX-only and undocumented I would be surprised if it caused much breakage.  Some suggestions:

  getEnv, setEnv, ...
  getEnvVar, setEnvVar, ...              <-- I'd prefer this
  getEnvVariable, setEnvVariable, ...    <-- ...or this
  getEnvironmentVar, setEnvironmentVar, ...
  getEnvironmentVariable, setEnvironmentVariable, ...
  etc.


-Lars



On Fri, 2010-08-13 at 12:32 -0700, Walter Bright wrote:
> 
> Lars Tandle Kyllingstad wrote:
> > Today, I noticed that the std.process functions setenv() and unsetenv()
> > only have POSIX implementations.  So I wrote Windows implementations for
> > them:
> >
> > http://github.com/kyllingstad/ltk/blob/master/ltk/system.d
> >
> > You'll also note a new Windows implementation of getEnv() and a new
> > function allEnv().
> > 
> 
> Great!
> 
> > Seeing as this is my first foray into Windows API land ever, I thought I'd post it here before incorporating anything into Phobos.  Please comment -- in particular I'm curious about whether it is correct to use the UTF-16 functions.
> >
> > 
> 
> It is correct to use the "A" functions for Win9x, and the "W" functions
> for all the other Windows versions. To see how to accomplish this, see
> std\file.d and grep for useWfuncs.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


August 14, 2010
On Sat, 2010-08-14 at 12:06 +0200, Lars Tandle Kyllingstad wrote:
> Also, I'd like to camelCase the functions' names (while keeping blah blah blah blah


Scratch that, I think I'll go with an AA-like interface instead, as suggested by Sean a few months ago.

-Lars