From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22375 invoked from network); 11 Mar 1999 15:43:40 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 11 Mar 1999 15:43:40 -0000 Received: (qmail 20870 invoked by alias); 11 Mar 1999 15:43:04 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 5759 Received: (qmail 20862 invoked from network); 11 Mar 1999 15:43:01 -0000 Date: Thu, 11 Mar 1999 16:42:59 +0100 (MET) Message-Id: <199903111542.QAA01649@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk Subject: PATCH: fixes for math environments There were a couple of bugs/problems: - completion inside `$((...))' didn't work because the code thought it were in a command substitution - subscripts inside math environments weren't detected - completion inside `foo[...' (without a `$') didn't set `compstate[parameter]' Bye Sven diff -u os/Zle/zle_tricky.c Src/Zle/zle_tricky.c --- os/Zle/zle_tricky.c Thu Mar 11 14:31:02 1999 +++ Src/Zle/zle_tricky.c Thu Mar 11 16:39:33 1999 @@ -1244,16 +1244,20 @@ inpop(); errflag = zleparse = 0; if (parbegin != -1) { - /* We are in command or process substitution */ + /* We are in command or process substitution if we are not in + * a $((...)). */ if (parend >= 0 && !tmp) line = (unsigned char *) dupstring(tmp = (char *)line); linptr = (char *) line + ll + addedx - parbegin + 1; - if (parend >= 0) { - ll -= parend; - line[ll + addedx] = '\0'; + if ((linptr - (char *) line) < 2 || + linptr[-1] != '(' || linptr[-2] != '$') { + if (parend >= 0) { + ll -= parend; + line[ll + addedx] = '\0'; + } + lexrestore(); + goto start; } - lexrestore(); - goto start; } if (inwhat == IN_MATH) @@ -1315,25 +1319,23 @@ * foo[_ wrong (note no $). If we are in a subscript, treat it * * as being in math. */ if (inwhat != IN_MATH) { - int i = 0, hn = 0; - char *nb = (*s == String ? s + 1 : NULL), *ne = NULL; + int i = 0; + char *nb = (iident(*s) ? s : s + 1), *ne = NULL; for (tt = s; ++tt < s + cs - wb;) - if (*tt == String) { - hn = 0; - nb = tt + 1; - } else if (*tt == Inbrack) { + if (*tt == Inbrack) { i++; - if (nb && !hn) { - hn = 1; - ne = tt; - } + ne = tt; } else if (i && *tt == Outbrack) i--; + else if (!iident(*tt)) { + nb = tt + 1; + ne = NULL; + } if (i) { inwhat = IN_MATH; insubscr = 1; - if (hn && nb && ne) { + if (nb < ne) { char sav = *ne; *ne = '\0'; zsfree(varname); @@ -1353,6 +1355,19 @@ s = zalloc(we - wb + 1); strncpy(s, (char *) line + wb, we - wb); s[we - wb] = '\0'; + if (wb > 2 && line[wb - 1] == '[' && iident(line[wb - 2])) { + int i = wb - 3; + unsigned char sav = line[wb - 1]; + + while (i >= 0 && iident(line[i])) + i--; + + line[wb - 1] = '\0'; + zsfree(varname); + varname = ztrdup((char *) line + i + 1); + line[wb - 1] = sav; + insubscr = 1; + } } /* This variable will hold the current word in quoted form. */ qword = ztrdup(s); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de