From: Pádraig Brady Date: Wed, 5 Feb 2025 12:00:22 +0000 (+0000) Subject: doc: sync help2man to latest version X-Git-Tag: v9.7~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32125782a6166213f5bcb4c2499ba96d50c3763d;p=thirdparty%2Fcoreutils.git doc: sync help2man to latest version * man/help2man: sync changes to commit 8fe02612 The main change here is to Use \f(CR for monospace text when using groff in troff mode. Previously \f(CW was used, but that's not portable. --- diff --git a/man/help2man b/man/help2man index 331feb02d5..960eebcae2 100755 --- a/man/help2man +++ b/man/help2man @@ -2,8 +2,8 @@ # Generate a short man page from --help and --version output. # Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, -# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021, 2022 Free Software -# Foundation, Inc. +# 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021, 2022, 2025 +# Free Software Foundation, Inc. # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ use Text::Tabs qw(expand); use POSIX qw(strftime setlocale LC_ALL); my $this_program = 'help2man'; -my $this_version = '1.49.3'; +my $this_version = '1.50.1'; sub _ { $_[0] } sub configure_locale @@ -49,13 +49,14 @@ sub program_basename; sub get_option_value; sub convert_option; sub fix_italic_spacing; +sub set_indent; my $version_info = enc_user sprintf _(<<'EOT'), $this_program, $this_version; GNU %s %s Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2009, -2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021, 2022 Free Software -Foundation, Inc. +2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2020, 2021, 2022, 2025 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. @@ -78,6 +79,7 @@ Usage: %s [OPTION]... EXECUTABLE -p, --info-page=TEXT name of Texinfo manual -N, --no-info suppress pointer to Texinfo manual -l, --libtool exclude the `lt-' from the program name + --loose-indent relax matching of indented continuation lines -b, --bold-refs apply bold style to references --help print this help, then exit --version print version number, then exit @@ -87,8 +89,8 @@ stdout although alternatives may be specified using: -h, --help-option=STRING help option string -v, --version-option=STRING version option string - --version-string=STRING version string - --no-discard-stderr include stderr when parsing option output + --version-string=STRING version string + --no-discard-stderr include stderr when parsing option output Report bugs to . EOT @@ -98,6 +100,7 @@ my $manual = ''; my $source = ''; my $help_option = '--help'; my $version_option = '--version'; +my $loose_indent = 0; my $discard_stderr = 1; my ($opt_name, @opt_include, $opt_output, $opt_info, $opt_no_info, $opt_libtool, $opt_bold_refs, $version_text); @@ -114,6 +117,7 @@ my %opt_def = ( 'p|info-page=s' => \$opt_info, 'N|no-info' => \$opt_no_info, 'l|libtool' => \$opt_libtool, + 'loose-indent!' => \$loose_indent, 'b|bold-refs' => \$opt_bold_refs, 'help' => sub { print $help_info; exit }, 'version' => sub { print $version_info; exit }, @@ -442,6 +446,7 @@ s/([^\n])\n($PAT_BUGS|$PAT_AUTHOR|$PAT_SEE_ALSO) /$1\n\n$2 /og; # character. s/^Copyright +(?:\xa9|\([Cc]\))/Copyright \\(co/mg; +my $require_mono = 0; while (length) { # Convert some standard paragraph names. @@ -500,15 +505,16 @@ while (length) } # Examples, indicated by an indented leading $, % or > are - # rendered in a constant width font. + # rendered in a monospace font when using groff in troff mode. if (/^( +)([\$\%>] )\S/) { - my $indent = $1; + my $spaces = $1; my $prefix = $2; my $break = '.IP'; - while (s/^$indent\Q$prefix\E(\S.*)\n*//) + while (s/^$spaces\Q$prefix\E(\S.*)\n*//) { - $include{$sect} .= "$break\n\\f(CW$prefix$1\\fR\n"; + $include{$sect} .= "$break\n\\*[mono]$prefix$1\\*[/mono]\n"; + $require_mono++; $break = '.br'; } @@ -531,12 +537,12 @@ while (length) if (s/^( {1,10}([+-]\S.*?))(?:( +(?!-))|\n( {20,}))(\S.*)\n//) { $matched .= $& if %append_match; - $indent = length ($4 || "$1$3"); + $indent = set_indent length ($4 || "$1$3"); $content = ".TP\n\x84$2\n\x84$5\n"; unless ($4) { # Indent may be different on second line. - $indent = length $& if /^ {20,}/; + $indent = set_indent length $& if /^ {20,}/; } } @@ -552,7 +558,7 @@ while (length) elsif (s/^( +(\S.*?) +)(\S.*)\n//) { $matched .= $& if %append_match; - $indent = length $1; + $indent = set_indent length $1; $content = ".TP\n\x84$2\n\x84$3\n"; } @@ -560,7 +566,7 @@ while (length) elsif (s/^( +)(\S.*)\n//) { $matched .= $& if %append_match; - $indent = length $1; + $indent = set_indent length $1; $content = ".IP\n\x84$2\n"; } @@ -681,7 +687,8 @@ EOT # Append additional text. while (my ($sect, $text) = each %append) { - $include{$sect} .= $append{$sect}; + $require_mono++ if $text =~ /\\\*\[mono\]/; + $include{$sect} .= $text; } # Replace sections. @@ -696,6 +703,15 @@ print enc <