Add terminal rows to various QtTimeZoneLocale tables

This fixes some read-past-end issues in assertions that verify the
next row of a table after the last for a specific locale belong to a
later locale. Since those assertions happen without sight of the table
of which the locale's range is a part, they can't tell when the
range's end is in fact the table's end - so they shouldn't have been
reading from a row there. Fix by putting a row there, that belongs to
a nominal locale with index out of range.

Pick-to: 6.9
Change-Id: Ib9d227ca4f86c372c13f963a08a8d637eae63ed0
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Edward Welbourne 2025-02-07 15:18:23 +01:00
parent 4dcff4ed6d
commit b37c580169
2 changed files with 18 additions and 6 deletions

View File

@ -58,8 +58,8 @@ namespace QtTimeZoneLocale {
// GENERATED PART STARTS HERE
/*
This part of the file was generated on 2025-01-13 from the
Common Locale Data Repository v46
This part of the file was generated on 2025-02-07 from the
Common Locale Data Repository v46.1
http://www.unicode.org/cldr/
@ -51631,6 +51631,7 @@ static inline constexpr LocaleZoneExemplar localeZoneExemplarTable[] = {
{ 681, 7211, 467, 7, }, // Indian/Reunion
{ 681, 3157, 474, 5, }, // Pacific/Chuuk
{ 681, 3096, 479, 7, }, // Pacific/Pohnpei
{ 682, 0, 0, 0, } // Terminal row
}; // Exemplar city table
// Sorted by locale index, then iana name
@ -52492,6 +52493,7 @@ static inline constexpr LocaleZoneNames localeZoneNameTable[] = {
{ 678, 2501, 0, 0, 8483, 0, 0, 0, 0, 0, 19, 0, 0, 0, }, // Europe/London
{ 679, 2455, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, }, // Etc/UTC Kara-Kalpak/Cyrillic/Uzbekistan
{ 681, 2455, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, }, // Etc/UTC Swampy Cree/Canadian Aboriginal/Canada
{ 682, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, } // Terminal row
}; // Zone naming table
// Sorted by locale index, then meta key
@ -79720,6 +79722,7 @@ static inline constexpr LocaleMetaZoneLongNames localeMetaZoneLongNameTable[] =
{ 678, 1862, 787179, 787194, 787219, 15, 25, 21, }, // Yakutsk
{ 678, 1870, 787240, 787260, 787290, 20, 30, 26, }, // Yekaterinburg
{ 681, 788, 0, 979873, 0, 0, 20, 0, }, // GMT Swampy Cree/Canadian Aboriginal/Canada
{ 682, 0, 0, 0, 0, 0, 0, 0, } // Terminal row
}; // Metazone long name table
// Sorted by locale index, then meta key
@ -81366,6 +81369,7 @@ static inline constexpr LocaleMetaZoneShortNames localeMetaZoneShortNameTable[]
{ 656, 135, 153, 153, 156, 3, 3, 4, }, // Amazon
{ 656, 437, 376, 376, 379, 3, 3, 4, }, // Brasilia
{ 672, 788, 0, 1868, 0, 0, 2, 0, }, // GMT Anii/Latin/Benin
{ 682, 0, 0, 0, 0, 0, 0, 0, } // Terminal Row
}; // Metazone short name table
// Indexing matches that of locale_data in qlocale_data_p.h

View File

@ -401,6 +401,10 @@ class LocaleZoneDataWriter (LocaleSourceEditor):
def localeData(self, locales: dict[tuple[int, int, int], Locale],
names: list[tuple[int, int, int]]) -> None:
assert len(names) == len(locales), 'Names should just be a sorted list of locale.keys()'
# Tables need a terminal row whose localeIndex is len(names) for the
# sake of an assertion in QTZL.cpp's findTableEntryFor(); the end() of
# each locale's range of rows must be a valid row.
out: Callable[[str], int] = self.writer.write
out('// Sorted by locale index, then iana name\n')
@ -425,7 +429,8 @@ class LocaleZoneDataWriter (LocaleSourceEditor):
if index == locale.exemplarStart else f', // {name}\n')
)
index += 1
out('}; // Exemplar city table\n')
out(formatLine(len(names), 0, 0, 0) + ' // Terminal row\n'
+ '}; // Exemplar city table\n')
if index >= (1 << 32):
raise Error(f'Exemplar table has too many ({index}) entries')
exemplarRowCount: int = index
@ -462,7 +467,8 @@ class LocaleZoneDataWriter (LocaleSourceEditor):
if index == locale.zoneStart else f', // {name}\n')
)
index += 1
out('}; // Zone naming table\n')
out(formatLine(*((len(names), 0) + (0, 0) * 6)) + ' // Terminal row\n'
+ '}; // Zone naming table\n')
if index >= (1 << 16):
raise Error(f'Zone naming table has too many ({index}) entries')
localeNameCount: int = index
@ -504,7 +510,8 @@ class LocaleZoneDataWriter (LocaleSourceEditor):
if index == locale.metaZoneLongStart else f', // {meta}\n')
)
index += 1
out('}; // Metazone long name table\n')
out(formatLine(*((len(names), 0) + (0, 0) * 3)) + ' // Terminal row\n'
+ '}; // Metazone long name table\n')
if index >= (1 << 32):
raise Error(f'Metazone long name table has too many ({index}) entries')
metaLongCount: int = index
@ -540,7 +547,8 @@ class LocaleZoneDataWriter (LocaleSourceEditor):
if index == locale.metaZoneShortStart else f', // {meta}\n')
)
index += 1
out('}; // Metazone short name table\n')
out(formatLine(*((len(names), 0) + (0, 0) * 3)) + ' // Terminal Row\n'
+ '}; // Metazone short name table\n')
if index >= (1 << 16):
raise Error(f'Metazone short name table has too many ({index}) entries')
metaShortCount: int = index