aboutsummaryrefslogtreecommitdiff
path: root/sam.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2016-04-05 15:58:25 +0200
committerMarc André Tanner <mat@brain-dump.org>2016-04-05 15:58:25 +0200
commitfc6a31fdc3a6c48633e5f3759a2357028566def1 (patch)
treee961b073a772d757811c25c2f33d4eb9c0a7f9f4 /sam.c
parentf0b64700f9da35bfb013574b597f11a1ad3d2a65 (diff)
downloadvis-fc6a31fdc3a6c48633e5f3759a2357028566def1.tar.gz
vis-fc6a31fdc3a6c48633e5f3759a2357028566def1.tar.xz
sam: improve group handling, do not loop infinitely
Diffstat (limited to 'sam.c')
-rw-r--r--sam.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sam.c b/sam.c
index 5f915bc..b2b09f1 100644
--- 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);
}