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 | |
parent | d32793394506cce30e5ae4fb6827bb6a2d170dd1 (diff) | |
download | perl-88f5bc07adcbdcc8427eef58d88a43884ef3f99a.tar.gz |
environ fixup
Message-ID: <434BDA72.4090109@sun.com>
p4raw-id: //depot/perl@25737
-rw-r--r-- | handy.h | 2 | ||||
-rw-r--r-- | hints/solaris_2.sh | 15 | ||||
-rw-r--r-- | perl.c | 9 | ||||
-rw-r--r-- | util.c | 44 |
4 files changed, 57 insertions, 13 deletions
@@ -175,7 +175,7 @@ typedef U64TYPE U64; #endif /* HMB H.Merijn Brand - a placeholder for preparing Configure patches */ -#if defined(HAS_MALLOC_SIZE) && defined(HAS_MALLOC_GOOD_SIZE) && defined(HAS_UNSETENV) +#if defined(HAS_MALLOC_SIZE) && defined(HAS_MALLOC_GOOD_SIZE) /* Not (yet) used at top level, but mention them for metaconfig */ #endif diff --git a/hints/solaris_2.sh b/hints/solaris_2.sh index a322ac0e17..a06d9e802a 100644 --- a/hints/solaris_2.sh +++ b/hints/solaris_2.sh @@ -612,4 +612,19 @@ EOM esac EOCBU +# +# If unsetenv is available, use it in conjunction with PERL_USE_SAFE_PUTENV to +# work around Sun bugid 6333830. Both unsetenv and 6333830 only appear in +# Solaris 10, so we don't need to probe explicitly for an OS version. We have +# to append this test to the end of config.over as it needs to run after +# Configure has probed for unsetenv, and this hints file is processed before +# that has happened. +# +cat >> config.over <<'EOOVER' +if test "$d_unsetenv" = "$define" -a \ + `expr "$ccflags" : '.*-D_PERL_USE_SAFE_PUTENV'` -eq 0; then + ccflags="$ccflags -DPERL_USE_SAFE_PUTENV" +fi +EOOVER + rm -f try.c try.o try a.out @@ -4592,7 +4592,16 @@ S_init_perllib(pTHX) if (!PL_tainting) { #ifndef VMS s = PerlEnv_getenv("PERL5LIB"); +/* + * It isn't possible to delete an environment variable with + * PERL_USE_SAFE_PUTENV set unless setenv() is also available, so in that case + * we treat PERL5LIB as undefined if it has a zero-length value. + */ +#if defined(PERL_USE_SAFE_PUTENV) && ! defined(HAS_UNSETENV) + if (s && *s != '\0') +#else if (s) +#endif incpush(s, TRUE, TRUE, TRUE, FALSE); else incpush(PerlEnv_getenv("PERLLIB"), FALSE, FALSE, TRUE, FALSE); @@ -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 } |