about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPeter Stephenson <pws@users.sourceforge.net>2007-07-31 11:26:54 +0000
committerPeter Stephenson <pws@users.sourceforge.net>2007-07-31 11:26:54 +0000
commit595dd31b636e0bae3a6c2478514b2d2e65e9b5a6 (patch)
treee78771fba180093334c27afe1723959ad0c17f27
parent40b42fc6f66f15b451ea35db2d296524c029982a (diff)
downloadzsh-595dd31b636e0bae3a6c2478514b2d2e65e9b5a6.tar.gz
zsh-595dd31b636e0bae3a6c2478514b2d2e65e9b5a6.tar.xz
zsh-595dd31b636e0bae3a6c2478514b2d2e65e9b5a6.zip
23730: improve preprocessor and regression tests for 23725
-rw-r--r--ChangeLog5
-rw-r--r--Src/exec.c2
-rw-r--r--Src/params.c18
-rw-r--r--Src/system.h4
-rw-r--r--Test/B02typeset.ztst17
5 files changed, 33 insertions, 13 deletions
diff --git a/ChangeLog b/ChangeLog
index 68f103210..95552947c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-07-31  Peter Stephenson  <pws@csr.com>
+
+	* 23730: Src/exec.c, Src/params.c, Src/system.h, B02typeset.ztst:
+	improve preprocessor and regression tests for 23725.
+
 2007-07-30  Peter Stephenson  <p.w.stephenson@ntlworld.com>
 
 	* 23726: Test/B02typeset.ztst: test for adding and removing
diff --git a/Src/exec.c b/Src/exec.c
index baabf1b87..1cfe97373 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -529,7 +529,7 @@ execute(LinkList args, int flags, int defpath)
 	 * for ARGV0: that's OK since we're about to exec or exit
 	 * on failure.
 	 */
-#ifdef HAVE_UNSETENV
+#ifdef USE_SET_UNSET_ENV
 	unsetenv("ARGV0");
 #else
 	delenvvalue(z - 6);
diff --git a/Src/params.c b/Src/params.c
index 080b1fca4..fb79268da 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -610,7 +610,7 @@ void
 createparamtable(void)
 {
     Param ip, pm;
-#if !defined(HAVE_PUTENV) && !defined(HAVE_SETENV)
+#if !defined(HAVE_PUTENV) && !defined(USE_SET_UNSET_ENV)
     char **new_environ;
     int  envsize;
 #endif
@@ -665,7 +665,7 @@ createparamtable(void)
 
     setsparam("LOGNAME", ztrdup((str = getlogin()) && *str ? str : cached_username));
 
-#if !defined(HAVE_PUTENV) && !defined(HAVE_SETENV)
+#if !defined(HAVE_PUTENV) && !defined(USE_SET_UNSET_ENV)
     /* Copy the environment variables we are inheriting to dynamic *
      * memory, so we can do mallocs and frees on it.               */
     envsize = sizeof(char *)*(1 + arrlen(environ));
@@ -3855,7 +3855,7 @@ arrfixenv(char *s, char **t)
 int
 zputenv(char *str)
 {
-#ifdef HAVE_SETENV
+#ifdef USE_SET_UNSET_ENV
     /*
      * If we are using unsetenv() to remove values from the
      * environment, which is the safe thing to do, we
@@ -3906,7 +3906,7 @@ zputenv(char *str)
 }
 
 /**/
-#ifndef HAVE_UNSETENV
+#ifndef USE_SET_UNSET_ENV
 /**/
 static int
 findenv(char *name, int *pos)
@@ -3969,12 +3969,10 @@ void
 addenv(Param pm, char *value)
 {
     char *newenv = 0;
-#ifndef HAVE_UNSETENV
+#ifndef USE_SET_UNSET_ENV
     char *oldenv = 0, *env = 0;
     int pos;
-#endif
 
-#ifndef HAVE_UNSETENV
     /*
      * First check if there is already an environment
      * variable matching string `name'.
@@ -3989,7 +3987,7 @@ addenv(Param pm, char *value)
 	pm->env = NULL;
 	return;
     }
-#ifdef HAVE_UNSETENV
+#ifdef USE_SET_UNSET_ENV
      /*
       * If we are using setenv/unsetenv to manage the environment,
       * we simply store the string we created in pm->env since
@@ -4052,7 +4050,7 @@ mkenvstr(char *name, char *value, int flags)
  * string.                                         */
 
 
-#ifndef HAVE_UNSETENV
+#ifndef USE_SET_UNSET_ENV
 /**/
 void
 delenvvalue(char *x)
@@ -4078,7 +4076,7 @@ delenvvalue(char *x)
 void
 delenv(Param pm)
 {
-#ifdef HAVE_UNSETENV
+#ifdef USE_SET_UNSET_ENV
     unsetenv(pm->node.nam);
     zsfree(pm->env);
 #else
diff --git a/Src/system.h b/Src/system.h
index af66687fa..781a90762 100644
--- a/Src/system.h
+++ b/Src/system.h
@@ -697,8 +697,8 @@ extern char **environ;
  * We always need setenv and unsetenv in pairs, because
  * we don't know how to do memory management on the values set.
  */
-#ifndef HAVE_UNSETENV
-#undef HAVE_SETENV
+#if defined(HAVE_SETENV) && defined(HAVE_UNSETENV)
+# define USE_SET_UNSET_ENV
 #endif
 
 
diff --git a/Test/B02typeset.ztst b/Test/B02typeset.ztst
index 5ba88035b..701048986 100644
--- a/Test/B02typeset.ztst
+++ b/Test/B02typeset.ztst
@@ -381,10 +381,27 @@
  export ENVFOO=bar
  print ENVFOO in environment
  env | grep '^ENVFOO'
+ print Changing ENVFOO
+ ENVFOO="not bar any more"
+ env | grep '^ENVFOO'
  unset ENVFOO
  print ENVFOO no longer in environment
  env | grep '^ENVFOO'
 1:Adding and removing values to and from the environment
 >ENVFOO in environment
 >ENVFOO=bar
+>Changing ENVFOO
+>ENVFOO=not bar any more
 >ENVFOO no longer in environment
+
+ (export FOOENV=BAR
+ env | grep '^FOOENV'
+ print Exec
+ exec $ZTST_testdir/../Src/zsh -c '
+ print Unset
+ unset FOOENV
+ env | grep "^FOOENV"')
+1:Can unset environment variables after exec
+>FOOENV=BAR
+>Exec
+>Unset