about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:21:49 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-04-15 18:21:49 +0000
commit640a840d2e94f0fc245ef8632050c37af23c6b94 (patch)
treebc0835572657666fe6d27cb73ea8a716e683925a /Src
parent04a89199d02a3ee6c4b3d89a6c782bdb0a4f1bc8 (diff)
downloadzsh-640a840d2e94f0fc245ef8632050c37af23c6b94.tar.gz
zsh-640a840d2e94f0fc245ef8632050c37af23c6b94.tar.xz
zsh-640a840d2e94f0fc245ef8632050c37af23c6b94.zip
zsh-3.1.5-pws-13 zsh-3.1.5-pws-13
Diffstat (limited to 'Src')
-rw-r--r--Src/Zle/zle_hist.c7
-rw-r--r--Src/Zle/zle_misc.c3
-rw-r--r--Src/Zle/zle_tricky.c59
-rw-r--r--Src/Zle/zle_vi.c2
-rw-r--r--Src/init.c2
-rw-r--r--Src/params.c2
-rw-r--r--Src/parse.c10
-rw-r--r--Src/subst.c5
-rw-r--r--Src/utils.c7
9 files changed, 73 insertions, 24 deletions
diff --git a/Src/Zle/zle_hist.c b/Src/Zle/zle_hist.c
index 2def5f03a..0064d4ef0 100644
--- a/Src/Zle/zle_hist.c
+++ b/Src/Zle/zle_hist.c
@@ -498,6 +498,7 @@ zle_goto_hist(int ev)
     histline = ev;
     setline(t);
     setlastline();
+    clearlist = 1;
     return 1;
 }
 
@@ -515,6 +516,7 @@ pushline(void)
     stackcs = cs;
     *line = '\0';
     ll = cs = 0;
+    clearlist = 1;
 }
 
 /**/
@@ -537,9 +539,9 @@ pushlineoredit(void)
 	cs += ics;
     }
     pushline();
-    if (!isfirstln) {
+    if (!isfirstln)
 	errflag = done = 1;
-    }
+    clearlist = 1;
 }
 
 /**/
@@ -571,6 +573,7 @@ getline(void)
 	memcpy((char *)line + cs, s, cc);
 	cs += cc;
 	free(s);
+	clearlist = 1;
     }
 }
 
diff --git a/Src/Zle/zle_misc.c b/Src/Zle/zle_misc.c
index cf9aac435..e7f1744d5 100644
--- a/Src/Zle/zle_misc.c
+++ b/Src/Zle/zle_misc.c
@@ -135,6 +135,7 @@ killbuffer(void)
 {
     cs = 0;
     forekill(ll, 0);
+    clearlist = 1;
 }
 
 /**/
@@ -157,6 +158,7 @@ backwardkillline(void)
 		cs--, i++;
     }
     forekill(i, 1);
+    clearlist = 1;
 }
 
 /**/
@@ -288,6 +290,7 @@ killline(void)
 		cs++, i++;
     }
     backkill(i, 0);
+    clearlist = 1;
 }
 
 /**/
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index 62c39fdc9..c303fd97d 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -1322,18 +1322,17 @@ get_comp_string(void)
 	 * as being in math.                                              */
 	if (inwhat != IN_MATH) {
 	    int i = 0;
-	    char *nb = (iident(*s) ? s : s + 1), *ne = NULL;
+	    char *nnb = (iident(*s) ? s : s + 1), *nb = NULL, *ne = NULL;
 
 	    for (tt = s; ++tt < s + cs - wb;)
 		if (*tt == Inbrack) {
 		    i++;
+		    nb = nnb;
 		    ne = tt;
 		} else if (i && *tt == Outbrack)
 		    i--;
-		else if (!iident(*tt)) {
-		    nb = tt + 1;
-		    ne = NULL;
-		}
+		else if (!iident(*tt))
+		    nnb = tt + 1;
 	    if (i) {
 		inwhat = IN_MATH;
 		insubscr = 1;
@@ -1347,12 +1346,35 @@ get_comp_string(void)
 	    }
 	}
 	if (inwhat == IN_MATH) {
-	    /* In mathematical expression, we complete parameter names (even *
-	     * if they don't have a `$' in front of them).  So we have to    *
-	     * find that name.                                               */
-	    for (we = cs; iident(line[we]); we++);
-	    for (wb = cs; --wb >= 0 && iident(line[wb]););
-	    wb++;
+	    if (compfunc) {
+		int lev;
+		char *p;
+
+		for (wb = cs - 1, lev = 0; wb > 0; wb--)
+		    if (line[wb] == ']' || line[wb] == ')')
+			lev++;
+		    else if (line[wb] == '[') {
+			if (!lev--)
+			    break;
+		    } else if (line[wb] == '(') {
+			if (!lev && line[wb - 1] == '(')
+			    break;
+			if (lev)
+			    lev--;
+		    }
+		wb++;
+		p = (char *) line + wb;
+		if (wb && (*p == '[' || *p == '(') &&
+		    !skipparens(*p, (*p == '[' ? ']' : ')'), &p))
+			we = p - (char *) line;
+	    } else {
+		/* In mathematical expression, we complete parameter names  *
+		 * (even if they don't have a `$' in front of them).  So we *
+		 * have to find that name.                                  */
+		for (we = cs; iident(line[we]); we++);
+		for (wb = cs; --wb >= 0 && iident(line[wb]););
+		wb++;
+	    }
 	    zsfree(s);
 	    s = zalloc(we - wb + 1);
 	    strncpy(s, (char *) line + wb, we - wb);
@@ -5032,6 +5054,7 @@ static void
 docompletion(char *s, int lst, int incmd)
 {
     HEAPALLOC {
+	char *opm;
 	LinkNode n;
 
 	pushheap();
@@ -5045,7 +5068,7 @@ docompletion(char *s, int lst, int incmd)
 		   ((isset(AUTOLIST) && !isset(BASHAUTOLIST)) ? 
 		    (isset(LISTAMBIGUOUS) ? 3 : 2) : 0) : 1);
 	zsfree(comppatmatch);
-	comppatmatch = ztrdup(useglob ? "yes" : "");
+	opm = comppatmatch = ztrdup(useglob ? "yes" : "");
 	zsfree(compforcelist);
 	compforcelist = ztrdup("");
 	haspattern = 0;
@@ -5057,7 +5080,7 @@ docompletion(char *s, int lst, int incmd)
 	    clearlist = 1;
 	    goto compend;
 	}
-	if (comppatmatch && *comppatmatch)
+	if (comppatmatch && *comppatmatch && comppatmatch != opm)
 	    haspattern = 1;
 	if (!useline && uselist)
 	    /* All this and the guy only wants to see the list, sigh. */
@@ -5240,14 +5263,20 @@ callcompfunc(char *s, char *fn)
 	zsfree(compprefix);
 	zsfree(compsuffix);
 	if (unset(COMPLETEINWORD)) {
-	    tmp = quotename(s, NULL, NULL, NULL);
+	    if (inwhat == IN_MATH)
+		tmp = s;
+	    else
+		tmp = quotename(s, NULL, NULL, NULL);
 	    untokenize(tmp);
 	    compprefix = ztrdup(tmp);
 	    compsuffix = ztrdup("");
 	} else {
 	    char *ss = s + offs, sav;
 	    
-	    tmp = quotename(s, &ss, NULL, NULL);
+	    if (inwhat == IN_MATH)
+		tmp = s;
+	    else
+		tmp = quotename(s, &ss, NULL, NULL);
 	    sav = *ss;
 	    *ss = '\0';
 	    untokenize(tmp);
diff --git a/Src/Zle/zle_vi.c b/Src/Zle/zle_vi.c
index 2e4fb4a32..5b1548e25 100644
--- a/Src/Zle/zle_vi.c
+++ b/Src/Zle/zle_vi.c
@@ -535,6 +535,7 @@ viopenlinebelow(void)
     spaceinline(1);
     line[cs++] = '\n';
     startvitext(1);
+    clearlist = 1;
 }
 
 /**/
@@ -545,6 +546,7 @@ viopenlineabove(void)
     spaceinline(1);
     line[cs] = '\n';
     startvitext(1);
+    clearlist = 1;
 }
 
 /**/
diff --git a/Src/init.c b/Src/init.c
index ab955b26a..f3576aadd 100644
--- a/Src/init.c
+++ b/Src/init.c
@@ -743,7 +743,7 @@ run_init_scripts(void)
 	    char *s = getsparam("ENV");
 	    if (islogin)
 		sourcehome(".profile");
-	    noerrs = 1;
+	    noerrs = 2;
 	    if (s && !parsestr(s)) {
 		singsub(&s);
 		noerrs = 0;
diff --git a/Src/params.c b/Src/params.c
index eb50c0b7e..7ae6a75ec 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -413,7 +413,7 @@ createparamtable(void)
 
     argvparam = (Param) paramtab->getnode(paramtab, "*");
 
-    noerrs = 1;
+    noerrs = 2;
 
     HEAPALLOC {
 	/* Add the standard non-special parameters which have to    *
diff --git a/Src/parse.c b/Src/parse.c
index eb8398b1a..043aa0f0d 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -955,9 +955,17 @@ par_simple(Cmd c)
 	    nocorrect = 1;
 	else if (tok == ENVSTRING) {
 	    struct varasg *v = (struct varasg *)make_varnode();
+	    char *p;
 
 	    v->type = PM_SCALAR;
-	    equalsplit(v->name = tokstr, &v->str);
+	    v->name = tokstr;
+	    for (p = tokstr; *p && *p != Inbrack && *p != '='; p++);
+	    if (*p == Inbrack && !skipparens(Inbrack, Outbrack, &p) &&
+		*p == '=') {
+		*p = '\0';
+		v->str = p + 1;
+	    } else
+		equalsplit(tokstr, &v->str);
 	    addlinknode(c->vars, v);
 	    isnull = 0;
 	} else if (tok == ENVARRAY) {
diff --git a/Src/subst.c b/Src/subst.c
index 42e8e36d4..651179b72 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -941,6 +941,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	} else if ((*s == '#' || *s == Pound) &&
 		   (iident(s[1])
 		    || s[1] == '*' || s[1] == Star || s[1] == '@'
+		    || s[1] == '-' || (s[1] == ':' && s[2] == '-')
 		    || (isstring(s[1]) && (s[2] == Inbrace || s[2] == Inpar))))
 	    getlen = 1 + whichlen, s++;
 	else if (*s == '~' || *s == Tilde) {
@@ -976,7 +977,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	skipparens(*s, *s == Inpar ? Outpar : Outbrace, &s);
 	sav = *s;
 	*s = 0;
-	if (multsub(&val, (((quoted || aspar) && !nojoin) ? NULL : &aval),
+	if (multsub(&val, ((!aspar && (!quoted || nojoin)) ? &aval : NULL),
 		    &isarr, NULL) &&
 	    quoted) {
 	    isarr = -1;
@@ -1272,7 +1273,7 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 	case '-':
 	    if (vunset) {
 		val = dupstring(s);
-		multsub(&val, &aval, &isarr, NULL);
+		multsub(&val, NULL, &isarr, NULL);
 		copied = 1;
 	    }
 	    break;
diff --git a/Src/utils.c b/Src/utils.c
index d010df4e0..3f8177271 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -52,8 +52,11 @@ char *scriptname;
 void
 zerr(const char *fmt, const char *str, int num)
 {
-    if (errflag || noerrs)
+    if (errflag || noerrs) {
+	if (noerrs < 2)
+	    errflag = 1;
 	return;
+    }
     errflag = 1;
     trashzle();
     /*
@@ -1306,7 +1309,7 @@ spckword(char **s, int hist, int cmd, int ask)
 		return;
 	    guess = dupstring(guess);
 	    ne = noerrs;
-	    noerrs = 1;
+	    noerrs = 2;
 	    singsub(&guess);
 	    noerrs = ne;
 	    if (!guess)