summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-06-11 14:22:55 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2004-06-11 14:22:55 +0000
commite77cf69f69c718be579e56562724518750ab0766 (patch)
tree9b3e850f8ff5ec8627a1db1ac9204da8662554ba /utils
parent0e885527258c31e904926227adc84e71c6d0d687 (diff)
downloadperl-e77cf69f69c718be579e56562724518750ab0766.tar.gz
More h2ph tweaks: recognition of C types
p4raw-id: //depot/perl@22930
Diffstat (limited to 'utils')
-rw-r--r--utils/h2ph.PL41
1 files changed, 23 insertions, 18 deletions
diff --git a/utils/h2ph.PL b/utils/h2ph.PL
index e501067ff8..2e1c499e55 100644
--- a/utils/h2ph.PL
+++ b/utils/h2ph.PL
@@ -58,13 +58,14 @@ my $Dest_dir = $opt_d || $Config{installsitearch};
die "Destination directory $Dest_dir doesn't exist or isn't a directory\n"
unless -d $Dest_dir;
-my @isatype = split(' ',<<END);
+my @isatype = qw(
char uchar u_char
short ushort u_short
int uint u_int
long ulong u_long
FILE key_t caddr_t
-END
+ float double size_t
+);
my %isatype;
@isatype{@isatype} = (1) x @isatype;
@@ -343,22 +344,26 @@ while (defined (my $file = next_file())) {
expr();
# try to find and perlify local C variables
our @local_variables = (); # needs to be a our(): (?{...}) bug workaround
- $new =~ s['
- (?:(?:un)?signed\s+)?
- (?:long\s+)?
- (?:long|int|float|double|char|\w+_t)\s+
- (\w+)
- (?{ push @local_variables, $1 })
- ']
- [my \$$1]gx;
- $new =~ s['
- (?:(?:un)?signed\s+)?
- (?:long\s+)?
- (?:long|int|float|double|char|\w+_t)
- ' \s+ &(\w+) \s* ;
- (?{ push @local_variables, $1 })
- ]
- [my \$$1;]gx;
+ {
+ use re "eval";
+ my $typelist = join '|', keys %isatype;
+ $new =~ s['
+ (?:(?:un)?signed\s+)?
+ (?:long\s+)?
+ (?:$typelist)\s+
+ (\w+)
+ (?{ push @local_variables, $1 })
+ ']
+ [my \$$1]gx;
+ $new =~ s['
+ (?:(?:un)?signed\s+)?
+ (?:long\s+)?
+ (?:$typelist)\s+
+ ' \s+ &(\w+) \s* ;
+ (?{ push @local_variables, $1 })
+ ]
+ [my \$$1;]gx;
+ }
$new =~ s/&$_\b/\$$_/g for @local_variables;
$new =~ s/(["\\])/\\$1/g; #"]);
# now that's almost like a macro (we hope)