public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tom de Vries <vries@sourceware.org>
To: gdb-cvs@sourceware.org
Subject: [binutils-gdb] [gdb/build] Remove dependency on _rl_term_autowrap
Date: Sat, 16 Dec 2023 09:38:54 +0000 (GMT)	[thread overview]
Message-ID: <20231216093854.19D3D3858409@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=14e61dbbbbb50e2b48834ba489942931514e7ff5

commit 14e61dbbbbb50e2b48834ba489942931514e7ff5
Author: Tom de Vries <tdevries@suse.de>
Date:   Sat Dec 16 10:39:17 2023 +0100

    [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

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 = false;
 
 \f
 
-/* See readline's rlprivate.h.  */
-
-extern "C" int _rl_term_autowrap;
-
 /* See utils.h.  */
 
 int readline_hidden_cols = 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 == 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.  */
+      const 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 + readline_hidden_cols;

                 reply	other threads:[~2023-12-16  9:38 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231216093854.19D3D3858409@sourceware.org \
    --to=vries@sourceware.org \
    --cc=gdb-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).