OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" | 7 #include "xfa/fxfa/fm2js/xfa_fm2jscontext.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
373 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 373 15, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
374 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, | 374 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, |
375 }; | 375 }; |
376 | 376 |
377 void AlternateDateTimeSymbols(CFX_WideString& wsPattern, | 377 void AlternateDateTimeSymbols(CFX_WideString& wsPattern, |
378 const CFX_WideString& wsAltSymbols, | 378 const CFX_WideString& wsAltSymbols, |
379 const uint8_t* pAltTable) { | 379 const uint8_t* pAltTable) { |
380 int32_t nLength = wsPattern.GetLength(); | 380 int32_t nLength = wsPattern.GetLength(); |
381 FX_BOOL bInConstRange = FALSE; | 381 FX_BOOL bInConstRange = FALSE; |
382 FX_BOOL bEscape = FALSE; | 382 FX_BOOL bEscape = FALSE; |
383 int32_t i = 0, n = 0; | 383 int32_t i = 0; |
384 FX_WCHAR n = 0; | |
384 while (i < nLength) { | 385 while (i < nLength) { |
385 FX_WCHAR wc = wsPattern[i]; | 386 FX_WCHAR wc = wsPattern[i]; |
386 if (wc == L'\'') { | 387 if (wc == L'\'') { |
387 bInConstRange = !bInConstRange; | 388 bInConstRange = !bInConstRange; |
388 if (bEscape) { | 389 if (bEscape) { |
389 i++; | 390 i++; |
390 } else { | 391 } else { |
391 wsPattern.Delete(i); | 392 wsPattern.Delete(i); |
392 nLength--; | 393 nLength--; |
393 } | 394 } |
394 bEscape = !bEscape; | 395 bEscape = !bEscape; |
395 continue; | 396 continue; |
396 } | 397 } |
397 if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { | 398 if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { |
Lei Zhang
2016/06/01 05:27:04
How about we get rid of |n| and do:
if (... wc >=
Oliver Chang
2016/06/01 16:08:22
Done.
| |
398 int32_t nAlt = (int32_t)pAltTable[n]; | 399 int32_t nAlt = static_cast<int32_t>(pAltTable[n]); |
Lei Zhang
2016/06/01 05:27:04
Just make |nAlt| a uint8_t?
Lei Zhang
2016/06/01 05:27:04
BTW, both of the possible tables, |g_sAltTable_Dat
Oliver Chang
2016/06/01 16:08:22
Done. Also removed the unused entries (now 33 entr
| |
399 if (nAlt != 255) | 400 if (nAlt != 255) |
400 wsPattern.SetAt(i, wsAltSymbols[nAlt]); | 401 wsPattern.SetAt(i, wsAltSymbols[nAlt]); |
401 } | 402 } |
402 i++; | 403 i++; |
403 bEscape = FALSE; | 404 bEscape = FALSE; |
404 } | 405 } |
405 } | 406 } |
406 | 407 |
407 bool PatternStringType(const CFX_ByteStringC& szPattern, | 408 bool PatternStringType(const CFX_ByteStringC& szPattern, |
408 uint32_t& patternType) { | 409 uint32_t& patternType) { |
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4221 strEncode[2] = strCode[ch - iIndex * 16]; | 4222 strEncode[2] = strCode[ch - iIndex * 16]; |
4222 wsResultBuf << FX_WSTRC(strEncode); | 4223 wsResultBuf << FX_WSTRC(strEncode); |
4223 } else if (ch <= 0x1f || ch == 0x7f) { | 4224 } else if (ch <= 0x1f || ch == 0x7f) { |
4224 int32_t iIndex = ch / 16; | 4225 int32_t iIndex = ch / 16; |
4225 strEncode[1] = strCode[iIndex]; | 4226 strEncode[1] = strCode[iIndex]; |
4226 strEncode[2] = strCode[ch - iIndex * 16]; | 4227 strEncode[2] = strCode[ch - iIndex * 16]; |
4227 wsResultBuf << FX_WSTRC(strEncode); | 4228 wsResultBuf << FX_WSTRC(strEncode); |
4228 } else if (ch >= 0x20 && ch <= 0x7e) { | 4229 } else if (ch >= 0x20 && ch <= 0x7e) { |
4229 wsResultBuf.AppendChar(ch); | 4230 wsResultBuf.AppendChar(ch); |
4230 } else { | 4231 } else { |
4231 int32_t iRadix = 16; | 4232 FX_WCHAR iRadix = 16; |
Lei Zhang
2016/06/01 05:27:04
const?
Oliver Chang
2016/06/01 16:08:22
Done.
| |
4232 CFX_WideString strTmp; | 4233 CFX_WideString strTmp; |
4233 while (ch >= iRadix) { | 4234 while (ch >= iRadix) { |
4234 FX_WCHAR tmp = strCode[ch % iRadix]; | 4235 FX_WCHAR tmp = strCode[ch % iRadix]; |
4235 ch /= iRadix; | 4236 ch /= iRadix; |
4236 strTmp += tmp; | 4237 strTmp += tmp; |
4237 } | 4238 } |
4238 strTmp += strCode[ch]; | 4239 strTmp += strCode[ch]; |
4239 int32_t iLen = strTmp.GetLength(); | 4240 int32_t iLen = strTmp.GetLength(); |
4240 if (iLen < 2) { | 4241 if (iLen < 2) { |
4241 break; | 4242 break; |
(...skipping 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7145 CFX_WideString wsFormat; | 7146 CFX_WideString wsFormat; |
7146 pAppProvider->LoadString(iStringID, wsFormat); | 7147 pAppProvider->LoadString(iStringID, wsFormat); |
7147 CFX_WideString wsMessage; | 7148 CFX_WideString wsMessage; |
7148 va_list arg_ptr; | 7149 va_list arg_ptr; |
7149 va_start(arg_ptr, iStringID); | 7150 va_start(arg_ptr, iStringID); |
7150 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); | 7151 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); |
7151 va_end(arg_ptr); | 7152 va_end(arg_ptr); |
7152 FXJSE_ThrowMessage( | 7153 FXJSE_ThrowMessage( |
7153 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); | 7154 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); |
7154 } | 7155 } |
OLD | NEW |