From b21a9b1c4eb175938b07855e670a39302726a03d Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Tue, 17 Mar 2020 16:06:30 +0000 Subject: getopt varies too much between platforms, and we already use compat/getopt.c for Linux so just use it everywhere. --- compat.h | 2 -- configure.ac | 40 ++++++---------------------------------- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/compat.h b/compat.h index 70801d0d..b7ec5a69 100644 --- a/compat.h +++ b/compat.h @@ -370,7 +370,6 @@ int utf8proc_mbtowc(wchar_t *, const char *, size_t); int utf8proc_wctomb(char *, wchar_t); #endif -#ifndef HAVE_GETOPT /* getopt.c */ extern int BSDopterr; extern int BSDoptind; @@ -384,6 +383,5 @@ int BSDgetopt(int, char *const *, const char *); #define optopt BSDoptopt #define optreset BSDoptreset #define optarg BSDoptarg -#endif #endif /* COMPAT_H */ diff --git a/configure.ac b/configure.ac index d98b72f2..947a0a2f 100644 --- a/configure.ac +++ b/configure.ac @@ -125,6 +125,12 @@ AC_FUNC_STRNLEN # Look for clock_gettime. Must come before event_init. AC_SEARCH_LIBS(clock_gettime, rt) +# Always use our getopt because 1) glibc's doesn't enforce argument order 2) +# musl does not set optarg to NULL for flags without arguments (although it is +# not required to, but it is helpful) 3) there are probably other weird +# implementations. +AC_LIBOBJ(getopt) + # Look for libevent. PKG_CHECK_MODULES( LIBEVENT, @@ -424,40 +430,6 @@ else AC_LIBOBJ(unvis) fi -# Look for getopt. glibc's getopt does not enforce argument order and the ways -# of making it do so are stupid, so just use our own instead. -AC_CHECK_FUNC(getopt, found_getopt=yes, found_getopt=no) -if test "x$found_getopt" != xno; then - AC_MSG_CHECKING(if getopt is suitable) - AC_EGREP_CPP( - yes, - [ - #include - #ifdef __GLIBC__ - yes - #endif - ], - [ - found_getopt=no - AC_MSG_RESULT(no) - ], - AC_MSG_RESULT(yes)) -fi -if test "x$found_getopt" != xno; then - AC_CHECK_DECLS( - [optarg, optind, optreset], - , - found_getopt=no, - [ - #include - ]) -fi -if test "x$found_getopt" != xno; then - AC_DEFINE(HAVE_GETOPT) -else - AC_LIBOBJ(getopt) -fi - # Look for fdforkpty and forkpty in libutil. AC_SEARCH_LIBS(fdforkpty, util, found_fdforkpty=yes, found_fdforkpty=no) if test "x$found_fdforkpty" = xyes; then -- cgit From c0d74661b7a176340a3ceaa77622d6c3747a2984 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 16 Mar 2020 18:08:39 +0000 Subject: Do not attempt to close a NULL pane when failing to create a new one. --- cmd-split-window.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cmd-split-window.c b/cmd-split-window.c index eaf1f74c..a5fa3acc 100644 --- a/cmd-split-window.c +++ b/cmd-split-window.c @@ -153,7 +153,6 @@ cmd_split_window_exec(struct cmd *self, struct cmdq_item *item) sc.flags |= SPAWN_DETACHED; if ((new_wp = spawn_pane(&sc, &cause)) == NULL) { - layout_close_pane(new_wp); cmdq_error(item, "create pane failed: %s", cause); free(cause); return (CMD_RETURN_ERROR); -- cgit From 4ffbebedce48d1758e082a82cbe9292fee358992 Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 16 Mar 2020 09:12:44 +0000 Subject: Terminate the output buffer for control mode output - it is now used as a string. GitHub issue 2114. --- control-notify.c | 1 + 1 file changed, 1 insertion(+) diff --git a/control-notify.c b/control-notify.c index babfcf2d..a513c147 100644 --- a/control-notify.c +++ b/control-notify.c @@ -54,6 +54,7 @@ control_notify_input(struct client *c, struct window_pane *wp, else evbuffer_add_printf(message, "%c", buf[i]); } + evbuffer_add(message, "", 1); control_write(c, "%s", EVBUFFER_DATA(message)); evbuffer_free(message); } -- cgit From f16085a362129f3b6801005fdff038d6845f4613 Mon Sep 17 00:00:00 2001 From: nicm Date: Sun, 15 Mar 2020 20:35:52 +0000 Subject: Fix C-Space key string. --- key-string.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/key-string.c b/key-string.c index d2b31e03..38e5b8a7 100644 --- a/key-string.c +++ b/key-string.c @@ -257,6 +257,10 @@ key_string_lookup_key(key_code key) return (out); } + /* Display C-@ as C-Space. */ + if ((key & KEYC_MASK_KEY) == 0) + key = ' ' | KEYC_CTRL | (key & KEYC_MASK_MOD); + /* Fill in the modifiers. */ if (key & KEYC_CTRL) strlcat(out, "C-", sizeof out); @@ -329,15 +333,6 @@ key_string_lookup_key(key_code key) return (out); } - /* - * Special case: display C-@ as C-Space. Could do this below in - * the (key >= 0 && key <= 32), but this way we let it be found - * in key_string_table, for the unlikely chance that we might - * change its name. - */ - if ((key & KEYC_MASK_KEY) == 0) - key = ' ' | KEYC_CTRL | (key & KEYC_MASK_MOD); - /* Try the key against the string table. */ for (i = 0; i < nitems(key_string_table); i++) { if (key == key_string_table[i].key) -- cgit From 617136c234f1a39c06e0ec4eed5c3ebea02cc85d Mon Sep 17 00:00:00 2001 From: nicm Date: Mon, 16 Mar 2020 09:18:47 +0000 Subject: Turn off mouse mode 1003 as well as the rest when exiting. --- tty.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tty.c b/tty.c index 3bab556d..8efe57b5 100644 --- a/tty.c +++ b/tty.c @@ -330,8 +330,10 @@ tty_start_tty(struct tty *tty) log_debug("%s: using UTF-8 for ACS", c->name); tty_putcode(tty, TTYC_CNORM); - if (tty_term_has(tty->term, TTYC_KMOUS)) - tty_puts(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l"); + if (tty_term_has(tty->term, TTYC_KMOUS)) { + tty_puts(tty, "\033[?1000l\033[?1002l\033[?1003l"); + tty_puts(tty, "\033[?1006l\033[?1005l"); + } if (tty_term_flag(tty->term, TTYC_XT)) { if (options_get_number(global_options, "focus-events")) { @@ -404,8 +406,10 @@ tty_stop_tty(struct tty *tty) tty_raw(tty, tty_term_string(tty->term, TTYC_CR)); tty_raw(tty, tty_term_string(tty->term, TTYC_CNORM)); - if (tty_term_has(tty->term, TTYC_KMOUS)) - tty_raw(tty, "\033[?1000l\033[?1002l\033[?1006l\033[?1005l"); + if (tty_term_has(tty->term, TTYC_KMOUS)) { + tty_raw(tty, "\033[?1000l\033[?1002l\033[?1003l"); + tty_raw(tty, "\033[?1006l\033[?1005l"); + } if (tty_term_flag(tty->term, TTYC_XT)) { if (tty->flags & TTY_FOCUS) { -- cgit