From 083befef2bfe9a93dbf6a6acfe2faed7f743d6ed Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Mon, 19 Jun 2000 10:48:21 +0000 Subject: new match spec characters bBeE, match only word/line not both (11977) --- Src/Zle/comp.h | 1 + Src/Zle/complete.c | 21 +++++++++++++-------- Src/Zle/compmatch.c | 12 +++++++++--- 3 files changed, 23 insertions(+), 11 deletions(-) (limited to 'Src/Zle') diff --git a/Src/Zle/comp.h b/Src/Zle/comp.h index 93e3c68eb..506d85135 100644 --- a/Src/Zle/comp.h +++ b/Src/Zle/comp.h @@ -150,6 +150,7 @@ struct cmatcher { #define CMF_LINE 1 #define CMF_LEFT 2 #define CMF_RIGHT 4 +#define CMF_INTER 8 struct cpattern { Cpattern next; /* next sub-pattern */ diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c index 11f6d24ef..20da967ef 100644 --- a/Src/Zle/complete.c +++ b/Src/Zle/complete.c @@ -183,13 +183,13 @@ parse_cmatcher(char *name, char *s) { Cmatcher ret = NULL, r = NULL, n; Cpattern line, word, left, right; - int fl, ll, wl, lal, ral, err, both; + int fl, fl2, ll, wl, lal, ral, err, both; if (!*s) return NULL; while (*s) { - lal = ral = both = 0; + lal = ral = both = fl2 = 0; left = right = NULL; while (*s && inblank(*s)) s++; @@ -197,10 +197,14 @@ parse_cmatcher(char *name, char *s) if (!*s) break; switch (*s) { + case 'b': fl2 = CMF_INTER; case 'l': fl = CMF_LEFT; break; + case 'e': fl2 = CMF_INTER; case 'r': fl = CMF_RIGHT; break; case 'm': fl = 0; break; + case 'B': fl2 = CMF_INTER; case 'L': fl = CMF_LEFT | CMF_LINE; break; + case 'E': fl2 = CMF_INTER; case 'R': fl = CMF_RIGHT | CMF_LINE; break; case 'M': fl = CMF_LINE; break; default: @@ -220,7 +224,7 @@ parse_cmatcher(char *name, char *s) zwarnnam(name, "missing patterns", NULL, 0); return pcm_err; } - if (fl & CMF_LEFT) { + if ((fl & CMF_LEFT) && !fl2) { left = parse_pattern(name, &s, &lal, '|', &err); if (err) return pcm_err; @@ -236,7 +240,8 @@ parse_cmatcher(char *name, char *s) } else left = NULL; - line = parse_pattern(name, &s, &ll, ((fl & CMF_RIGHT) ? '|' : '='), + line = parse_pattern(name, &s, &ll, + (((fl & CMF_RIGHT) && !fl2) ? '|' : '='), &err); if (err) return pcm_err; @@ -246,10 +251,10 @@ parse_cmatcher(char *name, char *s) line = NULL; ll = 0; } - if ((fl & CMF_RIGHT) && (!*s || !*++s)) { + if ((fl & CMF_RIGHT) && !fl2 && (!*s || !*++s)) { if (name) zwarnnam(name, "missing right anchor", NULL, 0); - } else if (!(fl & CMF_RIGHT)) { + } else if (!(fl & CMF_RIGHT) || fl2) { if (!*s) { if (name) zwarnnam(name, "missing word pattern", NULL, 0); @@ -257,7 +262,7 @@ parse_cmatcher(char *name, char *s) } s++; } - if (fl & CMF_RIGHT) { + if ((fl & CMF_RIGHT) && !fl2) { if (*s == '|') { left = line; lal = ll; @@ -304,7 +309,7 @@ parse_cmatcher(char *name, char *s) n = (Cmatcher) hcalloc(sizeof(*ret)); n->next = NULL; - n->flags = fl; + n->flags = fl | fl2; n->line = line; n->llen = ll; n->word = word; diff --git a/Src/Zle/compmatch.c b/Src/Zle/compmatch.c index 130cb23b0..aa7890407 100644 --- a/Src/Zle/compmatch.c +++ b/Src/Zle/compmatch.c @@ -565,7 +565,9 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, NULL, NULL)) || !match_parts(l + aoff, w + aoff, alen, part)))) continue; - } else if (!both || il || iw) + } else if (!both || ((mp->flags & CMF_INTER) ? + ((mp->flags & CMF_LINE) ? iw : il) : + (il || iw))) continue; /* Fine, now we call ourselves recursively to find the @@ -734,7 +736,9 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, tw - mp->lalen - mp->ralen, NULL, NULL)); else - t = (!sfx && !il && !iw); + t = (!sfx && !((mp->flags & CMF_INTER) ? + ((mp->flags & CMF_LINE) ? iw : il) : + (il || iw))); } if (mp->flags & CMF_RIGHT) { /* Try to match the right anchor, if any. */ @@ -753,7 +757,9 @@ match_str(char *l, char *w, Brinfo *bpp, int bc, int *rwlp, mp->ralen - mp->lalen, NULL, NULL)); else - t = (sfx && !il && !iw); + t = (sfx && !((mp->flags & CMF_INTER) ? + ((mp->flags & CMF_LINE) ? iw : il) : + (il || iw))); } /* Now try to match the line and word patterns. */ if (!t || -- cgit 1.4.1