Debian Codegraph @

pTk/makeenglish

raw
1 #!/usr/local/bin/perl -w
2 # BEGIN { push(@INC, qw(../../../lib ../../lib ../lib lib)) }
3
4 die "Must be executed from Tk/pTk distribution directory\n" unless -f "Lang.h";
5 open(STDOUT, ">../Tk/English.pm") || die "open failed: $!";
6 print <<'EOH';
7 package Tk::English;
8
9 require Exporter;
10 use base (Exporter);
11
12 # This file is generated automatically by pTk/makeenglish from Tk distribution.
13
14 EOH
15
16 my %found = ();
17
18 opendir(DIR,'.') || die "Cannot open '.':$!";
19 @ARGV = grep(/\.c/,readdir(DIR));
20 closedir(DIR);
21
22 while (<>)
23 {
24 if (/strn?cmp\s*\(.*"([a-z][a-z0-9]+)"/)
25 {my $key = $1;
26 my $name = "\U$key";
27 if (!defined $found{$name})
28 {
29 $found{$name} = $key;
30 }
31 }
32 }
33
34
35 print "\n\@EXPORT = qw(\n";
36 $line = "";
37 foreach (sort keys %found)
38 {
39 if (length($line)+length($_)+2 > 76)
40 {
41 print " $line\n";
42 $line = "";
43 }
44 else
45 {
46 $line .= ' ' if (length $line);
47 }
48 $line .= "&$_";
49 }
50 print " $line\n" if (length $line);
51 print ");\n";
52
53 foreach $name (sort keys %found) {
54 my $key = $found{$name};
55 print qq(sub $name () { '$key' }\n);
56 }
57
58 print "\n1;\n";
59