rebol/r3 — pull request #55 by hostilefork (2012-12-30 14:13:13+00:00)
Title: add SET-ENV, tweaks to host api for environment string handling

This might seem a bit of a non-sequitur. Like *"why would Fork care about `SET-ENV`?"*

I don't. It got in my way doing a larger const-correctness-on-string-literals sweep. Andreas just advised I break it out separately for discussion.

While my const-correcting was mostly just a const here, a const there, no big deal (besides touching 60+ files)...I actually had to rewrite the environment functions a bit to finish it. But set environment hadn't been used yet, so I couldn't exactly test my changes without fleshing things out. And as I delved, I discovered *inconvenient truths* about what a disaster the POSIX environment APIs have been:

http://stackoverflow.com/a/5876818/211160

http://julipedia.meroh.net/2004/10/portability-unsetenvfoo-vs-putenvfoo.html

This is one of those (not-as-few-as-people-think) cases where Win32 is "less wrong". So rather than copy POSIX I switched to copying Win32.

Is it "the" answer? Should the rest of the host API use Win32 API conventions for strings and buffers, or something new?

Err...my impression is that a unified philosophy about the host API has not been hammered out. So figuring out who-owns-what-buffer and who-should-free-what is something that needs formalism and documentation. It is tough to abstract abstractions intelligently, and my impression is that the initial open-sourcing of "host-kit" was an attempt to start precisely that discussion.

It's also my impression that people weren't interested in discussing "host-kit" without an open source story for the Rebol core. Nowadays I think incentive for a real review might be there, and I'm game.

But this is not meant to be that review or any kind of consistency check. This is simply meant to unblock the const correctness checkin, without trying to slipstream it in with more uniform-looking changes to 60+ files. And it adds `SET-ENV`.

Tested on Debian Wheezy 64-bit and MinGW on WinXP. *Note that POSIX environment keys are case-sensitive and Windows is not.*