mkutable (7e1b7636c894be9d1130c284089ce1ea0786ecec) mkutable (b2ea244070ff84eab79e04befb7aa30c982fc84d)
1#! /usr/bin/perl
2use strict;
3
4my $USAGE = <<__EOF__;
5 usage: mkutable [-n] [-f#] type... [--] [<] UnicodeData.txt
6 -n = take non-matching types
7 -f = zero-based type field (default 2)
8__EOF__
9
10use vars qw( $opt_f $opt_n );
11use Getopt::Std;
12my $type_field = 2;
13
1#! /usr/bin/perl
2use strict;
3
4my $USAGE = <<__EOF__;
5 usage: mkutable [-n] [-f#] type... [--] [<] UnicodeData.txt
6 -n = take non-matching types
7 -f = zero-based type field (default 2)
8__EOF__
9
10use vars qw( $opt_f $opt_n );
11use Getopt::Std;
12my $type_field = 2;
13
14# Override Unicode tables for certain control chars
15# that are expected to be found in normal text files.
16my %force_space = (
17 0x08 => 1, # backspace
18 0x09 => 1, # tab
19 0x0a => 1, # newline
20 0x0c => 1, # form feed
21 0x0d => 1, # carriage return
22);
23
14exit (main() ? 0 : 1);
15
16sub main {
17 my $date = `date`;
18 chomp $date;
19 my $args = join ' ', @ARGV;
20 my $header = "/* Generated by \"$0 $args\" on $date */\n";
21

--- 20 unchanged lines hidden (view full) ---

42 $lo_code = hex $1;
43 $hi_code = hex $2;
44 } else {
45 $lo_code = $hi_code = hex $fields[0];
46 }
47 my $type = $fields[$type_field];
48 $type =~ s/\s//g;
49 for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) {
24exit (main() ? 0 : 1);
25
26sub main {
27 my $date = `date`;
28 chomp $date;
29 my $args = join ' ', @ARGV;
30 my $header = "/* Generated by \"$0 $args\" on $date */\n";
31

--- 20 unchanged lines hidden (view full) ---

52 $lo_code = hex $1;
53 $hi_code = hex $2;
54 } else {
55 $lo_code = $hi_code = hex $fields[0];
56 }
57 my $type = $fields[$type_field];
58 $type =~ s/\s//g;
59 for ($last_code = $lo_code; $last_code <= $hi_code; ++$last_code) {
60 $type = 'Zs' if $force_space{$last_code};
50 output(\%out, $last_code, $type);
51 }
52 }
53 output(\%out, $last_code);
54 return 1;
55}
56
57sub output {

--- 28 unchanged lines hidden ---
61 output(\%out, $last_code, $type);
62 }
63 }
64 output(\%out, $last_code);
65 return 1;
66}
67
68sub output {

--- 28 unchanged lines hidden ---