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