mirror of
https://github.com/tmux/tmux.git
synced 2026-07-03 10:12:31 +00:00
Merge branch 'obsd-master'
This commit is contained in:
34
format.c
34
format.c
@@ -4525,11 +4525,14 @@ format_build_modifiers(struct format_expand_state *es, const char **s,
|
||||
return (list);
|
||||
}
|
||||
|
||||
/* Fuzzy match strings. */
|
||||
/* Fuzzy match a single token (no spaces). */
|
||||
static int
|
||||
format_fuzzy_match(const char *pattern, const char *text, int icase)
|
||||
format_fuzzy_match_token(const char *pattern, size_t patternlen,
|
||||
const char *text, int icase)
|
||||
{
|
||||
while (*pattern != '\0') {
|
||||
const char *end = pattern + patternlen;
|
||||
|
||||
while (pattern != end) {
|
||||
if (*text == '\0')
|
||||
return (0);
|
||||
if (icase) {
|
||||
@@ -4544,6 +4547,31 @@ format_fuzzy_match(const char *pattern, const char *text, int icase)
|
||||
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. */
|
||||
static char *
|
||||
format_match(struct format_modifier *fm, const char *pattern, const char *text)
|
||||
|
||||
3
tmux.1
3
tmux.1
@@ -6387,7 +6387,8 @@ means the pattern is a regular expression instead of the default
|
||||
pattern,
|
||||
.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,
|
||||
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
|
||||
means to ignore case.
|
||||
|
||||
Reference in New Issue
Block a user