diff --git a/icu4c/source/common/putil.cpp b/icu4c/source/common/putil.cpp index ab904af20ac4..ab25f3b996de 100644 --- a/icu4c/source/common/putil.cpp +++ b/icu4c/source/common/putil.cpp @@ -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); diff --git a/icu4c/source/test/depstest/dependencies.txt b/icu4c/source/test/depstest/dependencies.txt index 2892536efd7a..58c35d7764dd 100644 --- a/icu4c/source/test/depstest/dependencies.txt +++ b/icu4c/source/test/depstest/dependencies.txt @@ -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 @@ -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 @@ -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