diff options
author | Siyamed Sinir <siyamed@google.com> | 2019-10-09 16:31:06 +0000 |
---|---|---|
committer | Roland Levillain <rpl@google.com> | 2019-10-09 17:13:29 +0000 |
commit | 60c84605a92922b14e1d3217d7f5e7b1c9862537 (patch) | |
tree | 8e339cb19f246ee8c174eea2fc6038d7e27b01bd | |
parent | ac1a79bbc6550a5f84adf38eee34ab302856e309 (diff) | |
download | minikin-ndk-sysroot-r21.tar.gz |
Revert "Improve toLanguageTag()'s "und" locale handling"ndk-sysroot-r21
This reverts commit ac1a79bbc6550a5f84adf38eee34ab302856e309.
Reason for revert: ticket 142301859, causing flakes and errors on the test.
Bug: b/142301859
Change-Id: Ie37bd52f833fd444abf3351306010c270fa0e432
-rw-r--r-- | libs/minikin/LocaleListCache.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/libs/minikin/LocaleListCache.cpp b/libs/minikin/LocaleListCache.cpp index 9ed5bd6..15156cd 100644 --- a/libs/minikin/LocaleListCache.cpp +++ b/libs/minikin/LocaleListCache.cpp @@ -18,7 +18,6 @@ #include "LocaleListCache.h" -#include <cstring> #include <unordered_set> #include <log/log.h> @@ -50,20 +49,24 @@ static size_t toLanguageTag(char* output, size_t outSize, const StringPiece& loc return 0; } - char likelyChars[ULOC_FULLNAME_CAPACITY]; // Preserve "" and "_****" since uloc_addLikelySubtags changes "" to "en_Latn_US". if (outLength == 0 || (outLength == 5 && output[0] == '_')) { - size_t len = outLength < ULOC_FULLNAME_CAPACITY ? outLength : ULOC_FULLNAME_CAPACITY; - strncpy(likelyChars, output, len); - } else { - uErr = U_ZERO_ERROR; - uloc_addLikelySubtags(output, likelyChars, ULOC_FULLNAME_CAPACITY, &uErr); - if (U_FAILURE(uErr)) { - // unable to build a proper locale identifier - ALOGD("uloc_addLikelySubtags(\"%s\") failed: %s", output, u_errorName(uErr)); - output[0] = '\0'; - return 0; + if (output[0] == '_') { + output[0] = '-'; } + std::string buf(output, outLength); + outLength = (size_t)snprintf(output, outSize, "und%s", buf.c_str()); + return outLength; + } + + char likelyChars[ULOC_FULLNAME_CAPACITY]; + uErr = U_ZERO_ERROR; + uloc_addLikelySubtags(output, likelyChars, ULOC_FULLNAME_CAPACITY, &uErr); + if (U_FAILURE(uErr)) { + // unable to build a proper locale identifier + ALOGD("uloc_addLikelySubtags(\"%s\") failed: %s", output, u_errorName(uErr)); + output[0] = '\0'; + return 0; } uErr = U_ZERO_ERROR; |