summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorThomas Munro <tmunro@FreeBSD.org>2020-11-08 02:50:34 +0000
committerThomas Munro <tmunro@FreeBSD.org>2020-11-08 02:50:34 +0000
commitcc7edd258c2564fe9e3c4a0dc839acc4a71caff9 (patch)
tree713e7f140bcc509d153f6843f0c0c4e93cf43991 /tools
parentd2799054f0d29c33a1f2ab87ee4d88970ec36d91 (diff)
downloadsrc-test2-cc7edd258c2564fe9e3c4a0dc839acc4a71caff9.tar.gz
src-test2-cc7edd258c2564fe9e3c4a0dc839acc4a71caff9.zip
Add collation version support to querylocale(3).
Provide a way to ask for an opaque version string for a locale_t, so that potential changes in sort order can be detected. Similar to ICU's ucol_getVersion() and Windows' GetNLSVersionEx(), this API is intended to allow databases to detect when text order-based indexes might need to be rebuilt. The CLDR version is extracted from CLDR source data by the Makefile under tools/tools/locale, written into the machine-generated Makefile under shared/colldef, passed to localedef -V, and then written into LC_COLLATE file headers. The initial version is 34.0. tools/tools/locale was recently updated to pull down 35.0, but the output hasn't been committed under share/colldef yet, so that will provide the first observable change when it happens. Other versioning schemes are possible in future, because the format is unspecified. Reviewed by: bapt, 0mp, kib, yuripv (albeit a long time ago) Differential Revision: https://reviews.freebsd.org/D17166
Notes
Notes: svn path=/head/; revision=367476
Diffstat (limited to 'tools')
-rw-r--r--tools/tools/locale/Makefile2
-rwxr-xr-xtools/tools/locale/tools/cldr2def.pl19
2 files changed, 21 insertions, 0 deletions
diff --git a/tools/tools/locale/Makefile b/tools/tools/locale/Makefile
index aad2c2160bb5..76fff6acb17c 100644
--- a/tools/tools/locale/Makefile
+++ b/tools/tools/locale/Makefile
@@ -187,6 +187,8 @@ extract-${CLDRFILES_${N}:T}:: ${CLDRFILES_${N}:T} ${UNIDIR}
cd ${UNIDIR} && unzip -o ../${CLDRFILES_${N}:T}
extract: extract-${CLDRFILES_${N}:T}
.endfor
+ grep 'name="version"' ${UNIDIR}/tools/build.xml | \
+ sed 's/.* value="//;s/".*//' > ${UNIDIR}/cldr-version
patch::
.if exists(${PATCHDIR})
cd ${UNIDIR} && cat ${PATCHDIR}/patch-* | patch
diff --git a/tools/tools/locale/tools/cldr2def.pl b/tools/tools/locale/tools/cldr2def.pl
index 5f756cc3895a..8617ca81ca40 100755
--- a/tools/tools/locale/tools/cldr2def.pl
+++ b/tools/tools/locale/tools/cldr2def.pl
@@ -50,6 +50,8 @@ my $UNIDIR = undef;
my $ETCDIR = undef;
my $TYPE = undef;
+my $CLDR_VERSION = undef;
+
my $result = GetOptions (
"unidir=s" => \$UNIDIR,
"etc=s" => \$ETCDIR,
@@ -500,6 +502,12 @@ EOF
sub transform_collation {
+ # Read the CLDR version
+ open(FIN, "$UNIDIR/cldr-version") or die "Cannot open cldr-version";
+ read FIN, $CLDR_VERSION, -s FIN;
+ close(FIN);
+ $CLDR_VERSION =~ s/\s*$//;
+
foreach my $l (sort keys(%languages)) {
foreach my $f (sort keys(%{$languages{$l}})) {
foreach my $c (sort keys(%{$languages{$l}{$f}{data}})) {
@@ -861,8 +869,11 @@ sub make_makefile {
my $SRCOUT4 = "";
my $MAPLOC;
if ($TYPE eq "colldef") {
+ # In future, we might want to try to put the CLDR version into
+ # the .src files with some new syntax, instead of the makefile.
$SRCOUT = "localedef \${LOCALEDEF_ENDIAN} -D -U " .
"-i \${.IMPSRC} \\\n" .
+ "\t-V \${CLDR_VERSION} \\\n" .
"\t-f \${MAPLOC}/map.\${.TARGET:T:R:E:C/@.*//} " .
"\${.OBJDIR}/\${.IMPSRC:T:R}";
$MAPLOC = "MAPLOC=\t\t\${.CURDIR}/../../tools/tools/" .
@@ -875,6 +886,7 @@ sub make_makefile {
"\$t.LC_COLLATE: \${.CURDIR}/\$f.src\n" .
"\tlocaledef \${LOCALEDEF_ENDIAN} -D -U " .
"-i \${.ALLSRC} \\\n" .
+ "\t-V \${CLDR_VERSION} \\\n" .
"\t\t-f \${MAPLOC}/map.\${.TARGET:T:R:E:C/@.*//} \\\n" .
"\t\t\${.OBJDIR}/\${.TARGET:T:R}\n" .
".endfor\n\n";
@@ -917,6 +929,13 @@ FILESNAME= $FILESNAMES{$TYPE}
${MAPLOC}
EOF
+ if ($TYPE eq "colldef") {
+ print FOUT <<EOF;
+CLDR_VERSION= "${CLDR_VERSION}"
+
+EOF
+ }
+
if ($TYPE eq "colldef" || $TYPE eq "ctypedef") {
print FOUT <<EOF;
.include <bsd.endian.mk>