Skip to content

Commit

Permalink
ICU-22541 Fix MacOS 14 default timezone issue
Browse files Browse the repository at this point in the history
See #2669
  • Loading branch information
FrankYFTang authored and Squash Bot committed Oct 12, 2023
1 parent 6a4ae3b commit 87c3133
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
15 changes: 15 additions & 0 deletions icu4c/source/common/putil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1175,6 +1175,21 @@ uprv_tzname(int n)
if (ret != nullptr && uprv_strcmp(TZDEFAULT, gTimeZoneBuffer) != 0) {
int32_t tzZoneInfoTailLen = uprv_strlen(TZZONEINFOTAIL);
const char *tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL);
// MacOS14 has the realpath as something like
// /usr/share/zoneinfo.default/Australia/Melbourne
// which will not have "/zoneinfo/" in the path.
// Therefore if we fail, we fall back to read the link which is
// /var/db/timezone/zoneinfo/Australia/Melbourne
// We also fall back to reading the link if the realpath leads to something like
// /usr/share/zoneinfo/posixrules
if (tzZoneInfoTailPtr == nullptr ||
uprv_strcmp(tzZoneInfoTailPtr + tzZoneInfoTailLen, "posixrules") == 0) {
ssize_t size = readlink(TZDEFAULT, gTimeZoneBuffer, sizeof(gTimeZoneBuffer)-1);
if (size > 0) {
gTimeZoneBuffer[size] = 0;
tzZoneInfoTailPtr = uprv_strstr(gTimeZoneBuffer, TZZONEINFOTAIL);
}
}
if (tzZoneInfoTailPtr != nullptr) {
tzZoneInfoTailPtr += tzZoneInfoTailLen;
skipZoneIDPrefix(&tzZoneInfoTailPtr);
Expand Down
9 changes: 3 additions & 6 deletions icu4c/source/test/depstest/dependencies.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ system_symbols:
exp_and_tanhf
stdlib_qsort
system_locale
stdio_input stdio_output file_io realpath_function dir_io mmap_functions dlfcn
stdio_input stdio_output file_io dir_io mmap_functions dlfcn
# C++
cplusplus iostream
std_mutex
Expand Down Expand Up @@ -110,11 +110,8 @@ group: file_io
# Additional symbols in an optimized build.
__xstat

group: realpath_function
realpath # putil.cpp uprv_tzname() calls this in a hack to get the time zone name

group: dir_io
opendir closedir readdir # for a hack to get the time zone name
opendir closedir readdir readlink realpath # for a hack to get the time zone name

group: mmap_functions # for memory-mapped data loading
mmap munmap
Expand Down Expand Up @@ -868,7 +865,7 @@ group: platform
PIC system_misc system_debug malloc_functions ubsan
c_strings c_string_formatting
floating_point system_locale
stdio_input realpath_function dir_io
stdio_input dir_io
dlfcn # Move related code into icuplug.c?
cplusplus
std_mutex
Expand Down

0 comments on commit 87c3133

Please sign in to comment.