mirror of
https://github.com/tmux/tmux.git
synced 2026-10-09 03:34:25 +00:00
Remove fuzzy match operator again for now, this will be done differently.
This commit is contained in:
52
format.c
52
format.c
@@ -4507,53 +4507,6 @@ format_build_modifiers(struct format_expand_state *es, const char **s,
|
|||||||
return (list);
|
return (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fuzzy match a single token (no spaces). */
|
|
||||||
static int
|
|
||||||
format_fuzzy_match_token(const char *pattern, size_t patternlen,
|
|
||||||
const char *text, int icase)
|
|
||||||
{
|
|
||||||
const char *end = pattern + patternlen;
|
|
||||||
|
|
||||||
while (pattern != end) {
|
|
||||||
if (*text == '\0')
|
|
||||||
return (0);
|
|
||||||
if (icase) {
|
|
||||||
if (tolower((u_char)*pattern) == tolower((u_char)*text))
|
|
||||||
pattern++;
|
|
||||||
} else {
|
|
||||||
if (*pattern == *text)
|
|
||||||
pattern++;
|
|
||||||
}
|
|
||||||
text++;
|
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Fuzzy match strings. The pattern is split on spaces into tokens and every
|
|
||||||
* token must match as a sequence.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
format_fuzzy_match(const char *pattern, const char *text, int icase)
|
|
||||||
{
|
|
||||||
const char *start;
|
|
||||||
size_t len;
|
|
||||||
|
|
||||||
while (*pattern != '\0') {
|
|
||||||
while (*pattern == ' ')
|
|
||||||
pattern++;
|
|
||||||
if (*pattern == '\0')
|
|
||||||
break;
|
|
||||||
start = pattern;
|
|
||||||
while (*pattern != '\0' && *pattern != ' ')
|
|
||||||
pattern++;
|
|
||||||
len = pattern - start;
|
|
||||||
if (!format_fuzzy_match_token(start, len, text, icase))
|
|
||||||
return (0);
|
|
||||||
}
|
|
||||||
return (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Match against an fnmatch(3) pattern or regular expression. */
|
/* Match against an fnmatch(3) pattern or regular expression. */
|
||||||
static char *
|
static char *
|
||||||
format_match(struct format_modifier *fm, const char *pattern, const char *text)
|
format_match(struct format_modifier *fm, const char *pattern, const char *text)
|
||||||
@@ -4564,10 +4517,7 @@ format_match(struct format_modifier *fm, const char *pattern, const char *text)
|
|||||||
|
|
||||||
if (fm->argc >= 1)
|
if (fm->argc >= 1)
|
||||||
s = fm->argv[0];
|
s = fm->argv[0];
|
||||||
if (strchr(s, 'z') != NULL) {
|
if (strchr(s, 'r') == NULL) {
|
||||||
if (!format_fuzzy_match(pattern, text, strchr(s, 'i') != NULL))
|
|
||||||
return (xstrdup("0"));
|
|
||||||
} else if (strchr(s, 'r') == NULL) {
|
|
||||||
if (strchr(s, 'i') != NULL)
|
if (strchr(s, 'i') != NULL)
|
||||||
flags |= FNM_CASEFOLD;
|
flags |= FNM_CASEFOLD;
|
||||||
if (fnmatch(pattern, text, flags) != 0)
|
if (fnmatch(pattern, text, flags) != 0)
|
||||||
|
|||||||
11
tmux.1
11
tmux.1
@@ -6382,20 +6382,13 @@ An optional argument specifies flags:
|
|||||||
.Ql r
|
.Ql r
|
||||||
means the pattern is a regular expression instead of the default
|
means the pattern is a regular expression instead of the default
|
||||||
.Xr glob 7
|
.Xr glob 7
|
||||||
pattern,
|
pattern and
|
||||||
.Ql z
|
|
||||||
means the pattern is a fuzzy match, that is, it matches if its characters
|
|
||||||
appear in the string in order but not necessarily consecutively;
|
|
||||||
the pattern is split on spaces into separate terms which must all match,
|
|
||||||
and
|
|
||||||
.Ql i
|
.Ql i
|
||||||
means to ignore case.
|
means to ignore case.
|
||||||
For example:
|
For example:
|
||||||
.Ql #{m:*foo*,#{host}}
|
.Ql #{m:*foo*,#{host}}
|
||||||
or
|
or
|
||||||
.Ql #{m/ri:\[ha]A,MYVAR}
|
.Ql #{m/ri:\[ha]A,MYVAR} .
|
||||||
or
|
|
||||||
.Ql #{m/z:abc,aXbXc} .
|
|
||||||
A
|
A
|
||||||
.Ql C
|
.Ql C
|
||||||
performs a search for a
|
performs a search for a
|
||||||
|
|||||||
Reference in New Issue
Block a user