On Mon, Aug 06, 2007 at 03:55:40PM +0200, Enrico Forestieri wrote:

> On Mon, Aug 06, 2007 at 09:24:53AM +0200, Jean-Marc Lasgouttes wrote:
> 
> > Enrico Forestieri <[EMAIL PROTECTED]> writes:
> > 
> > > Recent versions of the cygwin dll have an internal function for
> > > syncing the Windows environment. The attached patch uses this
> > > function, leading to much simplified code.
> > >
> > > JMarc, Ok to also apply it to branch?
> > 
> > Yes. 
> 
> Done. I also avoided translating to native format the TEMP variable
> as this is already done by the cygwin dll for some variables (eg. PATH)
> and I verified that this is also the case for TEMP.

Well... after having my coffee, I realized that I was still using too
much code, so I committed the attached.

There's no need to check whether the TEMP var is already set, it suffices
using false as the third parameter to setenv for not having it replaced
when it is already set.

-- 
Enrico
Index: src/support/os_cygwin.cpp
===================================================================
--- src/support/os_cygwin.cpp   (revision 19333)
+++ src/support/os_cygwin.cpp   (working copy)
@@ -148,18 +148,7 @@ void os::init(int, char *[])
        // Make sure that the TEMP variable is set
        // and sync the Windows environment.
 
-       char **envp = environ;
-       string var;
-       bool temp_seen = false;
-
-       while (envp && *envp && !temp_seen) {
-               split(*envp++, var, '=');
-               if (var == "TEMP")
-                       temp_seen = true;
-       }
-       if (!temp_seen)
-               ::setenv("TEMP", "/tmp", true);
-
+       setenv("TEMP", "/tmp", false);
        cygwin_internal(CW_SYNC_WINENV);
 }
 

Reply via email to