From 0431b6c11685eeba699d61d87f985ded368405c0 Mon Sep 17 00:00:00 2001 From: akallabeth Date: Fri, 21 Jun 2024 11:29:51 +0200 Subject: [PATCH] [winpr,timezone] fix windows timezone mappings * WINDOWS_TZID_ENTRY struct members were inverted * Entries with multiple IANA entries (separated by space) are now each checked for a match --- .../libwinpr/timezone/TimeZoneNameMapUtils.c | 23 ++++++++++++++++++- winpr/libwinpr/timezone/WindowsZones.h | 2 +- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c b/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c index 16e4f91b0..efd3d0f0f 100644 --- a/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c +++ b/winpr/libwinpr/timezone/TimeZoneNameMapUtils.c @@ -115,7 +115,28 @@ static const char* map_fallback(const char* iana, TimeZoneNameType type) for (size_t x = 0; x < WindowsZonesNrElements; x++) { const WINDOWS_TZID_ENTRY* const entry = &WindowsZones[x]; - if (strcmp(entry->tzid, iana) == 0) + if (strchr(entry->tzid, ' ')) + { + const char* res = NULL; + char* tzid = _strdup(entry->tzid); + char* ctzid = tzid; + while (tzid) + { + char* space = strchr(tzid, ' '); + if (space) + *space++ = '\0'; + if (strcmp(tzid, iana) == 0) + { + res = entry->windows; + break; + } + tzid = space; + } + free(ctzid); + if (res) + return res; + } + else if (strcmp(entry->tzid, iana) == 0) return entry->windows; } diff --git a/winpr/libwinpr/timezone/WindowsZones.h b/winpr/libwinpr/timezone/WindowsZones.h index 90258ab9e..691c14ff9 100644 --- a/winpr/libwinpr/timezone/WindowsZones.h +++ b/winpr/libwinpr/timezone/WindowsZones.h @@ -8,8 +8,8 @@ typedef struct { - const char* windows; const char* tzid; + const char* windows; } WINDOWS_TZID_ENTRY; extern const WINDOWS_TZID_ENTRY WindowsZones[];