vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 8247902dbea29f63201485916f9c6df88002da61 parent 9f2270bad2aa6bc61b12e785e6df3c711b317ecf Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 16 Nov 2016 22:32:43 +0100 sam: support an empty regex as an alias for the most recently used one As in sam if an empty regex // is provided we substitute in the most recently used one. 0/regexp/// Will match the second occurrence in the fie. Diffstat:
| M | sam.c | | | 5 | ++--- |
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/sam.c b/sam.c @@ -386,6 +386,7 @@ const char *sam_error(enum SamError err) { [SAM_ERR_UNMATCHED_BRACE] = "Unmatched `}'", [SAM_ERR_REGEX] = "Bad regular expression", [SAM_ERR_TEXT] = "Bad text", + [SAM_ERR_SHELL] = "Shell command expected", [SAM_ERR_COMMAND] = "Unknown command", [SAM_ERR_EXECUTE] = "Error executing command", }; @@ -522,9 +523,7 @@ static char *parse_cmdname(const char **s) { static Regex *parse_regex(Vis *vis, const char **s) { char *pattern = parse_delimited(s, CMD_REGEX); - if (!pattern) - return NULL; - Regex *regex = vis_regex(vis, *pattern ? pattern : NULL); + Regex *regex = vis_regex(vis, pattern); free(pattern); return regex; }