2 # I'm assuming that you're running this on some kind of ASCII system, but
3 # it will generate EDCDIC too. (TODO)
8 my ($chrmap, $letter, $unpredictable, $nocsum, $size, $condition) = @_;
9 my $text = " /* $letter */ $size";
10 $text .= " | PACK_SIZE_UNPREDICTABLE" if $unpredictable;
11 $text .= " | PACK_SIZE_CANNOT_CSUM" if $nocsum;
15 $condition = join " && ", map {"defined($_)"} split ' ', $condition;
16 $text = "#if $condition
30 my ($letter, $shriek, $unpredictable, $nocsum, $size, $condition) =
31 /^([A-Za-z])(!?)\t(\S*)\t(\S*)\t([^\t\n]+)(?:\t+(.*))?$/ or
32 die "Can't parse '$_'";
34 $size = "sizeof($size)" unless $size =~ s/^=//;
36 $arrays{$shriek ? 'shrieking' : 'normal'}{ord $chrmap->{$letter}} =
37 make_text($chrmap, $letter,
38 $unpredictable, $nocsum, $size, $condition);
41 my $text = "const packprops_t packprops[512] = {\n";
42 foreach my $arrayname (qw(normal shrieking)) {
43 my $array = $arrays{$arrayname} ||
44 die "No defined entries in $arrayname";
45 $text .= " /* $arrayname */\n";
47 $text .= $array->{$ch} || " 0,";
51 # Join "0," entries together
52 1 while $text =~ s/\b0,\s*\n\s*0,/0, 0,/g;
53 # But split them up again if the sequence gets too long
54 $text =~ s/((?:\b0, ){15}0,) /$1\n /g;
66 my %asciimap = map {chr $_, chr $_} 0..255;
67 my %ebcdicmap = map {chr $_, Encode::encode("posix-bc", chr $_)} 0..255;
70 /* These tables are regenerated by genpacksizetables.pl (and then hand pasted
71 in). You're unlikely ever to need to regenerate them. */
73 #if TYPE_IS_SHRIEKING != 0x100
74 ++++shriek offset should be 256
77 typedef U8 packprops_t;
80 @{[make_tables (\%asciimap, @lines)]}
82 /* EBCDIC (or bust) */
83 @{[make_tables (\%ebcdicmap, @lines)]}
100 v! =SIZE16 PERL_PACK_CAN_SHRIEKSIGN
101 n! =SIZE16 PERL_PACK_CAN_SHRIEKSIGN
113 V! =SIZE32 PERL_PACK_CAN_SHRIEKSIGN
114 N! =SIZE32 PERL_PACK_CAN_SHRIEKSIGN
123 D =LONG_DOUBLESIZE HAS_LONG_DOUBLE USE_LONG_DOUBLE