Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(102)

Side by Side Diff: xfa/fxfa/fm2js/xfa_fm2jscontext.cpp

Issue 2023173002: Fix some signed/unsigned comparisons in xfa_fm2jscontext.cpp (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: static_assert Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 0, // number of properties 352 0, // number of properties
353 FX_ArraySize(formcalc_fm2js_functions), // number of methods 353 FX_ArraySize(formcalc_fm2js_functions), // number of methods
354 nullptr, // dynamic prop type 354 nullptr, // dynamic prop type
355 nullptr, // dynamic prop getter 355 nullptr, // dynamic prop getter
356 nullptr, // dynamic prop setter 356 nullptr, // dynamic prop setter
357 nullptr, // dynamic prop deleter 357 nullptr, // dynamic prop deleter
358 nullptr, // dynamic prop method call 358 nullptr, // dynamic prop method call
359 }; 359 };
360 360
361 const uint8_t g_sAltTable_Date[] = { 361 const uint8_t g_sAltTable_Date[] = {
362 255, 255, 255, 3, 9, 255, 255, 255, 255, 255, 255, 255, 2, 362 255, 255, 255, 3, 9, 255, 255, 255, 255, 255, 255,
363 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 1, 255, 363 255, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255,
364 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 364 255, 255, 1, 255, 255, 255, 255, 255, 255, 255, 255,
365 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
366 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,
367 }; 365 };
366 static_assert(FX_ArraySize(g_sAltTable_Date) == L'a' - L'A' + 1,
367 "Invalid g_sAltTable_Date size.");
368 368
369 const uint8_t g_sAltTable_Time[] = { 369 const uint8_t g_sAltTable_Time[] = {
370 14, 255, 255, 3, 9, 255, 255, 15, 255, 255, 255, 255, 6, 370 14, 255, 255, 3, 9, 255, 255, 15, 255, 255, 255,
371 255, 255, 255, 255, 255, 7, 255, 255, 255, 255, 255, 1, 17, 371 255, 6, 255, 255, 255, 255, 255, 7, 255, 255, 255,
372 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 372 255, 255, 1, 17, 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,
375 }; 373 };
374 static_assert(FX_ArraySize(g_sAltTable_Time) == L'a' - L'A' + 1,
375 "Invalid g_sAltTable_Time size.");
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 while (i < nLength) { 384 while (i < nLength) {
385 FX_WCHAR wc = wsPattern[i]; 385 FX_WCHAR wc = wsPattern[i];
386 if (wc == L'\'') { 386 if (wc == L'\'') {
387 bInConstRange = !bInConstRange; 387 bInConstRange = !bInConstRange;
388 if (bEscape) { 388 if (bEscape) {
389 i++; 389 i++;
390 } else { 390 } else {
391 wsPattern.Delete(i); 391 wsPattern.Delete(i);
392 nLength--; 392 nLength--;
393 } 393 }
394 bEscape = !bEscape; 394 bEscape = !bEscape;
395 continue; 395 continue;
396 } 396 }
397 if (!bInConstRange && (n = wc - L'A') >= 0 && n <= (L'a' - L'A')) { 397 if (!bInConstRange && wc >= L'A' && wc <= L'a') {
398 int32_t nAlt = (int32_t)pAltTable[n]; 398 uint8_t nAlt = pAltTable[wc - L'A'];
399 if (nAlt != 255) 399 if (nAlt != 255)
400 wsPattern.SetAt(i, wsAltSymbols[nAlt]); 400 wsPattern.SetAt(i, wsAltSymbols[nAlt]);
401 } 401 }
402 i++; 402 i++;
403 bEscape = FALSE; 403 bEscape = FALSE;
404 } 404 }
405 } 405 }
406 406
407 bool PatternStringType(const CFX_ByteStringC& szPattern, 407 bool PatternStringType(const CFX_ByteStringC& szPattern,
408 uint32_t& patternType) { 408 uint32_t& patternType) {
(...skipping 3812 matching lines...) Expand 10 before | Expand all | Expand 10 after
4221 strEncode[2] = strCode[ch - iIndex * 16]; 4221 strEncode[2] = strCode[ch - iIndex * 16];
4222 wsResultBuf << FX_WSTRC(strEncode); 4222 wsResultBuf << FX_WSTRC(strEncode);
4223 } else if (ch <= 0x1f || ch == 0x7f) { 4223 } else if (ch <= 0x1f || ch == 0x7f) {
4224 int32_t iIndex = ch / 16; 4224 int32_t iIndex = ch / 16;
4225 strEncode[1] = strCode[iIndex]; 4225 strEncode[1] = strCode[iIndex];
4226 strEncode[2] = strCode[ch - iIndex * 16]; 4226 strEncode[2] = strCode[ch - iIndex * 16];
4227 wsResultBuf << FX_WSTRC(strEncode); 4227 wsResultBuf << FX_WSTRC(strEncode);
4228 } else if (ch >= 0x20 && ch <= 0x7e) { 4228 } else if (ch >= 0x20 && ch <= 0x7e) {
4229 wsResultBuf.AppendChar(ch); 4229 wsResultBuf.AppendChar(ch);
4230 } else { 4230 } else {
4231 int32_t iRadix = 16; 4231 const FX_WCHAR iRadix = 16;
4232 CFX_WideString strTmp; 4232 CFX_WideString strTmp;
4233 while (ch >= iRadix) { 4233 while (ch >= iRadix) {
4234 FX_WCHAR tmp = strCode[ch % iRadix]; 4234 FX_WCHAR tmp = strCode[ch % iRadix];
4235 ch /= iRadix; 4235 ch /= iRadix;
4236 strTmp += tmp; 4236 strTmp += tmp;
4237 } 4237 }
4238 strTmp += strCode[ch]; 4238 strTmp += strCode[ch];
4239 int32_t iLen = strTmp.GetLength(); 4239 int32_t iLen = strTmp.GetLength();
4240 if (iLen < 2) { 4240 if (iLen < 2) {
4241 break; 4241 break;
(...skipping 2903 matching lines...) Expand 10 before | Expand all | Expand 10 after
7145 CFX_WideString wsFormat; 7145 CFX_WideString wsFormat;
7146 pAppProvider->LoadString(iStringID, wsFormat); 7146 pAppProvider->LoadString(iStringID, wsFormat);
7147 CFX_WideString wsMessage; 7147 CFX_WideString wsMessage;
7148 va_list arg_ptr; 7148 va_list arg_ptr;
7149 va_start(arg_ptr, iStringID); 7149 va_start(arg_ptr, iStringID);
7150 wsMessage.FormatV(wsFormat.c_str(), arg_ptr); 7150 wsMessage.FormatV(wsFormat.c_str(), arg_ptr);
7151 va_end(arg_ptr); 7151 va_end(arg_ptr);
7152 FXJSE_ThrowMessage( 7152 FXJSE_ThrowMessage(
7153 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC()); 7153 "", FX_UTF8Encode(wsMessage.c_str(), wsMessage.GetLength()).AsStringC());
7154 } 7154 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698