[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: native Win32 guile 1.7.0

From: Kevin Ryde
Subject: Re: native Win32 guile 1.7.0
Date: Thu, 12 Jun 2003 09:54:05 +1000
User-agent: Gnus/5.090019 (Oort Gnus v0.19) Emacs/21.2 (gnu/linux)

stefan <address@hidden> writes:
> I just added a check for unsetenv() in the configure script and used it in
> posix.c appropiately for mingw32 hosts.  Which means that a
> putenv("name="); would remove the environment variable 'name'.

I guess this means it's not possible to use putenv("name=") to set
name to an empty string.  I'm pretty sure it's valid to do so on other

On wine, which might not be the same as a real mingw, setting "name= "
and then changing that space to a \0 does the trick.  Bit nasty to go
changing putenvs strings like that, but unless there's a setenv or
some function hiding then there might be no choice.  Eg, (untested),

      /* If str is "FOO=", ie. attempting to set an empty string, then we
         need to see if it's been successful.  On MINGW, "FOO=" means remove
         FOO from the environment.  As a workaround, we set "FOO= ", ie. a
         space, and then modify the string returned by getenv.  It's not
         enough just to modify the string we set, because MINGW putenv
         copies it.  */
      if (ptr[SCM_STRING_LENGTH(str)-1] == '=')
          SCM name = scm_substring (str, SCM_MAKINUM (0),
                                    SCM_MAKINUM (SCM_STRING_LENGTH (str) - 1));
          if (getenv (SCM_STRING_CHARS (name)) == NULL)
              char  *alt = scm_malloc (SCM_STRING_LENGTH (str) + 2);
              memcpy (alt, SCM_STRING_CHARS (str), SCM_STRING_LENGTH(str));
              alt[SCM_STRING_LENGTH(str)] = ' ';
              alt[SCM_STRING_LENGTH(str)+1] = '\0';
              rv = putenv (alt);
              if (rv < 0)
              free (ptr);   /* don't need the old string we gave to putenv */
              alt = getenv (SCM_STRING_CHARS (name));
              alt[SCM_STRING_LENGTH(str)] = '\0';

reply via email to

[Prev in Thread] Current Thread [Next in Thread]