1 |
wakaba |
1.1 |
use strict;
|
2 |
|
|
use vars qw(%PROP %SET %SET_ALIAS $VERSION);
|
3 |
wakaba |
1.3 |
$VERSION=do{my @r=(q$Revision: 1.2 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r};
|
4 |
wakaba |
1.1 |
|
5 |
|
|
$PROP{module_name} = 'FooScript';
|
6 |
|
|
|
7 |
|
|
sub header () {
|
8 |
|
|
<<"EOH";
|
9 |
|
|
## This is auto-generated (at @{[ sprintf '%04d-%02d-%02dT%02d:%02d:%02dZ', (gmtime)[5]+1900, (gmtime)[4]+1, (gmtime)[3,2,1,0] ]}). Do not edit by hand!
|
10 |
|
|
use strict;
|
11 |
|
|
|
12 |
|
|
package Char::InSet::$PROP{module_name};
|
13 |
|
|
use Exporter;
|
14 |
|
|
use vars qw(\@EXPORT_OK \@ISA \$VERSION);
|
15 |
|
|
\@ISA = qw(Exporter);
|
16 |
|
|
\$VERSION = '$PROP{version}';
|
17 |
|
|
EOH
|
18 |
|
|
}
|
19 |
|
|
|
20 |
|
|
sub table () {
|
21 |
wakaba |
1.3 |
my $prefix = exists $PROP{prefix_name} ? $PROP{prefix_name} : $PROP{module_name};
|
22 |
wakaba |
1.1 |
my $r = '';
|
23 |
|
|
my @set;
|
24 |
|
|
for (sort keys %SET) {
|
25 |
wakaba |
1.2 |
my (@aline,@aitem);
|
26 |
wakaba |
1.1 |
$SET{$_} =~ s{^#\+(\w+)$}{
|
27 |
wakaba |
1.3 |
push @aline, qq(\&In${prefix}$1.); ''
|
28 |
wakaba |
1.1 |
}mge;
|
29 |
wakaba |
1.2 |
$SET{$_} =~ s{^!(.+)$}{ ## Pre-formated
|
30 |
|
|
push @aitem, $1; ''
|
31 |
|
|
}mge;
|
32 |
wakaba |
1.1 |
$SET{$_} =~ s{^#.+$}{}mg;
|
33 |
|
|
$SET{$_} =~ tr/\x09\x0A\x0D\x20//d;
|
34 |
wakaba |
1.3 |
push @set, [qq(In${prefix}$_) =>
|
35 |
|
|
join "\n", qq(sub In${prefix}$_ {),
|
36 |
wakaba |
1.2 |
@aline,
|
37 |
|
|
(length $SET{$_}?
|
38 |
|
|
(q(<<EOH;),
|
39 |
|
|
@aitem,
|
40 |
|
|
(map {sprintf '%04X', $_} sort {$a <=> $b}
|
41 |
|
|
map {ord $_} split //, $SET{$_}),
|
42 |
|
|
q(EOH)):
|
43 |
|
|
@aitem > 0? (q(<<EOH;), @aitem, q(EOH)): "''"),
|
44 |
|
|
q(})
|
45 |
wakaba |
1.1 |
];
|
46 |
|
|
}
|
47 |
|
|
for (sort keys %SET_ALIAS) {
|
48 |
wakaba |
1.3 |
push @set, [qq(In${prefix}$_) => qq(\*In${prefix}$_ = \\&In${prefix}$SET_ALIAS{$_};)];
|
49 |
wakaba |
1.1 |
}
|
50 |
|
|
|
51 |
|
|
$r = qq(\@EXPORT_OK = qw(@{[map {$_->[0]} @set]});\n\n);
|
52 |
|
|
$r .= join '', map {$_->[1]."\n\n"} @set;
|
53 |
|
|
$r;
|
54 |
|
|
}
|
55 |
|
|
|
56 |
|
|
sub footer () {
|
57 |
|
|
my $r = <<EOH;
|
58 |
|
|
=head1 NAME
|
59 |
|
|
|
60 |
wakaba |
1.3 |
$PROP{module_name}.pm --- @{[ $PROP{script_name} || $PROP{module_name} ]} character sets for C<\\p{In@{[ exists $PROP{prefix_name} ? $PROP{prefix_name} : $PROP{module_name} ]}HogeHoge}> regexps
|
61 |
wakaba |
1.1 |
|
62 |
|
|
@{[$PROP{pod_description}? "=head1 DESCRIPTION
|
63 |
|
|
|
64 |
wakaba |
1.2 |
$PROP{pod_description}":'']}@{[$PROP{pod_example}? "=head1 EXAMPLE
|
65 |
|
|
|
66 |
|
|
$PROP{pod_example}":'']}@{[$PROP{pod_license}? "=head1 LICENSE
|
67 |
wakaba |
1.1 |
|
68 |
wakaba |
1.2 |
$PROP{pod_license}":"=head1 LICENSE
|
69 |
wakaba |
1.1 |
|
70 |
wakaba |
1.2 |
Copyright @{[(gmtime)[5]+1900]} $PROP{author_name} <$PROP{author_mail}>
|
71 |
wakaba |
1.1 |
|
72 |
|
|
This library and the library generated by it is free software;
|
73 |
|
|
you can redistribute them and/or modify them under the same
|
74 |
|
|
terms as Perl itself.
|
75 |
wakaba |
1.2 |
"]}@{[$PROP{pod_see_also}? "=head1 SEE ALSO
|
76 |
wakaba |
1.1 |
|
77 |
|
|
$PROP{pod_see_also}":'']}
|
78 |
|
|
=cut
|
79 |
|
|
|
80 |
|
|
1;
|
81 |
|
|
### $PROP{module_name}.pm ends here
|
82 |
|
|
EOH
|
83 |
|
|
$r;
|
84 |
|
|
}
|
85 |
|
|
|
86 |
wakaba |
1.3 |
sub col2list ($) {
|
87 |
|
|
my $s = shift;
|
88 |
|
|
my @s;
|
89 |
|
|
$s =~ s{^[\x20\x09]*([0-9A-F][0-9A-F])((?:[\x20\x09]+[0-9A-F][0-9A-F](?:-[0-9A-F][0-9A-F])?)+)}{
|
90 |
|
|
my ($r, @c) = ($1, grep {length} split /\s+/, $2);
|
91 |
|
|
for (@c) {
|
92 |
|
|
if (/([0-9A-F][0-9A-F])-([0-9A-F][0-9A-F])/) {
|
93 |
|
|
push @s, sprintf '%s%s %s%s ', $r,$1, $r,$2;
|
94 |
|
|
} else {
|
95 |
|
|
push @s, sprintf '%s%s', $r,$_;
|
96 |
|
|
}
|
97 |
|
|
}
|
98 |
|
|
}gem;
|
99 |
|
|
join ("\n", map {'!'.$_} @s)."\n";
|
100 |
|
|
}
|
101 |
|
|
|
102 |
wakaba |
1.1 |
sub print_module () {
|
103 |
|
|
no warnings;
|
104 |
|
|
print &header.&table.&footer;
|
105 |
|
|
}
|
106 |
|
|
|
107 |
|
|
=head1 NAME
|
108 |
|
|
|
109 |
|
|
mkpm.pl --- Char::InSet::Han modules generating library
|
110 |
|
|
|
111 |
|
|
=head1 LICENSE
|
112 |
|
|
|
113 |
|
|
Copyright 2002 Wakaba <w@suika.fam.cx>
|
114 |
|
|
|
115 |
|
|
This library and the library generated by it is free software;
|
116 |
|
|
you can redistribute them and/or modify them under the same
|
117 |
|
|
terms as Perl itself.
|
118 |
|
|
|
119 |
|
|
=cut
|
120 |
|
|
|
121 |
wakaba |
1.3 |
1; ## $Date: 2002/08/23 23:16:32 $
|
122 |
wakaba |
1.1 |
### mkpm.pl ends here
|