about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-05-19 00:31:22 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-05-19 00:31:22 +0000
commit90a1316345c1e347908ec29e0b2865a6f03ad4ab (patch)
treed1d90d247d446dfd1b0b9b39d3685bdf8dc7b19f
parent7a616bd5383f5a0ffc6a46ff5105c37978641e59 (diff)
downloadzsh-90a1316345c1e347908ec29e0b2865a6f03ad4ab.tar.gz
zsh-90a1316345c1e347908ec29e0b2865a6f03ad4ab.tar.xz
zsh-90a1316345c1e347908ec29e0b2865a6f03ad4ab.zip
Fix re-set of integer special params after unset.
-rw-r--r--ChangeLog3
-rw-r--r--Src/params.c27
-rw-r--r--Src/subst.c1
3 files changed, 15 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index cee8cd531..798e3c54f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2001-05-18  Bart Schaefer  <schaefer@zsh.org>
 
+	* 14388: Src/params.c, Src/subst.c: Correctly handle re-set of
+	of integer-typed special parameters such as SHLVL, after unset.
+
 	* 14385: Test/V01zmodload.ztst, Test/ztst.zsh: Fix typo in a
 	comment; print a warning when unable to test zsh/example; make
 	sure the file descriptor for that warning (and others in other
diff --git a/Src/params.c b/Src/params.c
index acbe448a2..28a8f1e85 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -1998,17 +1998,16 @@ setiparam(char *s, zlong val)
     if (!(v = getvalue(&vbuf, &s, 1))) {
 	if ((ss = strchr(s, '[')))
 	    *ss = '\0';
-	pm = createparam(t, ss ? PM_ARRAY : PM_INTEGER);
+	if (!(pm = createparam(t, ss ? PM_ARRAY : PM_INTEGER)))
+	    pm = (Param) paramtab->getnode(paramtab, t);
 	DPUTS(!pm, "BUG: parameter not created");
 	if (ss) {
 	    *ss = '[';
-	    v = getvalue(&vbuf, &t, 1);
-	    DPUTS(!v, "BUG: value not found for new parameter");
 	} else {
-	    pm->u.val = val;
-	    unqueue_signals();
-	    return pm;
+	    pm->ct = outputradix;
 	}
+	v = getvalue(&vbuf, &t, 1);
+	DPUTS(!v, "BUG: value not found for new parameter");
     }
     mnval.type = MN_INTEGER;
     mnval.u.l = val;
@@ -2042,20 +2041,16 @@ setnparam(char *s, mnumber val)
 	    *ss = '\0';
 	pm = createparam(t, ss ? PM_ARRAY :
 			 (val.type & MN_INTEGER) ? PM_INTEGER : PM_FFLOAT);
+	if (!pm)
+	    pm = (Param) paramtab->getnode(paramtab, t);
 	DPUTS(!pm, "BUG: parameter not created");
 	if (ss) {
 	    *ss = '[';
-	    v = getvalue(&vbuf, &t, 1);
-	    DPUTS(!v, "BUG: value not found for new parameter");
-	} else {
-	    if (val.type & MN_INTEGER) {
-		pm->ct = outputradix;
-		pm->u.val = val.u.l;
-	    } else
-		pm->u.dval = val.u.d;
-	    unqueue_signals();
-	    return pm;
+	} else if (val.type & MN_INTEGER) {
+	    pm->ct = outputradix;
 	}
+	v = getvalue(&vbuf, &t, 1);
+	DPUTS(!v, "BUG: value not found for new parameter");
     }
     setnumvalue(v, val);
     unqueue_signals();
diff --git a/Src/subst.c b/Src/subst.c
index 24103b3da..25eda1cee 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1149,6 +1149,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		isarr = 0;
 	    }
 	    pm = createparam(nulstring, isarr ? PM_ARRAY : PM_SCALAR);
+	    DPUTS(!pm, "BUG: parameter not created");
 	    if (isarr)
 		pm->u.arr = aval;
 	    else