From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1665 invoked from network); 19 Feb 1999 08:59:25 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 19 Feb 1999 08:59:25 -0000 Received: (qmail 1492 invoked by alias); 19 Feb 1999 08:58:48 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5422 Received: (qmail 1485 invoked from network); 19 Feb 1999 08:58:46 -0000 Date: Fri, 19 Feb 1999 09:58:02 +0100 (MET) Message-Id: <199902190858.JAA09439@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: Peter Stephenson's message of Thu, 18 Feb 1999 18:17:26 +0100 Subject: Re: PATCH: 3.1.5-pws-8: setting duplicate elements of assoc array Peter Stephenson wrote: > While doing this, I discovered two other bugs which I haven't fixed: > > 1) > % __foo() { local list; list=(a b); complist -y '$list' -k list; } > % defcomp __foo foo > % foo ^D > The problem was (of course) that the code used the array returned by get*param() directly without copying it. > I don't know if it's supposed to work when list is about to go out of > scope, and there's an easy workaround `-y "($list)"' (provided $list > doesn't have spaces or commas --- which it actually does in the case I was > trying, so I seem to be stuck), but it shouldn't print what it did. I think we should make it work, and it's simple. > 2) > % print ${foo%% > ^ cursor here after space, hit tab, gives > % print ${foo%% BUG: inbrace == '{' in paramsubst() > BUG: inbrace == '{' in paramsubst() > % print ${foo%% I forgot to tokenize the '{' and '}'. This makes me think that the ctokenize() function should be joined with tokenize() even more, giving tokenize() an extra argument. But I'm reluctant to change every call to tokenize()... I also changed the test in getreal() so that the string returned by prefork() is not used if it is empty (which was the case in such situations). This is an incompatible change but previously the `${foo%% ' disappeared and one got normal completion for an empty prefix. Now the string typed so far is kept and completion is tried with it as a prefix. Bye Sven --- os/Zle/zle_tricky.c Thu Feb 18 15:57:34 1999 +++ Src/Zle/zle_tricky.c Fri Feb 19 09:40:22 1999 @@ -4559,7 +4559,8 @@ addlinknode(l, dupstring(str)); prefork(l, 0); noerrs = ne; - if (!errflag && nonempty(l)) + if (!errflag && nonempty(l) && + ((char *) peekfirst(l)) && ((char *) peekfirst(l))[0]) return dupstring(peekfirst(l)); errflag = 0; @@ -4991,11 +4991,13 @@ if (*p == '\\') bslash = 1; else { - if (*p == '$' || *p == '=') { + if (*p == '$' || *p == '=' || *p == '{' || *p == '}') { if (bslash) p[-1] = Bnull; else - *p = (*p == '$' ? String : Equals); + *p = (*p == '$' ? String : + (*p == '=' ? Equals : + (*p == '{' ? Inbrace : Outbrace))); } bslash = 0; } @@ -6484,15 +6486,17 @@ } else { /* Otherwise it should be a parameter name. */ char **arr = NULL, *val; - if (!(arr = getaparam(nam)) && !(arr = gethparam(nam)) && - (val = getsparam(nam))) { + + if ((arr = getaparam(nam)) || (arr = gethparam(nam))) + return (incompfunc ? arrdup(arr) : arr); + + if ((val = getsparam(nam))) { arr = (char **)ncalloc(2*sizeof(char *)); arr[0] = val; arr[1] = NULL; } return arr; } - } /* This is strcmp with ignoring backslashes. */ -- Sven Wischnowsky wischnow@informatik.hu-berlin.de