From a2876b6db3e25ab7c5f7df10806d6f0b45b89514 Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Fri, 24 Mar 2000 12:35:07 +0000 Subject: zsh-workers/10230 --- Src/Zle/comp.h | 15 +++++++-------- Src/Zle/compcore.c | 31 ++++++++++++++++++------------- Src/Zle/complete.c | 17 ++++------------- Src/Zle/compresult.c | 16 ---------------- 4 files changed, 29 insertions(+), 50 deletions(-) (limited to 'Src/Zle') diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index 082fab912..f513d4a5a 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -229,10 +229,9 @@ struct menuinfo { #define CAF_QUOTE 1 #define CAF_NOSORT 2 -#define CAF_ALT 4 -#define CAF_MATCH 8 -#define CAF_UNIQCON 16 -#define CAF_UNIQALL 32 +#define CAF_MATCH 4 +#define CAF_UNIQCON 8 +#define CAF_UNIQALL 16 /* Data for compadd and addmatches() */ @@ -351,12 +350,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_ANMATCHES 21 -#define CP_ANMATCHES (1 << CPN_ANMATCHES) -#define CPN_LISTLINES 22 +#define CPN_LISTLINES 21 #define CP_LISTLINES (1 << CPN_LISTLINES) -#define CPN_QUOTES 23 +#define CPN_QUOTES 22 #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 48189ab31..a7752967c 100644 --- a/Src/Zle/compcore.c +++ b/Src/Zle/compcore.c @@ -307,6 +307,7 @@ 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)) { @@ -1463,7 +1464,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 oisalt = 0, isalt, isexact, doadd, ois = instring, oib = inbackt; + int isexact, doadd, ois = instring, oib = inbackt; Cline lc = NULL, pline = NULL, sline = NULL; Cmatch cm; struct cmlist mst; @@ -1743,7 +1744,6 @@ 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 (!oisalt && (aign || pign)) { + if (aign || pign) { int max = 0; char **ap = argv; @@ -1780,9 +1780,8 @@ addmatches(Cadata dat, char **argv) disp = NULL; } sl = strlen(s); - isalt = oisalt; - if (!isalt && (aign || pign)) { - int il = ppl + sl + psl; + if (aign || pign) { + int il = ppl + sl + psl, addit = 1; if (ppl) memcpy(ibuf, dat->ppre, ppl); @@ -1796,15 +1795,19 @@ addmatches(Cadata dat, char **argv) char **pt = aign; int filell; - for (isalt = 0; !isalt && *pt; pt++) - isalt = ((filell = strlen(*pt)) < il && - !strcmp(*pt, ibuf + il - filell)); + for (; addit && *pt; pt++) + addit = !((filell = strlen(*pt)) < il && + !strcmp(*pt, ibuf + il - filell)); } - if (!isalt && pign) { + if (addit && pign) { Patprog *pt = pign; - for (isalt = 0; !isalt && *pt; pt++) - isalt = pattry(*pt, ibuf); + for (; addit && *pt; pt++) + addit = !pattry(*pt, ibuf); + } + if (!addit) { + compignored++; + continue; } } if (!(dat->aflags & CAF_MATCH)) { @@ -1832,7 +1835,7 @@ addmatches(Cadata dat, char **argv) for (bp = obsl; bp; bp = bp->next) bp->curpos += bsadd; - if ((cm = add_match_data(isalt, ms, lc, dat->ipre, NULL, + if ((cm = add_match_data(0, ms, lc, dat->ipre, NULL, dat->isuf, dat->pre, dat->prpre, dat->ppre, pline, dat->psuf, sline, @@ -2175,6 +2178,8 @@ 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 f625c34cd..c3a09c3dd 100644 --- a/Src/Zle/complete.c +++ b/Src/Zle/complete.c @@ -36,7 +36,8 @@ mod_export zlong compcurrent; /**/ zlong complistmax, - complistlines; + complistlines, + compignored; /**/ mod_export @@ -476,9 +477,6 @@ 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"; @@ -912,9 +910,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 } }; @@ -1025,14 +1023,7 @@ set_compstate(Param pm, HashTable ht) static zlong get_nmatches(Param pm) { - return num_matches(1); -} - -/**/ -static zlong -get_anmatches(Param pm) -{ - return num_matches(0); + return (permmatches(0) ? 0 : nmatches); } /**/ diff --git a/Src/Zle/compresult.c b/Src/Zle/compresult.c index c8aa96f22..0d93b8727 100644 --- a/Src/Zle/compresult.c +++ b/Src/Zle/compresult.c @@ -1102,22 +1102,6 @@ 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. */ /**/ -- cgit 1.4.1