about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-08-13 17:46:55 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-08-13 17:46:55 +0000
commit56b874a43e00d0d0823dfd8552b22aba33e95942 (patch)
tree05bba146836946e80cf2651f8721f5391c63ee4f /Src/builtin.c
parentc0832b6ffdfb5c62af6f7a41f4a143d6cc61bb3e (diff)
downloadzsh-56b874a43e00d0d0823dfd8552b22aba33e95942.tar.gz
zsh-56b874a43e00d0d0823dfd8552b22aba33e95942.tar.xz
zsh-56b874a43e00d0d0823dfd8552b22aba33e95942.zip
Merge typeset fixes and tests from dev trunk.
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 442c58fd3..65ff7da99 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1586,6 +1586,7 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 	       int on, int off, int roff, char *value, Param altpm)
 {
     int usepm, tc, keeplocal = 0, newspecial = 0;
+    char *subscript;
 
     /*
      * Do we use the existing pm?  Note that this isn't the end of the
@@ -1786,12 +1787,24 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 	    pm->ct = auxlen;
 	else
 	    pm->ct = 0;
-    } else if (strchr(pname, '[')) {
+    } else if ((subscript = strchr(pname, '['))) {
 	if (on & PM_READONLY) {
 	    zerrnam(cname,
 		    "%s: can't create readonly array elements", pname, 0);
 	    return NULL;
-	} else if (PM_TYPE(on) == PM_SCALAR) {
+	} else if (on & PM_LOCAL) {
+	    *subscript = 0;
+	    pm = (Param) (paramtab == realparamtab ?
+			  gethashnode2(paramtab, pname) :
+			  paramtab->getnode(paramtab, pname));
+	    *subscript = '[';
+	    if (!pm || pm->level != locallevel) {
+		zerrnam(cname,
+			"%s: can't create local array elements", pname, 0);
+		return NULL;
+	    }
+	}
+	if (PM_TYPE(on) == PM_SCALAR) {
 	    /*
 	     * This will either complain about bad identifiers, or will set
 	     * a hash element or array slice.  This once worked by accident,
@@ -1801,6 +1814,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 	    if (!(pm = setsparam(pname, ztrdup(value ? value : ""))))
 		return NULL;
 	    value = NULL;
+	    keeplocal = 0;
+	    on = pm->flags;
 	} else {
 	    zerrnam(cname,
 		    "%s: array elements must be scalar", pname, 0);