From: Steffen Mueller Date: Fri, 11 Feb 2011 13:37:33 +0000 (+0100) Subject: Reduce code duplication by using the same prototype regexp X-Git-Tag: accepted/trunk/20130322.191538~3330^2~49 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9c95e74bd07f99bfc0409e074db813bccf889131;p=platform%2Fupstream%2Fperl.git Reduce code duplication by using the same prototype regexp --- diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm index 8631063..1af0685 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/ParseXS/Constants.pm @@ -31,6 +31,8 @@ our $errors = 0; our $Fallback = '&PL_sv_undef'; # FIXME Check: Is this a constant? +# Note that to reduce maintenance, $PrototypeRegexp is used +# by ExtUtils::Typemaps, too! our $PrototypeRegexp = "[" . quotemeta('\$%&*@;[]_') . "]"; our @XSKeywords = qw( REQUIRE BOOT CASE PREINIT INPUT INIT CODE PPCODE diff --git a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm index cfda24b..c049cbe 100644 --- a/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm +++ b/dist/ExtUtils-ParseXS/lib/ExtUtils/Typemaps.pm @@ -5,8 +5,8 @@ use warnings; our $VERSION = '1.00'; use Carp qw(croak); -our $Proto_Regexp = "[" . quotemeta('\$%&*@;[]_') . "]"; # TODO: Use ExtUtils::ParseXS' constant instead - +require ExtUtils::ParseXS; +require ExtUtils::ParseXS::Constants; require ExtUtils::Typemaps::InputMap; require ExtUtils::Typemaps::OutputMap; require ExtUtils::Typemaps::Type; @@ -486,7 +486,7 @@ sub as_string { push @code, "TYPEMAP\n"; foreach my $entry (@$typemap) { # type kind proto - # /^(.*?\S)\s+(\S+)\s*($Proto_Regexp*)$/o + # /^(.*?\S)\s+(\S+)\s*($ExtUtils::ParseXS::Constants::PrototypeRegexp*)$/o push @code, $entry->ctype . "\t" . $entry->xstype . ($entry->proto ne '' ? "\t".$entry->proto : '') . "\n"; } @@ -615,7 +615,7 @@ sub _parse { my $line = $_; s/^\s+//; s/\s+$//; next if /^#/ or /^$/; - my($type, $kind, $proto) = /^(.*?\S)\s+(\S+)\s*($Proto_Regexp*)$/o + my($type, $kind, $proto) = /^(.*?\S)\s+(\S+)\s*($ExtUtils::ParseXS::Constants::PrototypeRegexp*)$/o or warn("Warning: File '$filename' Line $lineno '$line' TYPEMAP entry needs 2 or 3 columns\n"), next; #$proto = '' if not $proto; @@ -675,7 +675,7 @@ sub _tidy_type { # taken from ExtUtils::ParseXS sub _valid_proto_string { my $string = shift; - if ($string =~ /^$Proto_Regexp+$/o) { + if ($string =~ /^$ExtUtils::ParseXS::Constants::PrototypeRegexp+$/o) { return $string; }