From: Steffen Mueller Date: Fri, 11 Feb 2011 18:24:21 +0000 (+0100) Subject: Add method to get ANSIfied code X-Git-Tag: accepted/trunk/20130322.191538~3330^2~43 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16b42e0e2e1788788a0a658d6bf488a963fab1bb;p=platform%2Fupstream%2Fperl.git Add method to get ANSIfied code This is done to all of the code in EU::PXS anyway, so why not have a nice method for it? --- diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm index 9a1cdcd..8c28aec 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/InputMap.pm @@ -2,7 +2,6 @@ package ExtUtils::Typemaps::InputMap; use 5.006001; use strict; use warnings; -our $VERSION = '0.05'; use Carp qw(croak); =head1 NAME @@ -75,6 +74,26 @@ sub xstype { return $_[0]->{xstype}; } +=head2 cleaned_code + +Returns a cleaned-up copy of the code to which certain transformations +have been applied to make it more ANSI compliant. + +=cut + +sub cleaned_code { + my $self = shift; + my $code = $self->code; + + $code =~ s/;*\s+\z//; + + # Move C pre-processor instructions to column 1 to be strictly ANSI + # conformant. Some pre-processors are fussy about this. + $code =~ s/^\s+#/#/mg; + + return $code; +} + =head1 SEE ALSO L diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm index 3c04e1e..31b7312 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps/OutputMap.pm @@ -2,7 +2,6 @@ package ExtUtils::Typemaps::OutputMap; use 5.006001; use strict; use warnings; -our $VERSION = '0.05'; use Carp qw(croak); =head1 NAME @@ -75,6 +74,24 @@ sub xstype { return $_[0]->{xstype}; } +=head2 cleaned_code + +Returns a cleaned-up copy of the code to which certain transformations +have been applied to make it more ANSI compliant. + +=cut + +sub cleaned_code { + my $self = shift; + my $code = $self->code; + + # Move C pre-processor instructions to column 1 to be strictly ANSI + # conformant. Some pre-processors are fussy about this. + $code =~ s/^\s+#/#/mg; + + return $code; +} + =head1 SEE ALSO L