From 092c7bfeb85adffddf3cc24c4096e508c537a1ba Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Thu, 23 May 2019 13:06:47 +0100 Subject: [PATCH 1/8] TRAVIS: add bison to build deps --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a1d7e427..2188eec0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,5 +6,5 @@ matrix: env: CFLAGS="-g -O2" before_install: - sudo apt-get update -qq - - sudo apt-get -y install debhelper autotools-dev dh-autoreconf file libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential + - sudo apt-get -y install bison debhelper autotools-dev dh-autoreconf file libncurses5-dev libevent-dev pkg-config libutempter-dev build-essential script: (CFLAGS= ./autogen.sh) && ./configure --enable-debug && make From d67b99c7e4b3e16adc5dbc637ad67e5795064bdd Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Thu, 23 May 2019 13:09:34 +0100 Subject: [PATCH 2/8] configure.ac: add AC_PROC_YACC --- configure.ac | 2 ++ 1 file changed, 2 insertions(+) diff --git a/configure.ac b/configure.ac index 1e7578ee..514548b5 100644 --- a/configure.ac +++ b/configure.ac @@ -658,5 +658,7 @@ CFLAGS="$SAVED_CFLAGS" AC_SUBST(AM_LDFLAGS) LDFLAGS="$SAVED_LDFLAGS" +AC_PROG_YACC + # autoconf should create a Makefile. AC_OUTPUT(Makefile) From 3e6e533779fd6fb1540333a7910f71a4b799da1a Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 23 May 2019 13:04:41 +0100 Subject: [PATCH 3/8] Add yacc(1) bits. --- .gitignore | 1 + Makefile.am | 2 +- configure.ac | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index ad18d1de..d01a0166 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ Makefile.in configure tmux.1.* *.dSYM +cmd-parse.c diff --git a/Makefile.am b/Makefile.am index 9db08a02..ceaae6ad 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,7 +2,7 @@ # Obvious program stuff. bin_PROGRAMS = tmux -CLEANFILES = tmux.1.mdoc tmux.1.man +CLEANFILES = tmux.1.mdoc tmux.1.man cmd-parse.c # Distribution tarball options. EXTRA_DIST = \ diff --git a/configure.ac b/configure.ac index 514548b5..355cf0b4 100644 --- a/configure.ac +++ b/configure.ac @@ -28,6 +28,7 @@ AC_PROG_CC_C99 AC_PROG_CPP AC_PROG_EGREP AC_PROG_INSTALL +AC_PROG_YACC PKG_PROG_PKG_CONFIG AC_USE_SYSTEM_EXTENSIONS From 83b9807370bcba7d37795767da477a3215f1c2a8 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 23 May 2019 13:32:18 +0100 Subject: [PATCH 4/8] Remove duplicate. --- configure.ac | 2 -- 1 file changed, 2 deletions(-) diff --git a/configure.ac b/configure.ac index 355cf0b4..d09fec9d 100644 --- a/configure.ac +++ b/configure.ac @@ -659,7 +659,5 @@ CFLAGS="$SAVED_CFLAGS" AC_SUBST(AM_LDFLAGS) LDFLAGS="$SAVED_LDFLAGS" -AC_PROG_YACC - # autoconf should create a Makefile. AC_OUTPUT(Makefile) From 6bb505eb7379b82f2d3da1ce31bf1657670124ed Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Thu, 23 May 2019 15:11:13 +0100 Subject: [PATCH 5/8] CHANGES: mention yacc --- CHANGES | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGES b/CHANGES index 1c37c5ec..3caa9796 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,22 @@ CHANGES FROM 2.9 to X.X +* INCOMPATIBLE: tmux's configuration parsing has changed to use yacc(1) + instead. Most configuration files shouldn't need changing, however, the + following will need quoting: + + #{} + + That is, formats, since it would otherwise be consisdered a comment. + + Entirely the same parser is now used for parsing the configuration file + and for string commands. This means that constructs previously only + available in .tmux.conf, such as %if, can now be used in string commands + (for example, those given to if-shell - not commands invoked from the + shell, they are still parsed by the shell itself). + + DOWNSTREAM PACKAGERS: please make your tmux builds depend on yacc/bison or + similar. + * Add support for the overline attribute (SGR 53). The Smol capability is needed in terminal-overrides. From d0c462f718f4769140da73328cdcd1cbd2048ab7 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 23 May 2019 12:47:52 +0000 Subject: [PATCH 6/8] Fix length calculation for pasting UTF-8 characters in the status line, GitHub issue 1753. --- status.c | 111 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 41 deletions(-) diff --git a/status.c b/status.c index ef8cf14d..ce36cc3c 100644 --- a/status.c +++ b/status.c @@ -846,16 +846,79 @@ status_prompt_translate_key(struct client *c, key_code key, key_code *new_key) return (0); } +/* Paste into prompt. */ +static int +status_prompt_paste(struct client *c) +{ + struct paste_buffer *pb; + const char *bufdata; + size_t size, n, bufsize; + u_int i; + struct utf8_data *ud, *udp; + enum utf8_state more; + + size = utf8_strlen(c->prompt_buffer); + if (c->prompt_saved != NULL) { + ud = c->prompt_saved; + n = utf8_strlen(c->prompt_saved); + } else { + if ((pb = paste_get_top(NULL)) == NULL) + return (0); + bufdata = paste_buffer_data(pb, &bufsize); + ud = xreallocarray(NULL, bufsize, sizeof *ud); + udp = ud; + for (i = 0; i != bufsize; /* nothing */) { + more = utf8_open(udp, bufdata[i]); + if (more == UTF8_MORE) { + while (++i != bufsize && more == UTF8_MORE) + more = utf8_append(udp, bufdata[i]); + if (more == UTF8_DONE) { + udp++; + continue; + } + i -= udp->have; + } + if (bufdata[i] <= 31 || bufdata[i] >= 127) + break; + utf8_set(udp, bufdata[i]); + udp++; + i++; + } + udp->size = 0; + n = udp - ud; + } + if (n == 0) + return (0); + + c->prompt_buffer = xreallocarray(c->prompt_buffer, size + n + 1, + sizeof *c->prompt_buffer); + if (c->prompt_index == size) { + memcpy(c->prompt_buffer + c->prompt_index, ud, + n * sizeof *c->prompt_buffer); + c->prompt_index += n; + c->prompt_buffer[c->prompt_index].size = 0; + } else { + memmove(c->prompt_buffer + c->prompt_index + n, + c->prompt_buffer + c->prompt_index, + (size + 1 - c->prompt_index) * sizeof *c->prompt_buffer); + memcpy(c->prompt_buffer + c->prompt_index, ud, + n * sizeof *c->prompt_buffer); + c->prompt_index += n; + } + + if (ud != c->prompt_saved) + free(ud); + return (1); +} + /* Handle keys in prompt. */ int status_prompt_key(struct client *c, key_code key) { struct options *oo = c->session->options; - struct paste_buffer *pb; char *s, *cp, word[64], prefix = '='; - const char *histstr, *bufdata, *ws = NULL; - u_char ch; - size_t size, n, off, idx, bufsize, used; + const char *histstr, *ws = NULL; + size_t size, n, off, idx, used; struct utf8_data tmp, *first, *last, *ud; int keys; @@ -1107,43 +1170,9 @@ process_key: c->prompt_index = utf8_strlen(c->prompt_buffer); goto changed; case '\031': /* C-y */ - if (c->prompt_saved != NULL) { - ud = c->prompt_saved; - n = utf8_strlen(c->prompt_saved); - } else { - if ((pb = paste_get_top(NULL)) == NULL) - break; - bufdata = paste_buffer_data(pb, &bufsize); - for (n = 0; n < bufsize; n++) { - ch = (u_char)bufdata[n]; - if (ch < 32 || ch >= 127) - break; - } - ud = xreallocarray(NULL, n, sizeof *ud); - for (idx = 0; idx < n; idx++) - utf8_set(&ud[idx], bufdata[idx]); - } - - c->prompt_buffer = xreallocarray(c->prompt_buffer, size + n + 1, - sizeof *c->prompt_buffer); - if (c->prompt_index == size) { - memcpy(c->prompt_buffer + c->prompt_index, ud, - n * sizeof *c->prompt_buffer); - c->prompt_index += n; - c->prompt_buffer[c->prompt_index].size = 0; - } else { - memmove(c->prompt_buffer + c->prompt_index + n, - c->prompt_buffer + c->prompt_index, - (size + 1 - c->prompt_index) * - sizeof *c->prompt_buffer); - memcpy(c->prompt_buffer + c->prompt_index, ud, - n * sizeof *c->prompt_buffer); - c->prompt_index += n; - } - - if (ud != c->prompt_saved) - free(ud); - goto changed; + if (status_prompt_paste(c)) + goto changed; + break; case '\024': /* C-t */ idx = c->prompt_index; if (idx < size) From 7d702f3cef4c75130ad78ab2158fa1aac45b7ea1 Mon Sep 17 00:00:00 2001 From: nicm Date: Thu, 23 May 2019 13:08:43 +0000 Subject: [PATCH 7/8] Don't remove group items for group 0 (no group). --- cmd-queue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd-queue.c b/cmd-queue.c index c343a212..0cfa57fe 100644 --- a/cmd-queue.c +++ b/cmd-queue.c @@ -181,6 +181,8 @@ cmdq_remove_group(struct cmdq_item *item) { struct cmdq_item *this, *next; + if (item->group == 0) + return; this = TAILQ_NEXT(item, entry); while (this != NULL) { next = TAILQ_NEXT(this, entry); From 1a6540fea0285fd8eb10dd476b249c54e3f43d7a Mon Sep 17 00:00:00 2001 From: Thomas Adam Date: Thu, 23 May 2019 15:15:34 +0100 Subject: [PATCH 8/8] CHANGES: remove note to packagers --- CHANGES | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGES b/CHANGES index 3caa9796..7423344a 100644 --- a/CHANGES +++ b/CHANGES @@ -14,9 +14,6 @@ CHANGES FROM 2.9 to X.X (for example, those given to if-shell - not commands invoked from the shell, they are still parsed by the shell itself). - DOWNSTREAM PACKAGERS: please make your tmux builds depend on yacc/bison or - similar. - * Add support for the overline attribute (SGR 53). The Smol capability is needed in terminal-overrides.