aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-09-22 13:50:39 -0700
committerBruce Hill <bruce@bruce-hill.com>2019-09-22 13:50:39 -0700
commit6c075036d71d3a40417e9661c655240a9b2f9fa3 (patch)
tree1302617316d40c002716370dd462efab98413b62
parente1aaf05b98b3bf9b9333b5924e5448993dc76052 (diff)
Added support for space as a sort of wildcard so "foo bar" matches
"FooBar" and "foo.bar"
-rw-r--r--ask.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/ask.c b/ask.c
index 76c3966..3d58db6 100644
--- a/ask.c
+++ b/ask.c
@@ -46,6 +46,10 @@ static int lcs(const char *str, const char *patt, int slen, int plen, int s, int
{
if (!patt[p]) return 0;
if (!str[s]) return -1;
+ if (patt[p] == ' ') {
+ if (str[s] == ' ') return lcs(str, patt, slen, plen, s+1, p+1, cache);
+ else return lcs(str, patt, slen, plen, s, p+1, cache);
+ }
if (cache[s*plen + p]) return cache[s*plen + p];
if (!EQ(str[s], patt[p])) return lcs(str, patt, slen, plen, s+1, p, cache);
// Run starting here
@@ -62,6 +66,10 @@ static int lcs(const char *str, const char *patt, int slen, int plen, int s, int
static int matches(const char *str, const char *patt)
{
while (*patt) {
+ if (*patt == ' ') {
+ ++patt;
+ continue;
+ }
while (!EQ(*str, *patt)) {
if (!*str) return 0;
++str;
@@ -111,6 +119,10 @@ static int draw_line(FILE *out, const char *option, const char *patt, int cursor
else to_start += len;
++run;
++p;
+ } else if (patt[p] == ' ') {
+ run = 0;
+ ++p;
+ --i;
} else {
run = 0;
if (state != dim) {