Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: 3.1.5-pws-3: setsparam() and sethparam() bugs



This patch must be applied after my previous sethparam() patch.  It fixes
two problems:

1. setsparam() must unset and recreate a PM_SCALAR when the name refers to
   an existing PM_HASHED, as well as when it refers to an existing PM_ARRAY.
2. sethparam() must unset and recreate anything other than a PM_HASHED, even
   though setaparam() can handle both PM_ARRAY and PM_HASHED.

Index: Src/params.c
===================================================================
--- params.c	1998/12/15 00:40:02	1.15
+++ params.c	1998/12/15 06:01:47
@@ -1480,7 +1480,7 @@
     } else {
 	if (!(v = getvalue(&s, 1)))
 	    createparam(t, PM_SCALAR);
-	else if (PM_TYPE(v->pm->flags) == PM_ARRAY &&
+	else if (PM_TYPE(v->pm->flags) & (PM_ARRAY|PM_HASHED) &&
 		 !(v->pm->flags & PM_SPECIAL) && unset(KSHARRAYS)) {
 	    unsetparam(t);
 	    createparam(t, PM_SCALAR);
@@ -1557,7 +1557,7 @@
     } else {
 	if (!(v = getvalue(&s, 1)))
 	    createparam(t, PM_HASHED);
-	else if (!(PM_TYPE(v->pm->flags) & (PM_ARRAY|PM_HASHED)) &&
+	else if (!(PM_TYPE(v->pm->flags) & PM_HASHED) &&
 		 !(v->pm->flags & PM_SPECIAL)) {
 	    unsetparam(t);
 	    createparam(t, PM_HASHED);

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com



Messages sorted by: Reverse Date, Date, Thread, Author