From dbb4a6b592df08d6263af38c4857c55acb540352 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Mon, 1 May 2023 07:19:33 +0200 Subject: [PATCH] [gdb/build] Remove dependency on _rl_term_autowrap Commit deb1ba4e38b ("[gdb/tui] Fix TUI resizing for TERM=ansi") introduced a dependency on readline private variable _rl_term_autowrap. There is precedent for this, but it's something we want to get rid of (PR build/10723). Remove the dependency on _rl_term_autowrap, and instead calculate readline_hidden_cols by comparing the environment variable COLS with cols as returned by rl_get_screen_size. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=10723 --- gdb/utils.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gdb/utils.c b/gdb/utils.c index e10198accd0..8738d3fc7e4 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1116,10 +1116,6 @@ static bool filter_initialized = false; -/* See readline's rlprivate.h. */ - -EXTERN_C int _rl_term_autowrap; - /* See utils.h. */ int readline_hidden_cols = 0; @@ -1160,10 +1156,17 @@ init_page_info (void) (because rl_change_environment defaults to 1) - may report one less than the detected screen width in rl_get_screen_size (when _rl_term_autowrap == 0). - We could set readline_hidden_cols by comparing COLUMNS to cols as - returned by rl_get_screen_size, but instead simply use - _rl_term_autowrap. */ - readline_hidden_cols = _rl_term_autowrap ? 0 : 1; + We could use _rl_term_autowrap, but we want to avoid introducing + another dependency on readline private variables, so set + readline_hidden_cols by comparing COLUMNS to cols as returned by + rl_get_screen_size. */ + char *columns_env_str = getenv ("COLUMNS"); + gdb_assert (columns_env_str != nullptr); + int columns_env_val = atoi (columns_env_str); + gdb_assert (columns_env_val != 0); + readline_hidden_cols = columns_env_val - cols; + gdb_assert (readline_hidden_cols >= 0); + gdb_assert (readline_hidden_cols <= 1); lines_per_page = rows; chars_per_line = cols; base-commit: 077a1f08485e88f3b234af1dbb8b907b16045e6a -- 2.35.3