From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2205) id 19D3D3858409; Sat, 16 Dec 2023 09:38:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 19D3D3858409 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1702719534; bh=qrSPSIfSKy7LXlzo2Tz/a48FAKjKMc4CPRWQqXTBBr4=; h=From:To:Subject:Date:From; b=vrGbEpzyj7mydz2LY2yiz/i/WpYC/mSCilkqRoqe45mwuAR3B4j6PMX/F8Z+4J+FH 1qxYdlwbTgmHmOhEixmeUt+Mn8VpR5yzOkoGgkH96HalhUjN0SY65+L6iLUhv/ws/n itaRvEnKvk76pfFc7MP7uD0B69decaZ/sIrLTxXI= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom de Vries To: gdb-cvs@sourceware.org Subject: [binutils-gdb] [gdb/build] Remove dependency on _rl_term_autowrap X-Act-Checkin: binutils-gdb X-Git-Author: Tom de Vries X-Git-Refname: refs/heads/master X-Git-Oldrev: 86a6f9a9fb112614c15cc17630b29fbc62d3bca5 X-Git-Newrev: 14e61dbbbbb50e2b48834ba489942931514e7ff5 Message-Id: <20231216093854.19D3D3858409@sourceware.org> Date: Sat, 16 Dec 2023 09:38:54 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D14e61dbbbbb5= 0e2b48834ba489942931514e7ff5 commit 14e61dbbbbb50e2b48834ba489942931514e7ff5 Author: Tom de Vries Date: Sat Dec 16 10:39:17 2023 +0100 [gdb/build] Remove dependency on _rl_term_autowrap =20 Commit deb1ba4e38b ("[gdb/tui] Fix TUI resizing for TERM=3Dansi") intro= duced a dependency on readline private variable _rl_term_autowrap. =20 There is precedent for this, but it's something we want to get rid of (PR build/10723). =20 Remove the dependency on _rl_term_autowrap, and instead calculate readline_hidden_cols by comparing the environment variable COLS with co= ls as returned by rl_get_screen_size. =20 Tested on x86_64-linux. =20 Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D10723 Diff: --- gdb/utils.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/gdb/utils.c b/gdb/utils.c index 5ec8c5671f3..9ae9494d51d 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1110,10 +1110,6 @@ static bool filter_initialized =3D false; =20 =0C =20 -/* See readline's rlprivate.h. */ - -extern "C" int _rl_term_autowrap; - /* See utils.h. */ =20 int readline_hidden_cols =3D 0; @@ -1154,10 +1150,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 =3D=3D 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 =3D _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. */ + const char *columns_env_str =3D getenv ("COLUMNS"); + gdb_assert (columns_env_str !=3D nullptr); + int columns_env_val =3D atoi (columns_env_str); + gdb_assert (columns_env_val !=3D 0); + readline_hidden_cols =3D columns_env_val - cols; + gdb_assert (readline_hidden_cols >=3D 0); + gdb_assert (readline_hidden_cols <=3D 1); =20 lines_per_page =3D rows; chars_per_line =3D cols + readline_hidden_cols;