2 # I'm assuming that you're running this on some kind of ASCII system, but
3 # it will generate EBCDIC too. (TODO)
6 require 'regen/regen_lib.pl';
9 my ($chrmap, $letter, $unpredictable, $nocsum, $size, $condition) = @_;
10 my $text = " /* $letter */ $size";
11 $text .= " | PACK_SIZE_UNPREDICTABLE" if $unpredictable;
12 $text .= " | PACK_SIZE_CANNOT_CSUM" if $nocsum;
16 $condition = join " && ", map {"defined($_)"} split ' ', $condition;
17 $text = "#if $condition
31 my ($letter, $shriek, $unpredictable, $nocsum, $size, $condition) =
32 /^([A-Za-z])(!?)\t(\S*)\t(\S*)\t([^\t\n]+)(?:\t+(.*))?$/ or
33 die "Can't parse '$_'";
35 $size = "sizeof($size)" unless $size =~ s/^=//;
37 $arrays{$shriek ? 'shrieking' : 'normal'}{ord $chrmap->{$letter}} =
38 make_text($chrmap, $letter,
39 $unpredictable, $nocsum, $size, $condition);
42 my $text = "STATIC const packprops_t packprops[512] = {\n";
43 foreach my $arrayname (qw(normal shrieking)) {
44 my $array = $arrays{$arrayname} ||
45 die "No defined entries in $arrayname";
46 $text .= " /* $arrayname */\n";
48 $text .= $array->{$ch} || " 0,";
52 # Join "0," entries together
53 1 while $text =~ s/\b0,\s*\n\s*0,/0, 0,/g;
54 # But split them up again if the sequence gets too long
55 $text =~ s/((?:\b0, ){15}0,) /$1\n /g;
67 my %asciimap = map {chr $_, chr $_} 0..255;
68 my %ebcdicmap = map {chr $_, Encode::encode("posix-bc", chr $_)} 0..255;
70 my $fh = open_new('packsizetables.c', '>', { by => $0, from => 'its data'});
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)]}
87 read_only_bottom_close_and_rename($fh);
102 v! =SIZE16 PERL_PACK_CAN_SHRIEKSIGN
103 n! =SIZE16 PERL_PACK_CAN_SHRIEKSIGN
115 V! =SIZE32 PERL_PACK_CAN_SHRIEKSIGN
116 N! =SIZE32 PERL_PACK_CAN_SHRIEKSIGN
125 D =LONG_DOUBLESIZE HAS_LONG_DOUBLE USE_LONG_DOUBLE