From 56b874a43e00d0d0823dfd8552b22aba33e95942 Mon Sep 17 00:00:00 2001 From: Bart Schaefer Date: Mon, 13 Aug 2001 17:46:55 +0000 Subject: Merge typeset fixes and tests from dev trunk. --- Src/builtin.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'Src/builtin.c') 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); -- cgit 1.4.1