This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Improve wrapping of arguments in perlintern.pod
authorFather Chrysostomos <sprout@cpan.org>
Sat, 16 Jul 2011 19:45:04 +0000 (12:45 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 16 Jul 2011 19:45:04 +0000 (12:45 -0700)
Commit dee6204dc made a huge improvement to the formatting of argument
lists in perlapi (except for one pesky little entry, namely caller_cx,
that is 81 columns).

But I forgot to look through perlintern.

This just looks comical:

                       struct refcounted_he * refcounted_he_new_pv(struct refcounted_he *parent,
                                                                   const char *key,
                                                                   U32 hash,
                                                                   SV *value,
                                                                   U32 flags)

On an eighty-column terminal that wraps like this:

                       struct refcounted_he * refcounted_he_new_pv(struct refcoun
ted_he *parent,
                                                                   const char *k
ey,
                                                                   U32 hash,
                                                                   SV *value,
                                                                   U32 flags)

Ugh!!

So, for entries with individual arguments that don’t fit, this commit
wraps them like this:

                       struct refcounted_he * refcounted_he_new_pv(
                                                  struct refcounted_he *parent,
                                                  const char *key, U32 hash,
                                                  SV *value, U32 flags
                                              )

autodoc.pl
t/porting/known_pod_issues.dat

index 4c1d962..89b36df 100644 (file)
@@ -195,8 +195,21 @@ removed without notice.\n\n" if $flags =~ /x/;
                          +length($n) + 1;
        my $indent;
        print $fh "\t$ret" . ($large_ret ? ' ' : "\t") . "$n(";
-       my $args = $p ? @args ? "pTHX_ " : "pTHX" : '';
-       my $first = 1;
+       my $long_args;
+       for (@args) {
+           if ($indent_size + 2 + length > 80) {
+               $long_args=1;
+               $indent_size -= length($n) - 3;
+               last;
+           }
+       }
+       my $args = '';
+       if ($p) {
+           $args = @args ? "pTHX_ " : "pTHX";
+           if ($long_args) { print $fh $args; $args = '' }
+       }
+       $long_args and print $fh "\n";
+       my $first = !$long_args;
        while () {
            if (!@args or
                 length $args
@@ -206,7 +219,7 @@ removed without notice.\n\n" if $flags =~ /x/;
                  $first ? '' : (
                    $indent //=
                       "\t".($large_ret ? " " x (1+length $ret) : "\t")
-                     ." "x(1 + length $n)
+                     ." "x($long_args ? 4 : 1 + length $n)
                  ),
                  $args, (","x($args ne 'pTHX_ ') . "\n")x!!@args;
                $args = $first = '';
@@ -215,6 +228,7 @@ removed without notice.\n\n" if $flags =~ /x/;
            $args .= ", "x!!(length $args && $args ne 'pTHX_ ')
                   . shift @args;
        }
+       if ($long_args) { print $fh "\n", substr $indent, 0, -4 }
        print $fh ")\n\n";
     }
     print $fh "=for hackers\nFound in file $file\n\n";
index b480189..938359a 100644 (file)
@@ -211,7 +211,7 @@ os2/os2/os2-rexx/rexx.pm    Verbatim line length including indents exceeds 80 by    1
 pod/perl.pod   Verbatim line length including indents exceeds 80 by    9
 pod/perlaix.pod        Verbatim line length including indents exceeds 80 by    11
 pod/perlapi.pod        ? Should you be using L<...> instead of 86
-pod/perlapi.pod        Verbatim line length including indents exceeds 80 by    24
+pod/perlapi.pod        Verbatim line length including indents exceeds 80 by    23
 pod/perlapi.pod        unresolved internal link        3
 pod/perlapio.pod       Verbatim line length including indents exceeds 80 by    5
 pod/perlbeos.pod       ? Should you be using F<...> or maybe L<...> instead of 5
@@ -246,7 +246,7 @@ pod/perlhist.pod    Verbatim line length including indents exceeds 80 by    2
 pod/perlhpux.pod       Verbatim line length including indents exceeds 80 by    2
 pod/perlhurd.pod       Verbatim line length including indents exceeds 80 by    2
 pod/perlintern.pod     ? Should you be using L<...> instead of 5
-pod/perlintern.pod     Verbatim line length including indents exceeds 80 by    17
+pod/perlintern.pod     Verbatim line length including indents exceeds 80 by    2
 pod/perlinterp.pod     ? Should you be using L<...> instead of 1
 pod/perlinterp.pod     Verbatim line length including indents exceeds 80 by    1
 pod/perlintro.pod      Verbatim line length including indents exceeds 80 by    11