[
https://issues.apache.org/jira/browse/STDCXX-646?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12564292#action_12564292
]
Martin Sebor commented on STDCXX-646:
-------------------------------------
I did some searching online and found one other platform where calling
{{putenv("NAME=")}} doesn't set the value of {{NAME}} to the empty string:
[MinGW|http://www.mingw.org/], probably because it uses the Windows
implementation, but gcc for a compiler. There might be others. To play it safe
I think we might want to try to detect this at runtime instead of hardcoding it
specially for MSVC.
What I'm proposing is that when {{rw_putenv()}} is called with an empty
variable (i.e., where the {{VALUE}} part in {{NAME=VALUE}} is empty) the
function should first determine the effect of calling {{putenv("NAME=")}} and
if the call removes {{NAME}} from the environment instead of setting it to ""
{{rw_putenv()}} should do the trick implemented in your patch. This could even
be optimized so as to do this check just the first time, saving the value in a
static local variable for future use.
> [MSVC] rw_putenv() limitations
> ------------------------------
>
> Key: STDCXX-646
> URL: https://issues.apache.org/jira/browse/STDCXX-646
> Project: C++ Standard Library
> Issue Type: Bug
> Components: Test Driver
> Affects Versions: 4.2.0
> Environment: MSVC, ICC/Windows
> Reporter: Farid Zaripov
> Assignee: Farid Zaripov
> Fix For: 4.2.1
>
> Attachments: environ.cpp.diff, stdcxx-646.patch
>
> Time Spent: 6.07h
> Remaining Estimate: 0h
>
> In 0.printf.cpp test the rw_putenv() is used to define variable to null and
> to undefine variable.
> ---------------
> 1. rw_putenv ("NULL="); // define to null (empty string)
> 2. rw_putenv ("UNSET"); // undefine if defined
> ---------------
> But on MSVC putenv() could not define variable to null, so:
> 1. rw_putenv ("NULL="); undefines the NULL variable instead defining it to
> null;
> 2. rw_putenv ("UNSET"); does nothing instead of undefining variable
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.