Author: stas Date: Sat Nov 27 10:09:53 2004 New Revision: 106735 URL: http://svn.apache.org/viewcvs?view=rev&rev=106735 Log: some fixes to make C::Scan not complain on apache sources
Modified: perl/modperl/trunk/lib/ModPerl/CScan.pm Modified: perl/modperl/trunk/lib/ModPerl/CScan.pm Url: http://svn.apache.org/viewcvs/perl/modperl/trunk/lib/ModPerl/CScan.pm?view=diff&rev=106735&p1=perl/modperl/trunk/lib/ModPerl/CScan.pm&r1=106734&p2=perl/modperl/trunk/lib/ModPerl/CScan.pm&r2=106735 ============================================================================== --- perl/modperl/trunk/lib/ModPerl/CScan.pm (original) +++ perl/modperl/trunk/lib/ModPerl/CScan.pm Sat Nov 27 10:09:53 2004 @@ -660,17 +660,28 @@ unless ($out =~ /\w/) { # Probably a function-type declaration: typedef int f(int); # Redo scan leaving the last word of the first group of words: - $tout =~ /(\w+\s+)*(\w+)\s*\(/g; - $out = ' ' x (pos($tout) - length $2) - . $2 . ' ' x (length($tout) - pos($tout)); - # warn "function typedef\n\t'$in'\nwhited-out as\n\t'$out'\n"; + if ($tout =~ /(\w+\s+)*(\w+)\s*\(/g) { + $out = ' ' x (pos($tout) - length $2) + . $2 . ' ' x (length($tout) - pos($tout)); + } + else { + # try a different approach to get the last type + my $len = length $tout; + # cut all non-words at the end of the definition + my $end = $tout =~ s/(\W*)$// ? length $1 : 0; + # remove everything but the last word + my $mid = $tout =~ s/.*?(\w*)$/$1/ ? length $1 : 0; + # restore the length + $out = $tout . ' ' x ($len - $mid); + } + # warn "function typedef\n\t'$in'\nwhited-out as\n\t'$out'\n"; } warn "panic: length mismatch\n\t'$in'\nwhited-out as\n\t'$out'\n" if length($in) != length $out; # Sanity check - warn "panic: multiple types without intervening comma in\n\t$in\nwhited-out as\n\t$out\n" + warn "panic: multiple types without intervening comma in\n\t'$in'\nwhited-out as\n\t'$out'\n" if $out =~ /\w[^\w,]+\w/; - warn "panic: no types found in\n\t$in\nwhited-out as\n\t$out\n" + warn "panic: no types found in\n\t'$in'\nwhited-out as\n\t'$out'\n" unless $out =~ /\w/; $out }