From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: fixes for math environments
Date: Thu, 11 Mar 1999 16:42:59 +0100 (MET) [thread overview]
Message-ID: <199903111542.QAA01649@beta.informatik.hu-berlin.de> (raw)
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
reply other threads:[~1999-03-11 15:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=199903111542.QAA01649@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).