aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-04-12 17:39:51 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-04-12 18:37:01 +0200
commit964189735954a9e89ad507c68c20423fe02eaccf (patch)
treec5aacf02332a8e54c0de22eb8762e9eb33a8fa4c
parent08ca4d22e08491130bd6be4baad4503f972f7750 (diff)
downloadvis-964189735954a9e89ad507c68c20423fe02eaccf.tar.gz
vis-964189735954a9e89ad507c68c20423fe02eaccf.tar.xz
sam: distinguish between empty // and no regex
-rw-r--r--sam.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/sam.c b/sam.c
index e2e1667..1991c9e 100644
--- a/sam.c
+++ b/sam.c
@@ -550,7 +550,7 @@ static char *parse_until(const char **s, const char *until, const char *escchars
static char *parse_delimited(const char **s, int type) {
char delim[2] = { **s, '\0' };
- if (!delim[0])
+ if (!delim[0] || isspace((unsigned char)delim[0]))
return NULL;
(*s)++;
char *chunk = parse_until(s, delim, NULL, type);
@@ -624,7 +624,10 @@ static char *parse_cmdname(const char **s) {
}
static Regex *parse_regex(Vis *vis, const char **s) {
+ const char *before = *s;
char *pattern = parse_delimited(s, CMD_REGEX);
+ if (!pattern && *s == before)
+ return NULL;
Regex *regex = vis_regex(vis, pattern);
free(pattern);
return regex;