Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ICU-22541 Fix MacOS 14 default timezone issue #2669

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading