[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: native Win32 guile 1.7.0
From: |
stefan |
Subject: |
Re: native Win32 guile 1.7.0 |
Date: |
Sat, 14 Jun 2003 07:36:24 +0200 (CEST) |
On Thu, 12 Jun 2003, Kevin Ryde wrote:
> > 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
> systems.
>
> 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)
> SCM_SYSERROR;
> free (ptr); /* don't need the old string we gave to putenv */
> alt = getenv (SCM_STRING_CHARS (name));
> alt[SCM_STRING_LENGTH(str)] = '\0';
> }
> }
I tested this piece of code on my Win95 box and modified it a bit to get
it really working. Then I applied the code CVS. The (putenv) primitive
now behaves equally on GNU/Linux and Win32.
Cheers,
address@hidden
- Re: native Win32 guile 1.7.0, Kevin Ryde, 2003/06/08
- Re: native Win32 guile 1.7.0, Kevin Ryde, 2003/06/11
- Re: native Win32 guile 1.7.0, Kevin Ryde, 2003/06/11
- Re: native Win32 guile 1.7.0,
stefan <=
- Re: native Win32 guile 1.7.0, Marius Vollmer, 2003/06/14
- Re: native Win32 guile 1.7.0, stefan, 2003/06/14
- Re: native Win32 guile 1.7.0, Marius Vollmer, 2003/06/14
- Re: native Win32 guile 1.7.0, stefan, 2003/06/16
- Re: native Win32 guile 1.7.0, Marius Vollmer, 2003/06/18