vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 845a7f1c9c6ab1b72d21bcf87df6840390833e8a
parent c532f7e163f2af962f689d4f4f6574654d0e4357
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Wed, 12 Apr 2017 17:39:51 +0200

sam: distinguish between empty // and no regex

Diffstat:
Msam.c | 5++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git 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;