summaryrefslogtreecommitdiff
path: root/genpacksizetables.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2005-01-27 17:29:04 +0000
committerNicholas Clark <nick@ccl4.org>2005-01-27 17:29:04 +0000
commit7212898e16d553139d9eb78509677120af2b98db (patch)
tree940c06a8dd48afa6fb7e4f18c0e41567afd9126e /genpacksizetables.pl
parentefb78d13e88f09e1c42f464b0f2a4b96748960bb (diff)
downloadperl-7212898e16d553139d9eb78509677120af2b98db.tar.gz
Make the byte order modifers < and > and the sign modifier ! (for
n N v V) conditionally compile. This means that the refactored pp_pack/pp_unpack code can now be used in maint. p4raw-id: //depot/perl@23889
Diffstat (limited to 'genpacksizetables.pl')
-rwxr-xr-xgenpacksizetables.pl23
1 files changed, 14 insertions, 9 deletions
diff --git a/genpacksizetables.pl b/genpacksizetables.pl
index 334dece2c3..b3e3a8c39c 100755
--- a/genpacksizetables.pl
+++ b/genpacksizetables.pl
@@ -51,17 +51,22 @@ sub output_tables {
print "unsigned char size_${arrayname}[", scalar @$array, "] = {\n";
my @lines;
foreach (@$array) {
- # There is an assumption here that the last entry isn't conditonal
+ # Remove the assumption here that the last entry isn't conditonal
if (ref $_) {
- push @lines, "#if $_->[0]", " $_->[1]", "#else", " 0,", "#endif";
+ push @lines,
+ ["#if $_->[0]", " $_->[1]", "#else", " 0,", "#endif"];
} else {
push @lines, $_ ? " $_" : " 0,";
}
}
# remove the last, annoying, comma
- die "Last entry was a conditional: '$lines[$#lines]'"
- unless $lines[$#lines] =~ s/,$//;
- print "$_\n" foreach @lines;
+ my $last = $lines[$#lines];
+ my $got;
+ foreach (ref $last ? @$last : $last) {
+ $got += s/,$//;
+ }
+ die "Last entry had no commas" unless $got;
+ print map {"$_\n"} ref $_ ? @$_ : $_ foreach @lines;
print "};\n";
$earliest{$arrayname} = $earliest;
}
@@ -105,8 +110,8 @@ S! unsigned short
v =SIZE16
n =SIZE16
S =SIZE16
-v! =SIZE16
-n! =SIZE16
+v! =SIZE16 PERL_PACK_CAN_SHRIEKSIGN
+n! =SIZE16 PERL_PACK_CAN_SHRIEKSIGN
i int
i! int
I unsigned int
@@ -118,8 +123,8 @@ l =SIZE32
L! unsigned long
V =SIZE32
N =SIZE32
-V! =SIZE32
-N! =SIZE32
+V! =SIZE32 PERL_PACK_CAN_SHRIEKSIGN
+N! =SIZE32 PERL_PACK_CAN_SHRIEKSIGN
L =SIZE32
p * * char *
w * char