diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-08-17 16:54:12 +0100 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-08-17 16:54:12 +0100 |
commit | 8553b68c21502c75a75754c55aa9942917abd7d7 (patch) | |
tree | 50acdbb9d25a3214c8defadfc36fda7655f18135 /Porting/expand-macro.pl | |
parent | 6f3f41ca711fd6dbc2beafbe9b128ff0b066c73c (diff) | |
download | perl-8553b68c21502c75a75754c55aa9942917abd7d7.tar.gz |
Add an -X option to expand-macro.pl to show how XSUBs see the macro.
The default is to show macros as seen by the core.
Diffstat (limited to 'Porting/expand-macro.pl')
-rw-r--r-- | Porting/expand-macro.pl | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Porting/expand-macro.pl b/Porting/expand-macro.pl index b031f14d58..df2b002f1a 100644 --- a/Porting/expand-macro.pl +++ b/Porting/expand-macro.pl @@ -8,7 +8,7 @@ $Getopt::Std::STANDARD_HELP_VERSION = 1; my $trysource = "try.c"; my $tryout = "try.i"; -getopts('fF:ekvI:', \my %opt) or pod2usage(); +getopts('fF:ekvI:X', \my %opt) or pod2usage(); my($expr, @headers) = @ARGV ? splice @ARGV : "-"; @@ -54,13 +54,24 @@ open my $out, '>', $trysource or die "Can't open $trysource: $!"; my $sentinel = "$macro expands to"; -print $out <<"EOF"; -#include "EXTERN.h" -#include "perl.h" +my %done_header; + +sub do_header { + my $header = shift; + return if $done_header{$header}++; + print $out qq{#include "$header"\n}; +} + +print $out <<'EOF' if $opt{X}; +/* Need to do this like this, as cflags.sh sets it for us come what may. */ +#undef PERL_CORE + EOF -print $out qq{#include "$header"\n} - unless $header eq 'perl.h' or $header eq 'EXTERN.h'; +do_header('EXTERN.h'); +do_header('perl.h'); +do_header($header); +do_header('XSUB.h') if $opt{X}; print $out <<"EOF"; #line 4 "$sentinel" @@ -122,5 +133,6 @@ expand-macro.pl - expand C macros using the C preprocessor -k keep them after generating (for handy inspection) -v verbose -I <indent-opts> passed into indent + -X include "XSUB.h" (and undefine PERL_CORE) =cut |