about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/clone.c2
-rw-r--r--Src/Modules/mapfile.c3
-rw-r--r--Src/Modules/parameter.c2
-rw-r--r--Src/Zle/complist.c15
-rw-r--r--Src/Zle/zle_tricky.c77
-rw-r--r--Src/exec.c6
-rw-r--r--Src/subst.c2
7 files changed, 84 insertions, 23 deletions
diff --git a/Src/Modules/clone.c b/Src/Modules/clone.c
index e2cfea8d9..d9dd6c316 100644
--- a/Src/Modules/clone.c
+++ b/Src/Modules/clone.c
@@ -61,7 +61,7 @@ bin_clone(char *nam, char **args, char *ops, int func)
 	    zwarnnam(nam, "failed to create new session: %e", NULL, errno);
 #endif
 #ifdef TIOCNOTTY
-	    if (ioctl(SHTTY, TIOCNOTTY))
+	    if (ioctl(SHTTY, TIOCNOTTY, 0))
 		zwarnnam(nam, "%e", NULL, errno);
 	    setpgrp(0L, mypid);
 #endif
diff --git a/Src/Modules/mapfile.c b/Src/Modules/mapfile.c
index 41cae80b8..31265c0de 100644
--- a/Src/Modules/mapfile.c
+++ b/Src/Modules/mapfile.c
@@ -143,6 +143,9 @@ setpmmapfile(Param pm, char *value)
 	 */
 	ftruncate(fd, len);
 	memcpy(mmptr, value, len);
+#ifndef MS_SYNC
+#define MS_SYNC 0
+#endif
 	msync(mmptr, len, MS_SYNC);
 	/*
 	 * Then we need to truncate again, since mmap() always maps complete
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index 908a05ce9..10f61c0a5 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -91,6 +91,8 @@ paramtypestr(Param pm)
 	}
 	DPUTS(!val, "BUG: type not handled in parameter");
 	val = dupstring(val);
+	if (pm->level)
+	    val = dyncat(val, "-local");
 	if (f & PM_LEFT)
 	    val = dyncat(val, "-left");
 	if (f & PM_RIGHT_B)
diff --git a/Src/Zle/complist.c b/Src/Zle/complist.c
index 4bf3fec0e..9fe5f37cb 100644
--- a/Src/Zle/complist.c
+++ b/Src/Zle/complist.c
@@ -159,17 +159,15 @@ getcoldef(Listcols c, char *s)
 	n = ++s;
 	while (*s && *s != '=')
 	    s++;
-	if (!*s )
+	if (!*s)
 	    return s;
 	*s++ = '\0';
 	p = getcolval(s);
-	if (*n) {
-	    ec = (Extcol) zhalloc(sizeof(*ec));
-	    ec->ext = n;
-	    ec->col = s;
-	    ec->next = c->exts;
-	    c->exts = ec;
-	}
+	ec = (Extcol) zhalloc(sizeof(*ec));
+	ec->ext = n;
+	ec->col = s;
+	ec->next = c->exts;
+	c->exts = ec;
 	if (*p)
 	    *p++ = '\0';
 	return p;
@@ -460,6 +458,7 @@ complistmatches(Hookdef dummy, Chdata dat)
 	}
     }
     /* Now print the matches. */
+    last_col = COL_NO - 1;
     g = amatches;
     while (g) {
 	char **pp = g->ylist;
diff --git a/Src/Zle/zle_tricky.c b/Src/Zle/zle_tricky.c
index b678a5cad..9c7a19d87 100644
--- a/Src/Zle/zle_tricky.c
+++ b/Src/Zle/zle_tricky.c
@@ -565,8 +565,9 @@ acceptlast(void)
 	cs = minfo.pos + minfo.len + minfo.insc;
 	iremovesuffix(' ', 1);
 	l = cs;
-	cs = minfo.pos + minfo.len - (*(minfo.cur))->qisl;
-	foredel(l - cs);
+	cs = minfo.pos + minfo.len + minfo.insc - (*(minfo.cur))->qisl;
+	if (cs < l)
+	    foredel(l - cs);
 	inststrlen(" ", 1, 1);
 	if (parpre)
 	    inststr(parpre);
@@ -801,11 +802,12 @@ check_param(char *s, int set, int test)
 		parq = eparq = 0;
 
 	    /* Save the prefix. */
-	    sav = *b;
-	    *b = '\0';
-	    untokenize(parpre = ztrdup(s));
-	    *b = sav;
-
+	    if (incompfunc) {
+		sav = *b;
+		*b = '\0';
+		untokenize(parpre = ztrdup(s));
+		*b = sav;
+	    }
 	    /* And adjust wb, we, and offs again. */
 	    offs -= b - s;
 	    wb = cs - offs;
@@ -3527,7 +3529,9 @@ add_match_data(int alt, char *str, Cline line,
 		p->next = qsl;
 	}
     }
-    /* And the same for the prefix. */
+    /* The prefix is handled differently because the completion code
+     * is much more eager to insert the -P prefix than it is to insert
+     * the -S suffix. */
     if (qipre)
 	palen = (qipl = strlen(qipre));
     if (ipre)
@@ -3537,7 +3541,49 @@ add_match_data(int alt, char *str, Cline line,
     if (ppre)
 	palen += (ppl = strlen(ppre));
 
-    if (palen) {
+    if (pl) {
+	if (ppl) {
+	    Cline lp, p = bld_parts(ppre, ppl, ppl, &lp);
+
+	    if (lp->prefix && !(line->flags & (CLF_SUF | CLF_MID))) {
+		lp->prefix->next = line->prefix;
+		line->prefix = lp->prefix;
+		lp->prefix = NULL;
+
+		free_cline(lp);
+
+		if (p != lp) {
+		    Cline q;
+
+		    for (q = p; q->next != lp; q = q->next);
+
+		    q->next = line;
+		    line = p;
+		}
+	    } else {
+		lp->next = line;
+		line = p;
+	    }
+	}
+	if (pl) {
+	    Cline lp, p = bld_parts(pre, pl, pl, &lp);
+
+	    lp->next = line;
+	    line = p;
+	}
+	if (ipl) {
+	    Cline lp, p = bld_parts(ipre, ipl, ipl, &lp);
+
+	    lp->next = line;
+	    line = p;
+	}
+	if (qipl) {
+	    Cline lp, p = bld_parts(qipre, qipl, qipl, &lp);
+
+	    lp->next = line;
+	    line = p;
+	}
+    } else if (palen) {
 	char *apre = (char *) zhalloc(palen);
 	Cline p, lp;
 
@@ -4434,7 +4480,10 @@ docompletion(char *s, int lst, int incmd)
 		minfo.cur = NULL;
 		minfo.asked = 0;
 		do_single(m->matches[0]);
-		invalidatelist();
+		if (compforcelist && *compforcelist && uselist)
+		    showinglist = -2;
+		else
+		    invalidatelist();
 	    }
 	} else {
 	    invalidatelist();
@@ -4561,8 +4610,11 @@ callcompfunc(char *s, char *fn)
 		kset |= CP_PARAMETER;
 		if (!clwpos) {
 		    clwpos = 1;
+		    clwnum = 2;
 		    zsfree(clwords[1]);
 		    clwords[1] = ztrdup(s);
+		    zsfree(clwords[2]);
+		    clwords[2] = NULL;
 		}
 		aadd = 1;
 		break;
@@ -6697,8 +6749,9 @@ invalidatelist(void)
 	listmatches();
     if (validlist)
 	freematches();
-    lastambig = menucmp = menuacc = validlist = showinglist =
-	fromcomp = listshown = 0;
+    lastambig = menucmp = menuacc = validlist = showinglist = fromcomp = 0;
+    if (listshown < 0)
+	listshown = 0;
     minfo.cur = NULL;
     minfo.asked = 0;
     compwidget = NULL;
diff --git a/Src/exec.c b/Src/exec.c
index dc281675f..eab846540 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2922,7 +2922,7 @@ doshfunc(char *name, List list, LinkList doshargs, int flags, int noreturnval)
 
 	tab = pparams;
 	oldscriptname = scriptname;
-	scriptname = name;
+	scriptname = dupstring(name);
 	oldzoptind = zoptind;
 	zoptind = 1;
 
@@ -3145,6 +3145,7 @@ cancd2(char *s)
 {
     struct stat buf;
     char *us, *us2 = NULL;
+    int ret;
 
     /*
      * If CHASEDOTS and CHASELINKS are not set, we want to rationalize the
@@ -3159,9 +3160,10 @@ cancd2(char *s)
 	fixdir(us2 = us);
     } else
 	us = unmeta(s);
-    return !(access(us, X_OK) || stat(us, &buf) || !S_ISDIR(buf.st_mode));
+    ret = !(access(us, X_OK) || stat(us, &buf) || !S_ISDIR(buf.st_mode));
     if (us2)
 	free(us2);
+    return ret;
 }
 
 /**/
diff --git a/Src/subst.c b/Src/subst.c
index 18d815404..2a25d3e4b 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -1031,6 +1031,8 @@ paramsubst(LinkList l, LinkNode n, char **str, int qt, int ssub)
 		case PM_HASHED:  val = "association"; break;
 		}
 		val = dupstring(val);
+		if (v->pm->level)
+		    val = dyncat(val, "-local");
 		if (f & PM_LEFT)
 		    val = dyncat(val, "-left");
 		if (f & PM_RIGHT_B)