Issue #1971 - Part 2: Update ICU source to 63.2.

This commit is contained in:
Job Bautista 2022-07-24 21:03:27 +08:00 committed by roytam1
commit 1e69214382
3160 changed files with 275815 additions and 234203 deletions

View file

@ -74,11 +74,15 @@ tzorig: $(TZCODE) $(TZDATA)
cp $(srcdir)/zdump.c $(TZORIG)/zdump.c
-mv $(TZORIG)/factory $(TZORIG)/factory.orig
cat $(TZORIG)/factory.orig $(srcdir)/icuzones > $(TZORIG)/factory
-mv $(TZORIG)/zishrink.awk $(TZORIG)/zishrink.awk.orig
sed -e '/if (line ~ \/^R SystemV \/) return/s/^/#/' $(TZORIG)/zishrink.awk.orig > $(TZORIG)/zishrink.awk
-mv $(TZORIG)/Makefile $(TZORIG)/Makefile.orig
sed -e "s/^BACKWARD=.*/BACKWARD= backward pacificnew/" $(TZORIG)/Makefile.orig > $(TZORIG)/Makefile
$(MAKE) -C $@ $(TZORIG_OPTS) zdump zones
$(ZDUMPOUT): tzorig
( cd $(TZORIG) ; ./zdump$(EXEEXT) $(ZDUMP_OPTS) )
find $(ZDUMPOUT) -name '*--ICU' -exec sh -c 'mv "$${0}" $${0%--ICU}' {} \;
dump-out: $(ZDUMPOUT) $(ICUZDUMPOUT)
@ -121,7 +125,7 @@ $(ZICTARG): $(OBJECTS) $(TDATA) yearistype $(srcdir)/tz2icu.h
$(CC) $(CFLAGS) $(TZORIG_EXTRA_CFLAGS) $(LFLAGS) -I$(srcdir) $(OBJECTS) $(LDLIBS) -o $@
$(TZ2ICUTARG): $(srcdir)/tz2icu.cpp $(srcdir)/tz2icu.h
$(CXX) -W -Wall -I$(srcdir) -I$(top_srcdir)/common -pedantic $(srcdir)/tz2icu.cpp -o $@
$(CXX) $(CXXFLAGS) -I$(srcdir) -I$(top_srcdir)/common $(srcdir)/tz2icu.cpp -o $@
$(ICUZDUMPTARG): $(srcdir)/icuzdump.cpp
$(LINK.cc) -I$(srcdir) -I$(top_srcdir)/common -I$(top_srcdir)/i18n -I$(top_srcdir)/tools/toolutil -I$(top_srcdir)/io -pedantic $(srcdir)/icuzdump.cpp $(LIBICUUC) $(LIBICUDT) $(LIBICUI18N) $(LIBICUIO) $(LIBICUTOOLUTIL) -o $@

View file

@ -12,4 +12,5 @@
Africa/Asmera ER
America/Montreal CA
Europe/Simferopol UA
Pacific/Johnston UM

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
@ -8,7 +8,7 @@
*
*******************************************************************************
* file name: icuzdump.cpp
* encoding: US-ASCII
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
@ -40,6 +40,7 @@
#include "uoptions.h"
using namespace std;
using namespace icu;
class DumpFormatter {
public:

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
@ -12,6 +12,7 @@
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{655F4481-B461-4DF0-AF10-0D01114A26C1}</ProjectGuid>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
<RootNamespace>icuzdump</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">

View file

@ -71,3 +71,107 @@ Link America/Los_Angeles PST
Link Pacific/Guadalcanal SST
#Link Etc/UTC UTC # Olson LINK
Link Asia/Ho_Chi_Minh VST
#
# Aliases already dropped from the TZ database.
# ICU may also remove these aliases.
#
Link America/Regina Canada/East-Saskatchewan # removed from backward in 2017c
# Note:
# Following section was added for tz database 2018a and 2018b.
# ICU has a bug handling negative DST, and we also don't want to
# flip sumer time name and winter time name for Dublin at least for
# now. Because the change had major impacts to tz database external
# consumers, the tz database maintainer once reverted the Europe/Dublin
# rules (same as 2017c or older) in 2018c. The tz database maintainer
# thinks the changes in 2018a should be brought back when external
# tz database consumers are ready to adopt the change. We don't know
# what CLDR TC want to do with this for now. But if tz database brings
# back the change, and CLDR TC (and ICU TC) want to keep the display name
# unchanged, then we can uncomment the block below to restore ICU
# custom override. (Yoshito 2018-01-23)
#
# tzdata2018a changed Europe/Dublin to use IST (UTC+1) as the standard time
# of the region, and GMT (UTC) as the daylight saving time with negative
# offset (-1 hour) in winter. ICU SimpleTimeZone rejects a zone with negative
# daylight saving time offset. We could remove the restriction in newer version
# of ICU, but such data does not work well with older ICU runtime without
# fixing the issue. For now, we define our own Europe/Dubin in ICU, replacing
# Europe/Dublin data from the tz database.
#
#
# tzdata2018e suggests to use alternative zone definitions for use GB-Eire
# and EU rule after Oct 27, 1968. (Yoshito 2018-05-04)
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Dublin--ICU -0:25:00 - LMT 1880 Aug 2
-0:25:21 - DMT 1916 May 21 2:00s
-0:25:21 1:00 IST 1916 Oct 1 2:00s
0:00 GB-Eire %s 1921 Dec 6 # independence
0:00 GB-Eire GMT/IST 1940 Feb 25 2:00s
0:00 1:00 IST 1946 Oct 6 2:00s
0:00 - GMT 1947 Mar 16 2:00s
0:00 1:00 IST 1947 Nov 2 2:00s
0:00 - GMT 1948 Apr 18 2:00s
0:00 GB-Eire GMT/IST 1968 Oct 27
# The next line is for when negative SAVE values are used.
# 1:00 Eire IST/GMT
# These three lines are for when SAVE values are always nonnegative.
1:00 - IST 1971 Oct 31 2:00u
0:00 GB-Eire GMT/IST 1996
0:00 EU GMT/IST
Link Europe/Dublin--ICU Eire--ICU
#
# tzdata2018e also added another instance of negative DST to
# Europe/Prague and Africa/Windhoek
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Europe/Prague--ICU 0:57:44 - LMT 1850
0:57:44 - PMT 1891 Oct # Prague Mean Time
1:00 C-Eur CE%sT 1945 May 9
1:00 Czech CE%sT 1946 Dec 1 3:00
# Vanguard section, for zic and other parsers that support negative DST.
# 1:00 -1:00 GMT 1947 Feb 23 2:00
# Rearguard section, for parsers that do not support negative DST.
0:00 - GMT 1947 Feb 23 2:00
# End of rearguard section.
1:00 Czech CE%sT 1979
1:00 EU CE%sT
# Slovakia
Link Europe/Prague--ICU Europe/Bratislava--ICU
# RULE NAME FROM TO TYPE IN ON AT SAVE LETTER/S
# Vanguard section, for zic and other parsers that support negative DST.
#Rule Namibia 1994 only - Mar 21 0:00 -1:00 WAT
#Rule Namibia 1994 2017 - Sep Sun>=1 2:00 0 CAT
#Rule Namibia 1995 2017 - Apr Sun>=1 2:00 -1:00 WAT
# Rearguard section, for parsers that do not support negative DST.
Rule Namibia--ICU 1994 only - Mar 21 0:00 0 WAT
Rule Namibia--ICU 1994 2017 - Sep Sun>=1 2:00 1:00 CAT
Rule Namibia--ICU 1995 2017 - Apr Sun>=1 2:00 0 WAT
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Africa/Windhoek--ICU 1:08:24 - LMT 1892 Feb 8
1:30 - +0130 1903 Mar
2:00 - SAST 1942 Sep 20 2:00
2:00 1:00 SAST 1943 Mar 21 2:00
2:00 - SAST 1990 Mar 21 # independence
# Vanguard section, for zic and other parsers that support negative DST.
# 2:00 Namibia %s
# Rearguard section, for parsers that do not support negative DST.
2:00 - CAT 1994 Mar 21 0:00
# From Paul Eggert (2017-04-07):
# The official date of the 2017 rule change was 2017-10-24. See:
# http://www.lac.org.na/laws/annoSTAT/Namibian%20Time%20Act%209%20of%202017.pdf
1:00 Namibia--ICU %s 2017 Oct 24
2:00 - CAT
# End of rearguard section.

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
@ -830,7 +830,7 @@ struct FinalRulePart {
if (mode != DOM && (dow < 0 || dow >= 7)) {
os << "Invalid input day of week " << dow;
}
if (offset < 0 || offset > (2 * HOUR)) {
if (offset < (-1 * HOUR) || offset > (2 * HOUR)) {
os << "Invalid input offset " << offset;
}
if (isgmt && !isstd) {
@ -903,7 +903,6 @@ map<string,FinalRule> finalRules;
map<string, set<string> > links;
map<string, string> reverseLinks;
map<string, string> linkSource; // id => "Olson link" or "ICU alias"
/**
* Predicate used to find FinalRule objects that do not have both
@ -975,9 +974,6 @@ void readFinalZonesAndRules(istream& in) {
links[fromid].insert(toid);
reverseLinks[toid] = fromid;
linkSource[fromid] = "Olson link";
linkSource[toid] = "Olson link";
} else if (token.length() > 0 && token[0] == '#') {
consumeLine(in);
} else {
@ -1430,6 +1426,9 @@ void FinalRule::print(ostream& os) const {
os << part[whichpart].offset << endl;
}
#define ICU_ZONE_OVERRIDE_SUFFIX "--ICU"
#define ICU_ZONE_OVERRIDE_SUFFIX_LEN 5
int main(int argc, char *argv[]) {
string rootpath, zonetab, version;
bool validArgs = FALSE;
@ -1493,6 +1492,82 @@ int main(int argc, char *argv[]) {
<< (ZONEINFO.begin())->first << ".."
<< (--ZONEINFO.end())->first << "]" << endl;
// Overrides TZ database zones with ICU custom zone definition.
// These ICU zone overrides are defined in icuzones, with suffix --ICU.
// If there is a matching TZ database zone, the zoneinfo is replaced
// with the ICU definition. Then, the zone ID with --ICU suffix
// will be deleted from the final list.
// For example, zoneinfo for Europe/Dublin imported from the TZ database
// will be replaced with the zone definition for Europe/Dublin--ICU
// in icuzones.
// Collect zone IDs to be modified with ICU definition.
vector<string> customZones;
for (ZoneMapIter i = ZONEINFO.begin(); i != ZONEINFO.end(); ++i) {
const string& id = i->first;
size_t idx = id.rfind(ICU_ZONE_OVERRIDE_SUFFIX);
if (idx != string::npos && idx == id.length() - ICU_ZONE_OVERRIDE_SUFFIX_LEN) {
cout << "ICU zone override: " << id << endl;
customZones.push_back(id.substr(0, idx));
}
}
//
// BEGIN ICU Custom ZoneInfo Override Handling
//
// Replace zoneinfo with ICU definition, then remove ICU zone ID with
// the special suffix.
for (vector<string>::iterator i = customZones.begin(); i != customZones.end(); i++) {
string& origId = *i;
string custId = origId + ICU_ZONE_OVERRIDE_SUFFIX;
map<string,ZoneInfo>::iterator origZi = ZONEINFO.find(origId);
map<string,ZoneInfo>::iterator custZi = ZONEINFO.find(custId);
if (origZi != ZONEINFO.end() && custZi != ZONEINFO.end()) {
// replace original zone info with custom override,
// then delete one custom ID
cout << "Replacing ZoneInfo " << origId << " with " << custId << endl;
origZi->second = custZi->second;
ZONEINFO.erase(custZi);
}
// Also replace final rule
map<string,FinalZone>::iterator origFz = finalZones.find(origId);
map<string,FinalZone>::iterator custFz = finalZones.find(custId);
if (origFz != finalZones.end() && custFz != finalZones.end()) {
// replace original final zone with custom override,
// then delete one for custom ID
cout << "Replacing FinalZone for " << origId << " with " << custId << endl;
origFz->second = custFz->second;
finalZones.erase(custFz);
}
}
// Also remove aliases for ICU custom zoneinfo overrides.
for (map<string,set<string>>::const_iterator i = links.begin(); i != links.end(); ) {
const string& id = i->first;
size_t idx = id.rfind(ICU_ZONE_OVERRIDE_SUFFIX);
if (idx != string::npos && idx == id.length() - ICU_ZONE_OVERRIDE_SUFFIX_LEN) {
const set<string>& aliases = i->second;
// Also remove all revserse links
for (set<string>::const_iterator j = aliases.begin(); j != aliases.end(); j++) {
const string& alias = *j;
cout << "Removing alias " << alias << endl;
reverseLinks.erase(alias);
}
links.erase(i++);
} else {
i++;
}
}
//
// END ICU Custom ZoneInfo Override Handling
//
try {
for_each(finalZones.begin(), finalZones.end(), mergeFinalZone);
} catch (const exception& error) {
@ -1510,7 +1585,7 @@ int main(int argc, char *argv[]) {
const string& olson = i->first;
const set<string>& aliases = i->second;
if (ZONEINFO.find(olson) == ZONEINFO.end()) {
cerr << "Error: Invalid " << linkSource[olson] << " to non-existent \""
cerr << "Error: Invalid 'Link' to non-existent \""
<< olson << "\"" << endl;
return 1;
}

View file

@ -1,4 +1,4 @@
// Copyright (C) 2016 and later: Unicode, Inc. and others.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************

View file

@ -31,6 +31,7 @@
#ifdef ICU
#include "dirent.h"
#include "sys/stat.h"
#endif
#ifndef isascii
@ -428,7 +429,7 @@ main(int argc, char *argv[])
}
closedir(dp);
}
#endif ICU
#endif
if (vflag | Vflag) {
intmax_t lo;
@ -495,7 +496,6 @@ main(int argc, char *argv[])
int count;
count = getall(&namelist);
fakeargv = (char **) malloc((size_t) (argc + count) * sizeof *argv);
/*
if ((fakeargv = (char **) malloc((size_t) (argc + count) * sizeof *argv)) == NULL) {
@ -1020,9 +1020,9 @@ static void dumptimeICU(FILE * fp, time_t t)
min = offset % 60;
hour = offset / 60;
fprintf(fp, "%02d", hour);
fprintf(fp, "%02d", min);
fprintf(fp, "%02d", sec);
fprintf(fp, "%02ld", hour);
fprintf(fp, "%02ld", min);
fprintf(fp, "%02ld", sec);
fprintf(fp, "[DST=%d]", loc.tm_isdst);
}