From: Nicholas Clark Date: Fri, 17 Apr 2009 09:37:01 +0000 (+0100) Subject: In autodoc.pl, inline and hence eliminate walk_table(). X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=bc35008162d60af30a2b2bc397dbcb4ae872f26a;p=p5sagit%2Fp5-mst-13.2.git In autodoc.pl, inline and hence eliminate walk_table(). This simplifies the code considerably, as walk_table() was relying on its & prototype to cause the block after it to be co-erced to a passed in subroutine. --- diff --git a/autodoc.pl b/autodoc.pl index 0e8258f..502f6ab 100644 --- a/autodoc.pl +++ b/autodoc.pl @@ -17,33 +17,6 @@ use strict; # implicit interpreter context argument. # -open IN, "embed.fnc" or die $!; - -# walk table providing an array of components in each line to -# subroutine, printing the result -sub walk_table (&@) { - my $function = shift; - seek IN, 0, 0; # so we may restart - while () { - chomp; - next if /^:/; - while (s|\\\s*$||) { - $_ .= ; - chomp; - } - s/\s+$//; - my @args; - if (/^\s*(#|$)/) { - @args = $_; - } - else { - @args = split /\s*\|\s*/, $_; - } - s/\b(NN|NULLOK)\b\s+//g for @args; - $function->(@args); - } -} - my %apidocs; my %gutsdocs; my %docfuncs; @@ -166,30 +139,47 @@ for $file (($MANIFEST =~ /^(\S+\.c)\t/gm), ($MANIFEST =~ /^(\S+\.h)\t/gm)) { safer_unlink "pod/perlapi.pod"; my $doc = safer_open("pod/perlapi.pod"); -walk_table { # load documented functions into appropriate hash - if (@_ > 1) { - my($flags, $retval, $func, @args) = @_; - return "" unless $flags =~ /d/; - $func =~ s/\t//g; $flags =~ s/p//; # clean up fields from embed.pl - $retval =~ s/\t//; - my $docref = delete $docfuncs{$func}; - $seenfuncs{$func} = 1; - if ($docref and @$docref) { - if ($flags =~ /A/) { - $docref->[0].="x" if $flags =~ /M/; - $apidocs{$docref->[4]}{$func} = - [$docref->[0] . 'A', $docref->[1], $retval, $docref->[3], - @args]; - } else { - $gutsdocs{$docref->[4]}{$func} = - [$docref->[0], $docref->[1], $retval, $docref->[3], @args]; - } - } - else { - warn "no docs for $func\n" unless $seenfuncs{$func}; +open IN, "embed.fnc" or die $!; + +# walk table providing an array of components in each line to +# subroutine, printing the result + +while () { + chomp; + next if /^:/; + while (s|\\\s*$||) { + $_ .= ; + chomp; + } + s/\s+$//; + next if /^\s*(#|$)/; + + my ($flags, $retval, $func, @args) = split /\s*\|\s*/, $_; + + next unless $flags =~ /d/; + next unless $func; + + s/\b(NN|NULLOK)\b\s+//g for @args; + $func =~ s/\t//g; # clean up fields from embed.pl + $retval =~ s/\t//; + + my $docref = delete $docfuncs{$func}; + $seenfuncs{$func} = 1; + if ($docref and @$docref) { + if ($flags =~ /A/) { + $docref->[0].="x" if $flags =~ /M/; + $apidocs{$docref->[4]}{$func} = + [$docref->[0] . 'A', $docref->[1], $retval, $docref->[3], + @args]; + } else { + $gutsdocs{$docref->[4]}{$func} = + [$docref->[0], $docref->[1], $retval, $docref->[3], @args]; } } -}; + else { + warn "no docs for $func\n" unless $seenfuncs{$func}; + } +} for (sort keys %docfuncs) { # Have you used a full for apidoc or just a func name?