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 $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 = "STATIC 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;
68 # Currently, all things generated by this on EBCDIC are alphabetics, whose
69 # positions are all the same regardless of code page, so any EBCDIC encoding
70 # will work; just choose one
71 my %ebcdicmap = map {chr $_, Encode::encode("posix-bc", chr $_)} 0..255;
73 my $fh = open_new('packsizetables.inc', '>', { by => $0, from => 'its data'});
76 #if TYPE_IS_SHRIEKING != 0x100
77 ++++shriek offset should be 256
80 typedef U8 packprops_t;
83 @{[make_tables (\%asciimap, @lines)]}
85 /* EBCDIC (or bust) */
86 @{[make_tables (\%ebcdicmap, @lines)]}
90 read_only_bottom_close_and_rename($fh);
124 Q Uquad_t IVSIZE >= 8
128 D =LONG_DOUBLESIZE defined(HAS_LONG_DOUBLE) && defined(USE_LONG_DOUBLE)