Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Factory:PowerPC
ki18n
0001-KCountrySubdivision-unbreak-support-of-iso...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0001-KCountrySubdivision-unbreak-support-of-iso-codes-4.1.patch of Package ki18n
From 3327283e921627368b4545551d8d6443e24ef897 Mon Sep 17 00:00:00 2001 From: "Friedrich W. H. Kossebau" <kossebau@kde.org> Date: Sat, 3 Feb 2024 16:21:41 +0100 Subject: [PATCH] KCountrySubdivision: unbreak support of iso-codes >= 4.16 (cherry picked from commit 70a80cb1cb46b6660fb49480de8c6318d256586a) --- src/localedata/isocodes_p.h | 18 ++++++++++++++++++ src/localedata/isocodescache.cpp | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/localedata/isocodes_p.h b/src/localedata/isocodes_p.h index 57a01eb..83df3cb 100644 --- a/src/localedata/isocodes_p.h +++ b/src/localedata/isocodes_p.h @@ -177,6 +177,24 @@ constexpr inline uint32_t subdivisionCodeToKey(const char (&code)[N]) { return subdivisionCodeToKey(code, N - 1); } + +/// Before v4.16 iso-codes used for parent code just the subdivision code, without the country +/// (only by error sometimes). Since that version the full code now is always used. +/// Handle both cases gracefully. +/// Does not check the country part for sanity, but just discards the info. +constexpr inline uint16_t parentCodeToKey(QStringView code) +{ + if (code.size() < 4) { + return alphaNum3CodeToKey(code); + } + if (code[2] != QLatin1Char('-')) { + return 0; + } + + const auto countryKey = alpha2CodeToKey(code.left(2)); + const auto subdivKey = alphaNum3CodeToKey(code.mid(3), code.size() - 3); + return countryKey > 0 ? subdivKey : 0; +} } #endif // ISOCODES_P_H diff --git a/src/localedata/isocodescache.cpp b/src/localedata/isocodescache.cpp index e496387..eb8d931 100644 --- a/src/localedata/isocodescache.cpp +++ b/src/localedata/isocodescache.cpp @@ -289,7 +289,7 @@ void IsoCodesCache::createIso3166_2Cache() iso3166_2stringTable.append(entry.value(QLatin1String("name")).toString().toUtf8()); iso3166_2stringTable.append('\0'); - const auto parentKey = IsoCodes::alphaNum3CodeToKey(entry.value(QLatin1String("parent")).toString()); + const auto parentKey = IsoCodes::parentCodeToKey(entry.value(QLatin1String("parent")).toString()); if (parentKey) { subdivParentMap.push_back({key, parentKey}); } -- 2.43.0
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor