|
| 1 | +diff -aur target-org/webkit/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp target/webkit/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp |
| 2 | +--- target-org/webkit/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp 2019-01-28 09:56:29.000000000 +0800 |
| 3 | ++++ target/webkit/Source/JavaScriptCore/runtime/IntlDateTimeFormat.cpp 2019-09-06 02:00:12.000000000 +0800 |
| 4 | +@@ -40,6 +40,8 @@ |
| 5 | + #include <unicode/udatpg.h> |
| 6 | + #include <unicode/uenum.h> |
| 7 | + #include <wtf/text/StringBuilder.h> |
| 8 | ++#include <sys/system_properties.h> |
| 9 | ++#include <wtf/unicode/UTF8Conversion.h> |
| 10 | + |
| 11 | + #if JSC_ICU_HAS_UFIELDPOSITER |
| 12 | + #include <unicode/ufieldpositer.h> |
| 13 | +@@ -121,14 +123,34 @@ |
| 14 | + // 6.4.3 DefaultTimeZone () (ECMA-402 2.0) |
| 15 | + // The DefaultTimeZone abstract operation returns a String value representing the valid (6.4.1) and canonicalized (6.4.2) time zone name for the host environment’s current time zone. |
| 16 | + |
| 17 | +- UErrorCode status = U_ZERO_ERROR; |
| 18 | ++ UErrorCode status = U_UNDEFINED_VARIABLE; |
| 19 | + Vector<UChar, 32> buffer(32); |
| 20 | +- auto bufferLength = ucal_getDefaultTimeZone(buffer.data(), buffer.size(), &status); |
| 21 | +- if (status == U_BUFFER_OVERFLOW_ERROR) { |
| 22 | +- status = U_ZERO_ERROR; |
| 23 | +- buffer.grow(bufferLength); |
| 24 | +- ucal_getDefaultTimeZone(buffer.data(), bufferLength, &status); |
| 25 | ++ size_t bufferLength = 32; |
| 26 | ++ |
| 27 | ++ // [0] Try to get timezone from Android system property |
| 28 | ++ char systemPropBuffer[2 * (PROP_VALUE_MAX + 1)] = {0}; |
| 29 | ++ if (__system_property_get("persist.sys.timezone", systemPropBuffer) != 0) { |
| 30 | ++ size_t systemPropLength = strlen(systemPropBuffer); |
| 31 | ++ if (systemPropLength > buffer.capacity()) { |
| 32 | ++ buffer.grow(strlen(systemPropBuffer)); |
| 33 | ++ } |
| 34 | ++ UChar* bufferStart = buffer.data(); |
| 35 | ++ if (WTF::Unicode::convertUTF8ToUTF16(reinterpret_cast<const char**>(&systemPropBuffer), systemPropBuffer + systemPropLength, &bufferStart, bufferStart + buffer.capacity()) == WTF::Unicode::conversionOK) { |
| 36 | ++ status = U_ZERO_ERROR; |
| 37 | ++ } |
| 38 | + } |
| 39 | ++ |
| 40 | ++ // [1] Fallback to get timezone from ICU default |
| 41 | ++ if (U_FAILURE(status)) { |
| 42 | ++ bufferLength = ucal_getDefaultTimeZone(buffer.data(), buffer.size(), &status); |
| 43 | ++ if (status == U_BUFFER_OVERFLOW_ERROR) { |
| 44 | ++ status = U_ZERO_ERROR; |
| 45 | ++ buffer.grow(bufferLength); |
| 46 | ++ ucal_getDefaultTimeZone(buffer.data(), bufferLength, &status); |
| 47 | ++ } |
| 48 | ++ } |
| 49 | ++ |
| 50 | ++ // [2] Get canonical timezone ID |
| 51 | + if (U_SUCCESS(status)) { |
| 52 | + status = U_ZERO_ERROR; |
| 53 | + Vector<UChar, 32> canonicalBuffer(32); |
0 commit comments