about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/Modules/zpty.c43
-rw-r--r--Src/Zle/comp.h15
-rw-r--r--Src/Zle/compcore.c31
-rw-r--r--Src/Zle/complete.c17
-rw-r--r--Src/Zle/compresult.c16
-rw-r--r--Src/Zle/computil.c2
-rw-r--r--Src/Zle/zle_refresh.c2
-rw-r--r--Src/text.c14
8 files changed, 77 insertions, 63 deletions
diff --git a/Src/Modules/zpty.c b/Src/Modules/zpty.c
index 3692a5224..63135c31b 100644
--- a/Src/Modules/zpty.c
+++ b/Src/Modules/zpty.c
@@ -165,7 +165,7 @@ get_pty(int *master, int *slave)
 
 #else /* ! __osf__ */
 
-#if defined(__SVR4) || defined(sinix)
+#if __SVR4
 
 #include <sys/stropts.h>
 
@@ -174,12 +174,11 @@ get_pty(int *master, int *slave)
 {
     int mfd, sfd;
     char *name;
-    int ret;
 
     if ((mfd = open("/dev/ptmx", O_RDWR)) < 0)
 	return 1;
 
-    if (grantpt(mfd) || unlockpt(mfd) || !(name = ptsname(mfd))) {
+    if (!(name = ptsname(mfd)) || grantpt(mfd) || unlockpt(mfd)) {
 	close(mfd);
 	return 1;
     }
@@ -187,31 +186,31 @@ get_pty(int *master, int *slave)
 	close(mfd);
 	return 1;
     }
-    if ((ret = ioctl(sfd, I_FIND, "ptem")) != 1)
-	if (ret == -1 || ioctl(sfd, I_PUSH, "ptem") == -1) {
-	    close(mfd);
-	    close(sfd);
-	    return 1;
-	}
-    if ((ret = ioctl(sfd, I_FIND, "ldterm")) != 1)
-	if (ret == -1 || ioctl(sfd, I_PUSH, "ldterm") == -1) {
-	    close(mfd);
-	    close(sfd);
-	    return 1;
-	}
-    if ((ret = ioctl(sfd, I_FIND, "ttcompat")) != 1)
-	if (ret == -1 || ioctl(sfd, I_PUSH, "ttcompat") == -1) {
-	    close(mfd);
-	    close(sfd);
-	    return 1;
-	}
+   if ((ret = ioctl(sfd, I_FIND, "ptem")) != 1)
+      if (ret == -1 || ioctl(sfd, I_PUSH, "ptem") == -1) {
+          close(mfd);
+          close(sfd);
+          return 1;
+      }
+   if ((ret = ioctl(sfd, I_FIND, "ldterm")) != 1)
+      if (ret == -1 || ioctl(sfd, I_PUSH, "ldterm") == -1) {
+          close(mfd);
+          close(sfd);
+          return 1;
+      }
+   if ((ret = ioctl(sfd, I_FIND, "ttcompat")) != 1)
+      if (ret == -1 || ioctl(sfd, I_PUSH, "ttcompat") == -1) {
+          close(mfd);
+          close(sfd);
+          return 1;
+      }
     *master = mfd;
     *slave = sfd;
 
     return 0;
 }
 
-#else /* ! (defined(__SVR4) || defined(sinix))  */
+#else /* ! (defined(__SVR4) || defined(sinix)) */
 
 static int
 get_pty(int *master, int *slave)
diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h
index f513d4a5a..082fab912 100644
--- a/Src/Zle/comp.h
+++ b/Src/Zle/comp.h
@@ -229,9 +229,10 @@ struct menuinfo {
 
 #define CAF_QUOTE    1
 #define CAF_NOSORT   2
-#define CAF_MATCH    4
-#define CAF_UNIQCON  8
-#define CAF_UNIQALL 16
+#define CAF_ALT      4
+#define CAF_MATCH    8
+#define CAF_UNIQCON 16
+#define CAF_UNIQALL 32
 
 /* Data for compadd and addmatches() */
 
@@ -350,12 +351,12 @@ typedef void (*CLPrintFunc)(Cmgroup, Cmatch *, int, int, int, int,
 #define CP_OLDINS      (1 << CPN_OLDINS)
 #define CPN_VARED      20
 #define CP_VARED       (1 << CPN_VARED)
-#define CPN_LISTLINES  21
+#define CPN_ANMATCHES  21
+#define CP_ANMATCHES   (1 << CPN_ANMATCHES)
+#define CPN_LISTLINES  22
 #define CP_LISTLINES   (1 << CPN_LISTLINES)
-#define CPN_QUOTES     22
+#define CPN_QUOTES     23
 #define CP_QUOTES      (1 << CPN_QUOTES)
-#define CPN_IGNORED    23
-#define CP_IGNORED     (1 << CPN_IGNORED)
 
 #define CP_KEYPARAMS   24
 #define CP_ALLKEYS     ((unsigned int) 0xffffff)
diff --git a/Src/Zle/compcore.c b/Src/Zle/compcore.c
index a7752967c..48189ab31 100644
--- a/Src/Zle/compcore.c
+++ b/Src/Zle/compcore.c
@@ -307,7 +307,6 @@ do_completion(Hookdef dummy, Compldat dat)
     hasmatched = hasunmatched = 0;
     minmlen = 1000000;
     maxmlen = -1;
-    compignored = 0;
 
     /* Make sure we have the completion list and compctl. */
     if (makecomplist(s, incmd, lst)) {
@@ -1464,7 +1463,7 @@ addmatches(Cadata dat, char **argv)
     int lpl, lsl, pl, sl, bcp = 0, bcs = 0, bpadd = 0, bsadd = 0;
     int ppl = 0, psl = 0;
     int llpl = 0, llsl = 0, nm = mnum, gflags = 0, ohp = haspattern;
-    int isexact, doadd, ois = instring, oib = inbackt;
+    int oisalt = 0, isalt, isexact, doadd, ois = instring, oib = inbackt;
     Cline lc = NULL, pline = NULL, sline = NULL;
     Cmatch cm;
     struct cmlist mst;
@@ -1744,6 +1743,7 @@ addmatches(Cadata dat, char **argv)
 	    } else
 		dat->prpre = dupstring(dat->prpre);
 	    /* Select the set of matches. */
+	    oisalt = (dat->aflags & CAF_ALT);
 
 	    if (dat->remf) {
 		dat->remf = dupstring(dat->remf);
@@ -1761,7 +1761,7 @@ addmatches(Cadata dat, char **argv)
 	/* Walk through the matches given. */
 	obpl = bpl;
 	obsl = bsl;
-	if (aign || pign) {
+	if (!oisalt && (aign || pign)) {
 	    int max = 0;
 	    char **ap = argv;
 
@@ -1780,8 +1780,9 @@ addmatches(Cadata dat, char **argv)
 		    disp = NULL;
 	    }
 	    sl = strlen(s);
-	    if (aign || pign) {
-		int il = ppl + sl + psl, addit = 1;
+	    isalt = oisalt;
+	    if (!isalt && (aign || pign)) {
+		int il = ppl + sl + psl;
 
 		if (ppl)
 		    memcpy(ibuf, dat->ppre, ppl);
@@ -1795,19 +1796,15 @@ addmatches(Cadata dat, char **argv)
 		    char **pt = aign;
 		    int filell;
 
-		    for (; addit && *pt; pt++)
-			addit = !((filell = strlen(*pt)) < il &&
-				  !strcmp(*pt, ibuf + il - filell));
+		    for (isalt = 0; !isalt && *pt; pt++)
+			isalt = ((filell = strlen(*pt)) < il &&
+				 !strcmp(*pt, ibuf + il - filell));
 		}
-		if (addit && pign) {
+		if (!isalt && pign) {
 		    Patprog *pt = pign;
 
-		    for (; addit && *pt; pt++)
-			addit = !pattry(*pt, ibuf);
-		}
-		if (!addit) {
-		    compignored++;
-		    continue;
+		    for (isalt = 0; !isalt && *pt; pt++)
+			isalt = pattry(*pt, ibuf);
 		}
 	    }
 	    if (!(dat->aflags & CAF_MATCH)) {
@@ -1835,7 +1832,7 @@ addmatches(Cadata dat, char **argv)
 		for (bp = obsl; bp; bp = bp->next)
 		    bp->curpos += bsadd;
 
-		if ((cm = add_match_data(0, ms, lc, dat->ipre, NULL,
+		if ((cm = add_match_data(isalt, ms, lc, dat->ipre, NULL,
 					 dat->isuf, dat->pre, dat->prpre,
 					 dat->ppre, pline,
 					 dat->psuf, sline,
@@ -2178,8 +2175,6 @@ add_match_data(int alt, char *str, Cline line,
 
     newmatches = 1;
     mgroup->new = 1;
-    if (alt)
-	compignored++;
 
     if (!complastprompt || !*complastprompt)
 	dolastprompt = 0;
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index c3a09c3dd..f625c34cd 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -36,8 +36,7 @@
 mod_export zlong compcurrent;
 /**/
 zlong complistmax,
-      complistlines,
-      compignored;
+      complistlines;
 
 /**/
 mod_export
@@ -477,6 +476,9 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 		sp = &(dat.prpre);
 		e = "string expected after -%c";
 		break;
+	    case 'a':
+		dat.aflags |= CAF_ALT;
+		break;
 	    case 'M':
 		sp = &m;
 		e = "matching specification expected after -%c";
@@ -910,9 +912,9 @@ static struct compparam compkparams[] = {
     { "old_list", PM_SCALAR, VAL(compoldlist), NULL, NULL },
     { "old_insert", PM_SCALAR, VAL(compoldins), NULL, NULL },
     { "vared", PM_SCALAR, VAL(compvared), NULL, NULL },
+    { "alternate_nmatches", PM_INTEGER | PM_READONLY, NULL, NULL, VAL(get_anmatches) },
     { "list_lines", PM_INTEGER | PM_READONLY, NULL, NULL, VAL(get_listlines) },
     { "all_quotes", PM_SCALAR | PM_READONLY, VAL(compqstack), NULL, NULL },
-    { "ignored", PM_INTEGER | PM_READONLY, VAL(compignored), NULL, NULL },
     { NULL, 0, NULL, NULL, NULL }
 };
 
@@ -1023,7 +1025,14 @@ set_compstate(Param pm, HashTable ht)
 static zlong
 get_nmatches(Param pm)
 {
-    return (permmatches(0) ? 0 : nmatches);
+    return num_matches(1);
+}
+
+/**/
+static zlong
+get_anmatches(Param pm)
+{
+    return num_matches(0);
 }
 
 /**/
diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c
index 0d93b8727..c8aa96f22 100644
--- a/Src/Zle/compresult.c
+++ b/Src/Zle/compresult.c
@@ -1102,6 +1102,22 @@ do_ambig_menu(void)
     minfo.cur = mc;
 }
 
+/* Return the real number of matches. */
+
+/**/
+zlong
+num_matches(int normal)
+{
+    int alt;
+
+    alt = permmatches(0);
+
+    if (normal)
+	return (alt ? 0 : nmatches);
+    else
+	return (alt ? nmatches : 0);
+}
+
 /* Return the number of screen lines needed for the list. */
 
 /**/
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c
index 2b5ece54d..088d89931 100644
--- a/Src/Zle/computil.c
+++ b/Src/Zle/computil.c
@@ -2363,7 +2363,7 @@ bin_comptags(char *nam, char **args, char *ops, int func)
 		    return 1;
 		}
 		s->ptr = q + 1;
-		setsparam(args[2], ztrdup(*v == '-' ? dyncat(args[1], v) : v));
+		setsparam(args[2], ztrdup(v));
 		return 0;
 	    }
 	    return 1;
diff --git a/Src/Zle/zle_refresh.c b/Src/Zle/zle_refresh.c
index b43bfc028..75da73efb 100644
--- a/Src/Zle/zle_refresh.c
+++ b/Src/Zle/zle_refresh.c
@@ -333,7 +333,7 @@ zrefresh(void)
 	tsetcap(TCUNDERLINEEND, 0);
 
         if (!clearflag) {
-            if (tccan(TCCLEAREOD) && isset(ALWAYSLASTPROMPT))
+            if (tccan(TCCLEAREOD))
                 tcout(TCCLEAREOD);
             else
                 cleareol = 1;   /* request: clear to end of line */
diff --git a/Src/text.c b/Src/text.c
index c148423b8..32fcbf35b 100644
--- a/Src/text.c
+++ b/Src/text.c
@@ -122,7 +122,8 @@ getpermtext(Eprog prog, Wordcode c)
     tlim = tbuf + tsiz;
     tindent = 1;
     tjob = 0;
-    gettext2(&s);
+    if (prog->len)
+	gettext2(&s);
     *tptr = '\0';
     untokenize(tbuf);
     return tbuf;
@@ -194,9 +195,6 @@ struct tstack {
 	struct {
 	    int par;
 	} _cond;
-	struct {
-	    Wordcode end;
-	} _subsh;
     } u;
 };
 
@@ -332,10 +330,8 @@ gettext2(Estate state)
 	    if (!s) {
 		taddstr("( ");
 		tindent++;
-		n = tpush(code, 1);
-		n->u._subsh.end = state->pc + WC_SUBSH_SKIP(code);
+		tpush(code, 1);
 	    } else {
-		state->pc = s->u._subsh.end;
 		tindent--;
 		taddstr(" )");
 		stack = 1;
@@ -345,10 +341,8 @@ gettext2(Estate state)
 	    if (!s) {
 		taddstr("{ ");
 		tindent++;
-		n = tpush(code, 1);
-		n->u._subsh.end = state->pc + WC_CURSH_SKIP(code);
+		tpush(code, 1);
 	    } else {
-		state->pc = s->u._subsh.end;
 		tindent--;
 		taddstr(" }");
 		stack = 1;