summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorAlan Burlison <Alan.Burlison@uk.sun.com>2005-10-11 17:29:54 +0100
committerH.Merijn Brand <h.m.brand@xs4all.nl>2005-10-11 15:15:37 +0000
commit88f5bc07adcbdcc8427eef58d88a43884ef3f99a (patch)
tree9ff4104992b1e0501742f6532393057cfd7be2de /util.c
parentd32793394506cce30e5ae4fb6827bb6a2d170dd1 (diff)
downloadperl-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.c44
1 files changed, 32 insertions, 12 deletions
diff --git a/util.c b/util.c
index ccbb7f9eae..8fa774f189 100644
--- a/util.c
+++ b/util.c
@@ -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
}