vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 9943a48955d00d0f47c4e36d503b9fb64a0e4642 parent 753eda252cdf13a6269894cf80e8fe8d35439d8c Author: Marc André Tanner <mat@brain-dump.org> Date: Tue, 5 Apr 2016 15:58:25 +0200 sam: improve group handling, do not loop infinitely Diffstat:
| M | sam.c | | | 6 | ++++-- |
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sam.c b/sam.c @@ -485,6 +485,8 @@ static const CommandDef *command_lookup(Vis *vis, const char *name) { } static Command *command_parse(Vis *vis, const char **s, int level, enum SamError *err) { + if (!**s) + return NULL; Command *cmd = command_new(NULL); if (!cmd) return NULL; @@ -732,7 +734,7 @@ static bool sam_execute(Vis *vis, Win *win, Command *cmd, Cursor *cur, Filerange start = text_mark_set(txt, group.start); end = text_mark_set(txt, group.end); - ret &= sam_execute(vis, win, c, cur, &group); + ret &= sam_execute(vis, win, c, NULL, &group); size_t s = text_mark_get(txt, start); /* hack to make delete work, only update if still valid */ @@ -827,7 +829,7 @@ static bool cmd_extract(Vis *vis, Win *win, Command *cmd, const char *argv[], Cu Cursor *cursor = NULL; size_t pos = view_cursor_get(view); - if (!view_cursors_dispose(cur)) { + if (cur && !view_cursors_dispose(cur)) { cursor = view_cursors_new(view, text_size(txt)+1); view_cursors_dispose(cur); }