Merge branch 'obsd-master'

This commit is contained in:
Thomas Adam 2019-06-18 13:02:28 +01:00
commit ee9bc355f5
11 changed files with 47 additions and 19 deletions

2
cfg.c
View File

@ -52,7 +52,7 @@ cfg_done(__unused struct cmdq_item *item, __unused void *data)
cfg_show_causes(RB_MIN(sessions, &sessions)); cfg_show_causes(RB_MIN(sessions, &sessions));
if (cfg_item != NULL) if (cfg_item != NULL)
cfg_item->flags &= ~CMDQ_WAITING; cmdq_continue(cfg_item);
status_prompt_load_history(); status_prompt_load_history();

View File

@ -188,7 +188,7 @@ cmd_display_panes_free(struct client *c)
struct cmd_display_panes_data *cdata = c->overlay_data; struct cmd_display_panes_data *cdata = c->overlay_data;
if (cdata->item != NULL) if (cdata->item != NULL)
cdata->item->flags &= ~CMDQ_WAITING; cmdq_continue(cdata->item);
free(cdata->command); free(cdata->command);
free(cdata); free(cdata);
} }

View File

@ -196,7 +196,7 @@ cmd_if_shell_callback(struct job *job)
out: out:
if (cdata->item != NULL) if (cdata->item != NULL)
cdata->item->flags &= ~CMDQ_WAITING; cmdq_continue(cdata->item);
} }
static void static void

View File

@ -176,7 +176,7 @@ cmd_load_buffer_callback(struct client *c, int closed, void *data)
free(cause); free(cause);
} }
out: out:
cdata->item->flags &= ~CMDQ_WAITING; cmdq_continue(cdata->item);
free(cdata->bufname); free(cdata->bufname);
free(cdata); free(cdata);

View File

@ -1338,8 +1338,8 @@ static int
yylex_token_brace(char **buf, size_t *len) yylex_token_brace(char **buf, size_t *len)
{ {
struct cmd_parse_state *ps = &parse_state; struct cmd_parse_state *ps = &parse_state;
int ch, nesting = 1, escape = 0, quote = '\0'; int ch, lines = 0, nesting = 1, escape = 0;
int lines = 0; int quote = '\0', token = 0;
/* /*
* Extract a string up to the matching unquoted '}', including newlines * Extract a string up to the matching unquoted '}', including newlines
@ -1349,6 +1349,10 @@ yylex_token_brace(char **buf, size_t *len)
* depth, we scan the input as if it was a tmux config file, and ignore * depth, we scan the input as if it was a tmux config file, and ignore
* braces which would be considered quoted, escaped, or in a comment. * braces which would be considered quoted, escaped, or in a comment.
* *
* We update the token state after every character because '#' begins a
* comment only when it begins a token. For simplicity, we treat an
* unquoted directive format as comment.
*
* The result is verbatim copy of the input excluding the final brace. * The result is verbatim copy of the input excluding the final brace.
*/ */
@ -1368,6 +1372,8 @@ yylex_token_brace(char **buf, size_t *len)
ch == '\n' || ch == '\n' ||
ch == '\\')) { ch == '\\')) {
escape = 0; escape = 0;
if (ch != '\n')
token = 1;
continue; continue;
} }
@ -1383,7 +1389,7 @@ yylex_token_brace(char **buf, size_t *len)
/* A newline always resets to unquoted. */ /* A newline always resets to unquoted. */
if (ch == '\n') { if (ch == '\n') {
quote = 0; quote = token = 0;
continue; continue;
} }
@ -1394,33 +1400,47 @@ yylex_token_brace(char **buf, size_t *len)
*/ */
if (ch == quote && quote != '#') if (ch == quote && quote != '#')
quote = 0; quote = 0;
} else { token = 1; /* token continues regardless */
} else {
/* Not inside quotes or comment. */ /* Not inside quotes or comment. */
switch (ch) { switch (ch) {
case '"': case '"':
case '\'': case '\'':
case '#': case '#':
/* Beginning of quote or comment. */ /* Beginning of quote or maybe comment. */
quote = ch; if (ch != '#' || !token)
quote = ch;
token = 1;
break;
case ' ':
case '\t':
case ';':
/* Delimiter - token resets. */
token = 0;
break; break;
case '{': case '{':
nesting++; nesting++;
token = 0; /* new commands set - token resets */
break; break;
case '}': case '}':
nesting--; nesting--;
token = 1; /* same as after quotes */
if (nesting == 0) { if (nesting == 0) {
(*len)--; /* remove closing } */ (*len)--; /* remove closing } */
ps->input->line += lines; ps->input->line += lines;
return (1); return (1);
} }
break; break;
default:
token = 1;
break;
} }
} }
} }
/* /*
* Update line count after error as reporting the opening line * Update line count after error as reporting the opening line is more
* is more useful than EOF. * useful than EOF.
*/ */
yyerror("unterminated brace string"); yyerror("unterminated brace string");
ps->input->line += lines; ps->input->line += lines;

View File

@ -156,6 +156,13 @@ cmdq_insert_hook(struct session *s, struct cmdq_item *item,
free(name); free(name);
} }
/* Continue processing command queue. */
void
cmdq_continue(struct cmdq_item *item)
{
item->flags &= ~CMDQ_WAITING;
}
/* Remove an item. */ /* Remove an item. */
static void static void
cmdq_remove(struct cmdq_item *item) cmdq_remove(struct cmdq_item *item)

View File

@ -155,7 +155,7 @@ cmd_run_shell_callback(struct job *job)
free(msg); free(msg);
if (cdata->item != NULL) if (cdata->item != NULL)
cdata->item->flags &= ~CMDQ_WAITING; cmdq_continue(cdata->item);
} }
static void static void

View File

@ -153,7 +153,7 @@ cmd_wait_for_signal(__unused struct cmdq_item *item, const char *name,
log_debug("signal wait channel %s, with waiters", wc->name); log_debug("signal wait channel %s, with waiters", wc->name);
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) { TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
wi->item->flags &= ~CMDQ_WAITING; cmdq_continue(wi->item);
TAILQ_REMOVE(&wc->waiters, wi, entry); TAILQ_REMOVE(&wc->waiters, wi, entry);
free(wi); free(wi);
@ -229,7 +229,7 @@ cmd_wait_for_unlock(struct cmdq_item *item, const char *name,
} }
if ((wi = TAILQ_FIRST(&wc->lockers)) != NULL) { if ((wi = TAILQ_FIRST(&wc->lockers)) != NULL) {
wi->item->flags &= ~CMDQ_WAITING; cmdq_continue(wi->item);
TAILQ_REMOVE(&wc->lockers, wi, entry); TAILQ_REMOVE(&wc->lockers, wi, entry);
free(wi); free(wi);
} else { } else {
@ -248,13 +248,13 @@ cmd_wait_for_flush(void)
RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) { RB_FOREACH_SAFE(wc, wait_channels, &wait_channels, wc1) {
TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) { TAILQ_FOREACH_SAFE(wi, &wc->waiters, entry, wi1) {
wi->item->flags &= ~CMDQ_WAITING; cmdq_continue(wi->item);
TAILQ_REMOVE(&wc->waiters, wi, entry); TAILQ_REMOVE(&wc->waiters, wi, entry);
free(wi); free(wi);
} }
wc->woken = 1; wc->woken = 1;
TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) { TAILQ_FOREACH_SAFE(wi, &wc->lockers, entry, wi1) {
wi->item->flags &= ~CMDQ_WAITING; cmdq_continue(wi->item);
TAILQ_REMOVE(&wc->lockers, wi, entry); TAILQ_REMOVE(&wc->lockers, wi, entry);
free(wi); free(wi);
} }

2
menu.c
View File

@ -161,7 +161,7 @@ menu_free_cb(struct client *c)
struct menu_data *md = c->overlay_data; struct menu_data *md = c->overlay_data;
if (md->item != NULL) if (md->item != NULL)
md->item->flags &= ~CMDQ_WAITING; cmdq_continue(md->item);
if (md->cb != NULL) if (md->cb != NULL)
md->cb(md->menu, UINT_MAX, KEYC_NONE, md->data); md->cb(md->menu, UINT_MAX, KEYC_NONE, md->data);

1
tmux.h
View File

@ -2039,6 +2039,7 @@ void cmdq_insert_after(struct cmdq_item *, struct cmdq_item *);
void cmdq_append(struct client *, struct cmdq_item *); void cmdq_append(struct client *, struct cmdq_item *);
void cmdq_insert_hook(struct session *, struct cmdq_item *, void cmdq_insert_hook(struct session *, struct cmdq_item *,
struct cmd_find_state *, const char *, ...); struct cmd_find_state *, const char *, ...);
void cmdq_continue(struct cmdq_item *);
void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *, void printflike(3, 4) cmdq_format(struct cmdq_item *, const char *,
const char *, ...); const char *, ...);
u_int cmdq_next(struct client *); u_int cmdq_next(struct client *);

View File

@ -1513,7 +1513,7 @@ window_pane_input_callback(struct client *c, int closed, void *data)
c->stdin_callback = NULL; c->stdin_callback = NULL;
server_client_unref(c); server_client_unref(c);
cdata->item->flags &= ~CMDQ_WAITING; cmdq_continue(cdata->item);
free(cdata); free(cdata);
return; return;