From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy3-pub.mail.unifiedlayer.com (gproxy3-pub.mail.unifiedlayer.com [69.89.30.42]) by sourceware.org (Postfix) with ESMTPS id C528A385803D for ; Fri, 31 Dec 2021 22:25:31 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C528A385803D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com Received: from cmgw12.mail.unifiedlayer.com (unknown [10.0.90.127]) by progateway5.mail.pro1.eigbox.com (Postfix) with ESMTP id 33A811004B03A for ; Fri, 31 Dec 2021 22:25:31 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id 3QL4nA2jlXOyf3QL5n5fSr; Fri, 31 Dec 2021 22:25:31 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=Ot6Kdwzt c=1 sm=1 tr=0 ts=61cf835b a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=IOMw9HtfNCkA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=BhGoh4YZbOFwag41U6AA:9 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=MMMqegzt0V3hdYrx+kN+K5/4DWbND4dFVL0kckL0Iys=; b=Z7QtR+ictvIIRBa8w5dnCWInfQ hoiomK5cxxq4f9ITDNM2QDsBPfMxd1p9mSyrSbRJYDVArl73SN/7ZfKi9O611+aG+Yy4Bc+at2Mai 7MEXzWCUWvTEp2sS/j0onx/Tt; Received: from 75-166-134-30.hlrn.qwest.net ([75.166.134.30]:52048 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1n3QL4-003Nuh-FZ; Fri, 31 Dec 2021 15:25:30 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 2/4] Add ui_file::wrap_here Date: Fri, 31 Dec 2021 15:25:25 -0700 Message-Id: <20211231222527.2930519-3-tom@tromey.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211231222527.2930519-1-tom@tromey.com> References: <20211231222527.2930519-1-tom@tromey.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.134.30 X-Source-L: No X-Exim-ID: 1n3QL4-003Nuh-FZ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-134-30.hlrn.qwest.net (localhost.localdomain) [75.166.134.30]:52048 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3032.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 31 Dec 2021 22:25:33 -0000 Right now, wrap_here is a global function. In the long run, we'd like output streams to be relatively self-contained objects, and having a global function like this is counter to that goal. Also, existing code freely mixes writes to some parameterized stream with calls to wrap_here -- but wrap_here only really affects gdb_stdout, so this is also incoherent. This step is a patch toward making wrap_here more sane. It adds a wrap_here method to ui_file and changes ui_out implementations to use it. --- gdb/cli-out.c | 2 +- gdb/mi/mi-out.c | 2 +- gdb/ui-file.c | 6 ++++++ gdb/ui-file.h | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/gdb/cli-out.c b/gdb/cli-out.c index 68cf284cf44..02633e5bbbe 100644 --- a/gdb/cli-out.c +++ b/gdb/cli-out.c @@ -243,7 +243,7 @@ cli_ui_out::do_wrap_hint (int indent) if (m_suppress_output) return; - wrap_here (indent); + m_streams.back ()->wrap_here (indent); } void diff --git a/gdb/mi/mi-out.c b/gdb/mi/mi-out.c index 6c0d2f04e48..fe58adbbad5 100644 --- a/gdb/mi/mi-out.c +++ b/gdb/mi/mi-out.c @@ -174,7 +174,7 @@ mi_ui_out::do_message (const ui_file_style &style, void mi_ui_out::do_wrap_hint (int indent) { - wrap_here (indent); + m_streams.back ()->wrap_here (indent); } void diff --git a/gdb/ui-file.c b/gdb/ui-file.c index eb1d72bf8b3..bde90a9e6ed 100644 --- a/gdb/ui-file.c +++ b/gdb/ui-file.c @@ -68,6 +68,12 @@ ui_file::vprintf (const char *format, va_list args) vfprintf_unfiltered (this, format, args); } +void +ui_file::wrap_here (int indent) +{ + ::wrap_here (indent); +} + void diff --git a/gdb/ui-file.h b/gdb/ui-file.h index 0faf84996aa..4e72524b7f0 100644 --- a/gdb/ui-file.h +++ b/gdb/ui-file.h @@ -96,6 +96,23 @@ class ui_file default. */ return false; } + + /* Indicate that if the next sequence of characters overflows the + line, a newline should be inserted here rather than when it hits + the end. If INDENT is non-zero, it is a number of spaces to be + printed to indent the wrapped part on the next line. + + If the line is already overfull, we immediately print a newline and + the indentation, and disable further wrapping. + + If we don't know the width of lines, but we know the page height, + we must not wrap words, but should still keep track of newlines + that were explicitly printed. + + This routine is guaranteed to force out any output which has been + squirreled away in the wrap_buffer, so wrap_here (0) can be + used to force out output from the wrap_buffer. */ + void wrap_here (int indent); }; typedef std::unique_ptr ui_file_up; -- 2.31.1