From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 7EA8A3858C52; Mon, 20 Feb 2023 21:35:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EA8A3858C52 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: bfd-cvs@sourceware.org Subject: [binutils-gdb] Fix formatting of long function description in chew output X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: c22ff449275c91e4842bb10c650e83c572580f65 X-Git-Newrev: ee0e1723013527bfea4116f2fb8428add2e5343c Message-Id: <20230220213551.7EA8A3858C52@sourceware.org> Date: Mon, 20 Feb 2023 21:35:51 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Feb 2023 21:35:51 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dee0e17230135= 27bfea4116f2fb8428add2e5343c commit ee0e1723013527bfea4116f2fb8428add2e5343c Author: Tom Tromey Date: Fri Feb 17 12:12:11 2023 -0700 Fix formatting of long function description in chew output =20 Currently, if a function description spans a line, the resulting info can look like this: =20 -- 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, =20 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: =20 -- 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 =20 2023-02-17 Tom Tromey =20 * doc/doc.str (SYNOPSIS): Use collapse_whitespace. * doc/chew.c (collapse_whitespace): New function. (main): Register collapse_whitespace. Diff: --- bfd/ChangeLog | 6 ++++++ bfd/doc/chew.c | 33 +++++++++++++++++++++++++++++++++ bfd/doc/doc.str | 2 ++ 3 files changed, 41 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index e160e4472df..2b487818721 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,9 @@ +2023-02-17 Tom Tromey + + * doc/doc.str (SYNOPSIS): Use collapse_whitespace. + * doc/chew.c (collapse_whitespace): New function. + (main): Register collapse_whitespace. + 2023-02-07 Tom Tromey =20 * bfd.c, cache.c, compress.c, opncls.c: Remove RETURNS from diff --git a/bfd/doc/chew.c b/bfd/doc/chew.c index cd399697abd..e8478969d64 100644 --- a/bfd/doc/chew.c +++ b/bfd/doc/chew.c @@ -884,6 +884,38 @@ kill_bogus_lines (void) =20 } =20 +static void +collapse_whitespace (void) +{ + int last_was_ws =3D 0; + int idx; + + string_type out; + init_string (&out); + + for (idx =3D 0; at (tos, idx) !=3D 0; ++idx) + { + char c =3D at (tos, idx); + if (isspace (c)) + { + if (!last_was_ws) + { + catchar (&out, ' '); + last_was_ws =3D 1; + } + } + else + { + catchar (&out, c); + last_was_ws =3D 0; + } + } + + pc++; + delete_string (tos); + *tos =3D out; +} + static void indent (void) { @@ -1485,6 +1517,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); =20 internal_mode =3D xmalloc (sizeof (intptr_t)); *internal_mode =3D 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 =20 kill_bogus_lines + collapse_whitespace indent catstr + "\n" catstr ; =20 : func