Chromium Code Reviews| Index: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp |
| diff --git a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp |
| index e47d0af390a6875d7a177cf209e67362044790e2..849eb566098f1f428f0ec0422aa018b232c0c586 100644 |
| --- a/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp |
| +++ b/xfa/fxfa/fm2js/xfa_fm2jscontext.cpp |
| @@ -249,6 +249,51 @@ const XFA_FMHtmlReserveCode reservesForEncode[] = { |
| {9827, L"clubs"}, {9829, L"hearts"}, {9830, L"diams"}, |
| }; |
| +const uint8_t g_sAltTable_Date[] = { |
| + 19, 19, 19, 3, 9, 19, 19, 19, 19, 19, 19, 19, 2, 19, 19, 19, |
|
Tom Sepez
2016/05/17 20:08:30
How about using 255 instead of 19? That might mak
dsinclair
2016/05/17 20:13:28
Done.
|
| + 19, 19, 19, 19, 19, 19, 19, 19, 1, 19, 19, 19, 19, 19, 19, 19, |
| + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, |
| + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, |
| +}; |
| + |
| +const uint8_t g_sAltTable_Time[] = { |
| + 14, 19, 19, 3, 9, 19, 19, 15, 19, 19, 19, 19, 6, 19, 19, 19, |
| + 19, 19, 7, 19, 19, 19, 19, 19, 1, 17, 19, 19, 19, 19, 19, 19, |
| + 19, 19, 19, 19, 19, 19, 19, 15, 19, 19, 19, 19, 19, 19, 19, 19, |
| + 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, |
| +}; |
| + |
| +void AlternateDateTimeSymbols(CFX_WideString& wsPattern, |
| + const CFX_WideString& wsAltSymbols, |
| + const uint8_t* pAltTable) { |
| + int32_t nLength = wsPattern.GetLength(); |
| + FX_BOOL bInConstRange = FALSE; |
| + FX_BOOL bEscape = FALSE; |
| + int32_t i = 0, n = 0; |
| + while (i < nLength) { |
| + FX_WCHAR wc = wsPattern[i]; |
| + if (wc == L'\'') { |
| + bInConstRange = !bInConstRange; |
| + if (bEscape) { |
| + i++; |
| + } else { |
| + wsPattern.Delete(i); |
| + nLength--; |
| + } |
| + bEscape = !bEscape; |
| + continue; |
| + } |
| + if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { |
| + int32_t nAlt = (int32_t)pAltTable[n]; |
| + if (nAlt != 19) { |
| + wsPattern.SetAt(i, wsAltSymbols[nAlt]); |
| + } |
| + } |
| + i++; |
| + bEscape = FALSE; |
| + } |
| +} |
| + |
| } // namespace |
| void CXFA_FM2JSContext::Abs(FXJSE_HOBJECT hThis, |
| @@ -2275,54 +2320,7 @@ int32_t CXFA_FM2JSContext::DateString2Num(const CFX_ByteStringC& szDateString) { |
| } |
| return (int32_t)dDays; |
| } |
| -#define XFA_N 19 |
| -static uint8_t g_sAltTable_Date[] = { |
| - XFA_N, XFA_N, XFA_N, 3, 9, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, 2, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, 1, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| -}; |
| -static uint8_t g_sAltTable_Time[] = { |
| - 14, XFA_N, XFA_N, 3, 9, XFA_N, XFA_N, 15, XFA_N, XFA_N, XFA_N, |
| - XFA_N, 6, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, 7, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, 1, 17, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, 15, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| - XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, XFA_N, |
| -}; |
| -static void XFA_FM_AlternateDateTimeSymbols(CFX_WideString& wsPattern, |
| - const CFX_WideString& wsAltSymbols, |
| - uint8_t* pAltTable) { |
| - int32_t nLength = wsPattern.GetLength(); |
| - FX_BOOL bInConstRange = FALSE; |
| - FX_BOOL bEscape = FALSE; |
| - int32_t i = 0, n = 0; |
| - while (i < nLength) { |
| - FX_WCHAR wc = wsPattern[i]; |
| - if (wc == L'\'') { |
| - bInConstRange = !bInConstRange; |
| - if (bEscape) { |
| - i++; |
| - } else { |
| - wsPattern.Delete(i); |
| - nLength--; |
| - } |
| - bEscape = !bEscape; |
| - continue; |
| - } |
| - if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { |
| - int32_t nAlt = (int32_t)pAltTable[n]; |
| - if (nAlt != XFA_N) { |
| - wsPattern.SetAt(i, wsAltSymbols[nAlt]); |
| - } |
| - } |
| - i++; |
| - bEscape = FALSE; |
| - } |
| -} |
| -#undef XFA_N |
| + |
| void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis, |
| int32_t iStyle, |
| const CFX_ByteStringC& szLocalStr, |
| @@ -2373,7 +2371,7 @@ void CXFA_FM2JSContext::GetLocalDateFormat(FXJSE_HOBJECT hThis, |
| if (!bStandard) { |
| CFX_WideString wsSymbols; |
| pLocale->GetDateTimeSymbols(wsSymbols); |
| - XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| + AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Date); |
| } |
| strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| } |
| @@ -2427,7 +2425,7 @@ void CXFA_FM2JSContext::GetLocalTimeFormat(FXJSE_HOBJECT hThis, |
| if (!bStandard) { |
| CFX_WideString wsSymbols; |
| pLocale->GetDateTimeSymbols(wsSymbols); |
| - XFA_FM_AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| + AlternateDateTimeSymbols(strRet, wsSymbols, g_sAltTable_Time); |
| } |
| strFormat = FX_UTF8Encode(strRet.c_str(), strRet.GetLength()); |
| } |