From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gproxy2-pub.mail.unifiedlayer.com (gproxy2-pub.mail.unifiedlayer.com [69.89.18.3]) by sourceware.org (Postfix) with ESMTPS id EC6633857B93 for ; Fri, 17 Feb 2023 19:29:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EC6633857B93 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 cmgw15.mail.unifiedlayer.com (unknown [10.0.90.130]) by progateway4.mail.pro1.eigbox.com (Postfix) with ESMTP id 5B22910047A49 for ; Fri, 17 Feb 2023 19:29:16 +0000 (UTC) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTP id T6Q0ptsoOaJXNT6Q0p9bgV; Fri, 17 Feb 2023 19:29:16 +0000 X-Authority-Reason: nr=8 X-Authority-Analysis: v=2.4 cv=ZpQol/3G c=1 sm=1 tr=0 ts=63efd58c a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=dLZJa+xiwSxG16/P+YVxDGlgEgI=:19 a=m04uMKEZRckA:10:nop_rcvd_month_year a=Qbun_eYptAEA:10:endurance_base64_authed_username_1 a=zstS-IiYAAAA:8 a=gv_ASkQVD69oEhmg_GEA:9 a=4G6NA9xxw8l3yy4pmD5M:22 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=m+NCPlDaVxFj+mFpNANrx8DVKxwUSpQl/+CufRQvx3A=; b=Nipy79rLLq4o+YoeIATpDYYdNw vA+jhCThSEtl4Ft/NBb26KOUM/TpwX31PJhtSENNw7UWUddFP2xX00cfBluO+8lwPw8jaHSgF/Cz0 ltnvN7ZJAdW/1zkF2mWdJ/x4X; Received: from 75-166-130-93.hlrn.qwest.net ([75.166.130.93]:37066 helo=localhost.localdomain) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1pT6Q0-002oM4-0g; Fri, 17 Feb 2023 12:29:16 -0700 From: Tom Tromey To: binutils@sourceware.org Cc: Tom Tromey Subject: [PATCH 1/4] Fix formatting of long function description in chew output Date: Fri, 17 Feb 2023 12:29:02 -0700 Message-Id: <20230217192905.3160819-2-tom@tromey.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230217192905.3160819-1-tom@tromey.com> References: <20230217192905.3160819-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.130.93 X-Source-L: No X-Exim-ID: 1pT6Q0-002oM4-0g X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-130-93.hlrn.qwest.net (localhost.localdomain) [75.166.130.93]:37066 X-Source-Auth: tom+tromey.com X-Email-Count: 2 X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-Spam-Status: No, score=-3025.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Currently, if a function description spans a line, the resulting info can look like this: -- Function: long bfd_canonicalize_reloc (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); Call the back end associated with the open BFD ABFD and translate the external form of the relocation information attached to SEC into the internal canonical form. Place the table into memory at LOC, That is, the function prototype runs together with the text in an ugly way. This patch fixes this by introducing a new primitive, so that the generated Texinfo can be a bit nicer. Now this output looks like: -- Function: long bfd_canonicalize_reloc (bfd *abfd, asection *sec, arelent **loc, asymbol **syms); Call the back end associated with the open BFD ABFD and translate the external form of the relocation information attached to SEC bfd/ChangeLog 2023-02-17 Tom Tromey * doc/doc.str (SYNOPSIS): Use collapse_whitespace. * doc/chew.c (collapse_whitespace): New function. (main): Register collapse_whitespace. --- bfd/ChangeLog | 6 ++++++ bfd/doc/chew.c | 33 +++++++++++++++++++++++++++++++++ bfd/doc/doc.str | 2 ++ 3 files changed, 41 insertions(+) diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c index 19e3781bdda..eca9305fee0 100644 --- a/bfd/doc/chew.c +++ b/bfd/doc/chew.c @@ -884,6 +884,38 @@ kill_bogus_lines (void) } +static void +collapse_whitespace (void) +{ + int last_was_ws = 0; + int idx; + + string_type out; + init_string (&out); + + for (idx = 0; at (tos, idx) != 0; ++idx) + { + char c = at (tos, idx); + if (isspace (c)) + { + if (!last_was_ws) + { + catchar (&out, ' '); + last_was_ws = 1; + } + } + else + { + catchar (&out, c); + last_was_ws = 0; + } + } + + pc++; + delete_string (tos); + *tos = out; +} + static void indent (void) { @@ -1479,6 +1511,7 @@ main (int ac, char *av[]) add_intrinsic ("indent", indent); add_intrinsic ("print_stack_level", print_stack_level); add_intrinsic ("strip_trailing_newlines", strip_trailing_newlines); + add_intrinsic ("collapse_whitespace", collapse_whitespace); internal_mode = xmalloc (sizeof (intptr_t)); *internal_mode = 0; diff --git a/bfd/doc/doc.str b/bfd/doc/doc.str index 2a0953a3ece..5077ada9812 100644 --- a/bfd/doc/doc.str +++ b/bfd/doc/doc.str @@ -55,8 +55,10 @@ variable synopsis_seen "@deftypefn {Function} " catstr get_stuff_in_command kill_bogus_lines + collapse_whitespace indent catstr + "\n" catstr ; : func -- 2.39.1