Change 34527 by [EMAIL PROTECTED] on 2008/10/20 14:09:36

        Integrate:
        [ 34348]
        Skip another file in the VERSION comparison program
        
        [ 34391]
        Skip another module from the VERSION comparison checks
        
        [ 34473]
        Make sure expand-macro.pl also works for macros in headers
        that are not included by perl.h (like regcomp.h).
        
        [ 34474]
        Make expand-macro.pl accept macro expressions, i.e. macros with
        arguments. This makes it much more convenient to get expanded
        expressions that can be directly copied to a debugger. This is
        optional, so the original behaviour is maintained. Allow to read
        the macro name or expression from stdin, which can be useful for
        feeding it multi-line macro expressions. Use Pod::Usage and move
        the usage to POD section.

Affected files ...

... //depot/maint-5.10/perl/Porting/cmpVERSION.pl#2 integrate
... //depot/maint-5.10/perl/Porting/expand-macro.pl#3 integrate

Differences ...

==== //depot/maint-5.10/perl/Porting/cmpVERSION.pl#2 (text) ====
Index: perl/Porting/cmpVERSION.pl
--- perl/Porting/cmpVERSION.pl#1~32694~ 2007-12-22 01:23:09.000000000 -0800
+++ perl/Porting/cmpVERSION.pl  2008-10-20 07:09:36.000000000 -0700
@@ -25,7 +25,11 @@
 # Files to skip from the check for one reason or another,
 # usually because they pull in their version from some other file.
 my %skip;
[EMAIL PROTECTED]'./lib/Exporter/Heavy.pm'} = ();
[EMAIL PROTECTED]
+    './lib/Carp/Heavy.pm',
+    './lib/Exporter/Heavy.pm',
+    './win32/FindExt.pm'
+} = ();
 
 my @wanted;
 find(

==== //depot/maint-5.10/perl/Porting/expand-macro.pl#3 (text) ====
Index: perl/Porting/expand-macro.pl
--- perl/Porting/expand-macro.pl#2~33617~       2008-03-31 12:23:09.000000000 
-0700
+++ perl/Porting/expand-macro.pl        2008-10-20 07:09:36.000000000 -0700
@@ -1,70 +1,63 @@
 #!perl -w
 use strict;
 
+use Pod::Usage;
 use Getopt::Std;
+$Getopt::Std::STANDARD_HELP_VERSION = 1;
 
-use vars qw($trysource $tryout $sentinel);
-$trysource = "try.c";
-$tryout = "try.i";
-
-getopts('fF:ekvI:', \my %opt) or usage();
-
-sub usage {
-    die<<EO_HELP;
[EMAIL PROTECTED];
-usage: $0 [options] <macro-name> [headers]
-options:
-    -f         use 'indent' to format output
-    -F <tool>  use <tool> to format output  (instead of -f)
-    -e         erase try.[ic] instead of failing when theyre present 
(errdetect)
-    -k         keep them after generating (for handy inspection)
-    -v         verbose
-    -I <indent-opts>   passed into indent
-EO_HELP
-}
+my $trysource = "try.c";
+my $tryout = "try.i";
 
-my $macro = shift;
-usage "missing <macro-name>" unless defined $macro;
+getopts('fF:ekvI:', \my %opt) or pod2usage();
 
-$sentinel = "$macro expands to";
+my($expr, @headers) = @ARGV ? splice @ARGV : "-";
 
-usage "-f and -F <tool> are exclusive\n" if $opt{f} and $opt{F};
+pod2usage "-f and -F <tool> are exclusive\n" if $opt{f} and $opt{F};
 
 foreach($trysource, $tryout) {
     unlink $_ if $opt{e};
     die "You already have a $_" if -e $_;
 }
 
-if ([EMAIL PROTECTED]) {
+if ($expr eq '-') {
+    warn "reading from stdin...\n";
+    $expr = do { local $/; <> };
+}
+
+my($macro, $args) = $expr =~ /^\s*(\w+)((?:\s*\(.*\))?)\s*;?\s*$/s
+    or pod2usage "$expr doesn't look like a macro-name or macro-expression to 
me";
+
+if (!(@ARGV = @headers)) {
     open my $fh, '<', 'MANIFEST' or die "Can't open MANIFEST: $!";
     while (<$fh>) {
        push @ARGV, $1 if m!^([^/]+\.h)\t!;
     }
 }
 
-my $args = '';
-
-my $found_macro;
+my $header;
 while (<>) {
     next unless /^#\s*define\s+$macro\b/;
     my ($def_args) = /^#\s*define\s+$macro\(([^)]*)\)/;
-    if (defined $def_args) {
+    if (defined $def_args && !$args) {
        my @args = split ',', $def_args;
        print "# macro: $macro args: @args in $_\n" if $opt{v};
        my $argname = "A0";
        $args = '(' . join (', ', map {$argname++} [EMAIL PROTECTED]) . ')';
     }
-    $found_macro++;
+    $header = $ARGV;
     last;
 }
-die "$macro not found\n" unless $found_macro;
+die "$macro not found\n" unless defined $header;
 
 open my $out, '>', $trysource or die "Can't open $trysource: $!";
 
+my $sentinel = "$macro expands to";
+
 print $out <<"EOF";
 #include "EXTERN.h"
 #include "perl.h"
-#line 3 "$sentinel"
+#include "$header"
+#line 4 "$sentinel"
 $macro$args
 EOF
 
@@ -105,3 +98,23 @@
        die "Can't unlink $_" unless unlink $_;
     }
 }
+
+__END__
+
+=head1 NAME
+
+expand-macro.pl - expand C macros using the C preprocessor
+
+=head1 SYNOPSIS
+
+  expand-macro.pl [options] [ < macro-name | macro-expression | - > [headers] ]
+
+  options:
+    -f         use 'indent' to format output
+    -F <tool>  use <tool> to format output  (instead of -f)
+    -e         erase try.[ic] instead of failing when they're present 
(errdetect)
+    -k         keep them after generating (for handy inspection)
+    -v         verbose
+    -I <indent-opts>   passed into indent
+
+=cut
End of Patch.

Reply via email to