svn commit: r196140 - in user/edwin/locale: . etc tools
Edwin Groothuis
edwin at FreeBSD.org
Wed Aug 12 12:49:53 UTC 2009
Author: edwin
Date: Wed Aug 12 12:49:52 2009
New Revision: 196140
URL: http://svn.freebsd.org/changeset/base/196140
Log:
- Follow up of move from tools/*.xml and tools/charmaps to etc/.
- Add etc/unicode.conf to specify the unicode.org data.
- Improve argument handling in cldr2def.
Added:
user/edwin/locale/etc/unicode.conf
Modified:
user/edwin/locale/Makefile
user/edwin/locale/tools/charmaps.pm
user/edwin/locale/tools/cldr2def.pl
user/edwin/locale/tools/whatis.pl
Modified: user/edwin/locale/Makefile
==============================================================================
--- user/edwin/locale/Makefile Wed Aug 12 12:47:47 2009 (r196139)
+++ user/edwin/locale/Makefile Wed Aug 12 12:49:52 2009 (r196140)
@@ -2,17 +2,17 @@
# $FreeBSD$
#
-UNICODEDIR?= /home/edwin/unicode/
-CLDRVERSION?= 1.7.1
-CLDRDIR?= ${UNICODEDIR}/cldr/${CLDRVERSION}/
-UNIDATAVERSION?=5.2.0
-UNIDATADIR?= ${UNICODEDIR}/UNIDATA/${UNIDATAVERSION}/
+CLDRDIR!= grep ^cldr etc/unicode.conf | cut -f 2 -d " "
+UNIDATADIR!= grep ^unidata etc/unicode.conf | cut -f 2 -d " "
-XMLDIR?= /home/edwin/svn/edwin/locale/tools/
-XMLFILE?= charmaps.xml
+ETCDIR= ${.CURDIR}/etc
TYPES?= monetdef numericdef msgdef timedef
+.if defined(LC)
+LC:= --lc=${LC}
+.endif
+
all:
.for t in ${TYPES}
test -d ${t} || mkdir ${t}
@@ -30,7 +30,11 @@ install:
.for t in ${TYPES}
build-${t}:
test -d ${t} || mkdir ${t}
- perl -I tools tools/cldr2def.pl ${CLDRDIR} ${UNIDATADIR} ${XMLDIR} ${XMLDIR}/${XMLFILE} ${t} ${LC}
+ perl -I tools tools/cldr2def.pl \
+ --cldr=$$(realpath ${CLDRDIR}) \
+ --unidata=$$(realpath ${UNIDATADIR}) \
+ --etc=$$(realpath ${ETCDIR}) \
+ --type=${t} ${LC}
.endfor
clean:
Added: user/edwin/locale/etc/unicode.conf
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ user/edwin/locale/etc/unicode.conf Wed Aug 12 12:49:52 2009 (r196140)
@@ -0,0 +1,2 @@
+cldr ~/unicode/cldr/1.7.1
+unidata ~/unicode/UNIDATA/5.2.0
Modified: user/edwin/locale/tools/charmaps.pm
==============================================================================
--- user/edwin/locale/tools/charmaps.pm Wed Aug 12 12:47:47 2009 (r196139)
+++ user/edwin/locale/tools/charmaps.pm Wed Aug 12 12:49:52 2009 (r196140)
@@ -13,9 +13,9 @@ my %d = ();
my $index = -1;
sub get_xmldata {
- my $xmlfile = shift;
+ my $etcdir = shift;
- open(FIN, $xmlfile);
+ open(FIN, "$etcdir/charmaps.xml");
my @xml = <FIN>;
chomp(@xml);
close(FIN);
Modified: user/edwin/locale/tools/cldr2def.pl
==============================================================================
--- user/edwin/locale/tools/cldr2def.pl Wed Aug 12 12:47:47 2009 (r196139)
+++ user/edwin/locale/tools/cldr2def.pl Wed Aug 12 12:49:52 2009 (r196140)
@@ -8,23 +8,33 @@ use strict;
use XML::Parser;
use Tie::IxHash;
use Data::Dumper;
+use Getopt::Long;
use Digest::SHA qw(sha1_hex);
require "charmaps.pm";
+
if ($#ARGV < 2) {
- print "Usage: $0 <cldrdir> <unidatadir> <xmldirs> <charmaps> <type> [la_CC]\n";
+ print "Usage: $0 --cldr=<cldrdir> --unidata=<unidatadir> --etc=<etcdir> --type=<type> [--lc=<la_CC>]\n";
exit(1);
}
my $DEFENCODING = "UTF-8";
-my $CLDRDIR = shift(@ARGV);
-my $UNIDATADIR = shift(@ARGV);
-my $XMLDIR = shift(@ARGV);
-my $CHARMAPS = shift(@ARGV);
-my $TYPE = shift(@ARGV);
-my $doonly = shift(@ARGV);
my @filter = ();
+my $CLDRDIR = undef;
+my $UNIDATADIR = undef;
+my $ETCDIR = undef;
+my $TYPE = undef;
+my $doonly = undef;
+
+my $result = GetOptions (
+ "cldr=s" => \$CLDRDIR,
+ "unidata=s" => \$UNIDATADIR,
+ "etc=s" => \$ETCDIR,
+ "type=s" => \$TYPE,
+ "lc=s" => \$doonly
+ );
+
my %convertors = ();
my %ucd = ();
@@ -40,7 +50,7 @@ my %utf8map = ();
my %utf8aliases = ();
get_unidata($UNIDATADIR);
get_utf8map("$CLDRDIR/posix/$DEFENCODING.cm");
-get_encodings("$XMLDIR/charmaps");
+get_encodings("$ETCDIR/charmaps");
my %keys = ();
tie(%keys, "Tie::IxHash");
@@ -198,7 +208,8 @@ sub callback_altmon {
sub get_unidata {
my $directory = shift;
- open(FIN, "$directory/UnicodeData.txt");
+ open(FIN, "$directory/UnicodeData.txt")
+ or die("Cannot open $directory/UnicodeData.txt");;
my @lines = <FIN>;
chomp(@lines);
close(FIN);
@@ -276,7 +287,7 @@ sub get_encodings {
}
sub get_languages {
- my %data = get_xmldata($CHARMAPS);
+ my %data = get_xmldata($ETCDIR);
%languages = %{$data{L}};
%translations = %{$data{T}};
%alternativemonths = %{$data{AM}};
@@ -315,7 +326,7 @@ sub get_fields {
$file .= $c;
my $filename = "$CLDRDIR/posix/$file.$DEFENCODING.src";
- $filename = "$XMLDIR/$file.$DEFENCODING.src"
+ $filename = "$ETCDIR/$file.$DEFENCODING.src"
if (! -f $filename);
if (! -f $filename
&& defined $languages{$l}{$f}{fallback}) {
Modified: user/edwin/locale/tools/whatis.pl
==============================================================================
--- user/edwin/locale/tools/whatis.pl Wed Aug 12 12:47:47 2009 (r196139)
+++ user/edwin/locale/tools/whatis.pl Wed Aug 12 12:49:52 2009 (r196140)
@@ -1,8 +1,8 @@
#!/bin/sh
-UNIDATA=/home/edwin/unicode/UNIDATA/5.2.0/UnicodeData.txt
-CHARMAPS=/home/edwin/svn/edwin/locale/tools/charmaps
-UTF8=~/unicode/cldr/1.7.1/posix/UTF-8.cm
+UNIDATA=$(grep ^unidata etc/unicode.conf | cut -f 2 -d " ")
+UTF8=$(grep ^cldr etc/unicode.conf | cut -f 2 -d " ")/UTF-8.cm
+CHARMAPS=etc/charmaps
if [ -z "$1" ]; then
echo "Usage: $0 <unicode string>"
More information about the svn-src-user
mailing list