summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2019-05-29 19:34:43 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2019-05-29 19:34:43 +0000
commit838ffe0f3110c5639b501d76efe97fc54bdb12be (patch)
treefa8ca976019bf06311a5258e7ab26283f2a3b98e
parent37ded1a3660f8f140baa3e150346e12939f673a9 (diff)
The line number needs to be updated only after the \n is processed by
the parser, so store a flag and update it next time around. Also each new line needs its own shared data.
-rw-r--r--usr.bin/tmux/cmd-parse.y9
-rw-r--r--usr.bin/tmux/cmd-queue.c30
2 files changed, 28 insertions, 11 deletions
diff --git a/usr.bin/tmux/cmd-parse.y b/usr.bin/tmux/cmd-parse.y
index b68289926fa..ea13fd3da6f 100644
--- a/usr.bin/tmux/cmd-parse.y
+++ b/usr.bin/tmux/cmd-parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-parse.y,v 1.7 2019/05/29 10:08:36 nicm Exp $ */
+/* $OpenBSD: cmd-parse.y,v 1.8 2019/05/29 19:34:42 nicm Exp $ */
/*
* Copyright (c) 2019 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -58,6 +58,7 @@ struct cmd_parse_state {
size_t len;
size_t off;
+ int eol;
int eof;
struct cmd_parse_input *input;
u_int escapes;
@@ -933,6 +934,10 @@ yylex(void)
char *token, *cp;
int ch, next;
+ if (ps->eol)
+ ps->input->line++;
+ ps->eol = 0;
+
for (;;) {
ch = yylex_getc();
@@ -959,7 +964,7 @@ yylex(void)
/*
* End of line. Update the line number.
*/
- ps->input->line++;
+ ps->eol = 1;
return ('\n');
}
diff --git a/usr.bin/tmux/cmd-queue.c b/usr.bin/tmux/cmd-queue.c
index 1346379b381..dee7ab92cb1 100644
--- a/usr.bin/tmux/cmd-queue.c
+++ b/usr.bin/tmux/cmd-queue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cmd-queue.c,v 1.71 2019/05/25 10:46:55 nicm Exp $ */
+/* $OpenBSD: cmd-queue.c,v 1.72 2019/05/29 19:34:42 nicm Exp $ */
/*
* Copyright (c) 2013 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -203,16 +203,20 @@ cmdq_get_command(struct cmd_list *cmdlist, struct cmd_find_state *current,
struct cmdq_item *item, *first = NULL, *last = NULL;
struct cmd *cmd;
struct cmdq_shared *shared;
-
- shared = xcalloc(1, sizeof *shared);
- if (current != NULL)
- cmd_find_copy_state(&shared->current, current);
- else
- cmd_find_clear_state(&shared->current, 0);
- if (m != NULL)
- memcpy(&shared->mouse, m, sizeof shared->mouse);
+ u_int group = 0;
TAILQ_FOREACH(cmd, &cmdlist->list, qentry) {
+ if (cmd->group != group) {
+ shared = xcalloc(1, sizeof *shared);
+ if (current != NULL)
+ cmd_find_copy_state(&shared->current, current);
+ else
+ cmd_find_clear_state(&shared->current, 0);
+ if (m != NULL)
+ memcpy(&shared->mouse, m, sizeof shared->mouse);
+ group = cmd->group;
+ }
+
item = xcalloc(1, sizeof *item);
xasprintf(&item->name, "[%s/%p]", cmd->entry->name, item);
item->type = CMDQ_COMMAND;
@@ -263,12 +267,20 @@ static enum cmd_retval
cmdq_fire_command(struct cmdq_item *item)
{
struct client *c = item->client;
+ const char *name = cmdq_name(c);
struct cmdq_shared *shared = item->shared;
struct cmd *cmd = item->cmd;
const struct cmd_entry *entry = cmd->entry;
enum cmd_retval retval;
struct cmd_find_state *fsp, fs;
int flags;
+ char *tmp;
+
+ if (log_get_level() > 1) {
+ tmp = cmd_print(cmd);
+ log_debug("%s %s: (%u) %s", __func__, name, item->group, tmp);
+ free(tmp);
+ }
flags = !!(shared->flags & CMDQ_SHARED_CONTROL);
cmdq_guard(item, "begin", flags);