diff options
author | Alan Burlison <Alan.Burlison@uk.sun.com> | 2005-10-11 17:29:54 +0100 |
---|---|---|
committer | H.Merijn Brand <h.m.brand@xs4all.nl> | 2005-10-11 15:15:37 +0000 |
commit | 88f5bc07adcbdcc8427eef58d88a43884ef3f99a (patch) | |
tree | 9ff4104992b1e0501742f6532393057cfd7be2de /util.c | |
parent | d32793394506cce30e5ae4fb6827bb6a2d170dd1 (diff) | |
download | perl-88f5bc07adcbdcc8427eef58d88a43884ef3f99a.tar.gz |
environ fixup
Message-ID: <434BDA72.4090109@sun.com>
p4raw-id: //depot/perl@25737
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 44 |
1 files changed, 32 insertions, 12 deletions
@@ -1496,19 +1496,39 @@ Perl_my_setenv(pTHX_ const char *nam, const char *val) } else { # endif # if defined(__CYGWIN__) || defined(EPOC) || defined(SYMBIAN) - setenv(nam, val, 1); +# if defined(HAS_UNSETENV) + if (val == NULL) { + (void)unsetenv(nam); + } else { + (void)setenv(nam, val, 1); + } +# else /* ! HAS_UNSETENV */ + (void)setenv(nam, val, 1); +# endif /* HAS_UNSETENV */ # else - char *new_env; - const int nlen = strlen(nam); - int vlen; - if (!val) { - val = ""; - } - vlen = strlen(val); - new_env = (char*)safesysmalloc((nlen + vlen + 2) * sizeof(char)); - /* all that work just for this */ - my_setenv_format(new_env, nam, nlen, val, vlen); - (void)putenv(new_env); +# if defined(HAS_UNSETENV) + if (val == NULL) { + (void)unsetenv(nam); + } else { + int nlen = strlen(nam); + int vlen = strlen(val); + char *new_env = + (char*)safesysmalloc((nlen + vlen + 2) * sizeof(char)); + my_setenv_format(new_env, nam, nlen, val, vlen); + (void)putenv(new_env); + } +# else /* ! HAS_UNSETENV */ + char *new_env; + int nlen = strlen(nam), vlen; + if (!val) { + val = ""; + } + vlen = strlen(val); + new_env = (char*)safesysmalloc((nlen + vlen + 2) * sizeof(char)); + /* all that work just for this */ + my_setenv_format(new_env, nam, nlen, val, vlen); + (void)putenv(new_env); +# endif /* HAS_UNSETENV */ # endif /* __CYGWIN__ */ #ifndef PERL_USE_SAFE_PUTENV } |