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

Side by Side Diff: fpdfsdk/src/javascript/util.cpp

Issue 1405253007: Revert "Revert "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix mac build Created 5 years, 1 month 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
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 "util.h" 7 #include "util.h"
8 8
9 #include "../../include/javascript/IJavaScript.h" 9 #include "../../include/javascript/IJavaScript.h"
10 #include "JS_Context.h" 10 #include "JS_Context.h"
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 for (int iIndex = 0; iIndex < (int)cFormat.size() && itSource < iSize; 418 for (int iIndex = 0; iIndex < (int)cFormat.size() && itSource < iSize;
419 iIndex++) { 419 iIndex++) {
420 char letter = cFormat[iIndex]; 420 char letter = cFormat[iIndex];
421 switch (letter) { 421 switch (letter) {
422 case '?': 422 case '?':
423 cPurpose += cSource[itSource]; 423 cPurpose += cSource[itSource];
424 itSource++; 424 itSource++;
425 break; 425 break;
426 case 'X': { 426 case 'X': {
427 while (itSource < iSize) { 427 while (itSource < iSize) {
428 if ((cSource[itSource] >= '0' && cSource[itSource] <= '9') || 428 if (std::isdigit(cSource[itSource]) ||
429 (cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || 429 (cSource[itSource] >= 'a' && cSource[itSource] <= 'z') ||
430 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { 430 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) {
431 cPurpose += cSource[itSource]; 431 cPurpose += cSource[itSource];
432 itSource++; 432 itSource++;
433 break; 433 break;
434 } 434 }
435 itSource++; 435 itSource++;
436 } 436 }
437 break; 437 break;
438 } break; 438 } break;
439 case 'A': { 439 case 'A': {
440 while (itSource < iSize) { 440 while (itSource < iSize) {
441 if ((cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || 441 if ((cSource[itSource] >= 'a' && cSource[itSource] <= 'z') ||
442 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { 442 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) {
443 cPurpose += cSource[itSource]; 443 cPurpose += cSource[itSource];
444 itSource++; 444 itSource++;
445 break; 445 break;
446 } 446 }
447 itSource++; 447 itSource++;
448 } 448 }
449 break; 449 break;
450 } break; 450 } break;
451 case '9': { 451 case '9': {
452 while (itSource < iSize) { 452 while (itSource < iSize) {
453 if (cSource[itSource] >= '0' && cSource[itSource] <= '9') { 453 if (std::isdigit(cSource[itSource])) {
454 cPurpose += cSource[itSource]; 454 cPurpose += cSource[itSource];
455 itSource++; 455 itSource++;
456 break; 456 break;
457 } 457 }
458 itSource++; 458 itSource++;
459 } 459 }
460 break; 460 break;
461 } 461 }
462 case '*': { 462 case '*': {
463 cPurpose.append(cSource, itSource, iSize - itSource); 463 cPurpose.append(cSource, itSource, iSize - itSource);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 int iSize = params.size(); 545 int iSize = params.size();
546 if (iSize == 0) 546 if (iSize == 0)
547 return FALSE; 547 return FALSE;
548 int nByte = params[0].ToInt(); 548 int nByte = params[0].ToInt();
549 unsigned char cByte = (unsigned char)nByte; 549 unsigned char cByte = (unsigned char)nByte;
550 CFX_WideString csValue; 550 CFX_WideString csValue;
551 csValue.Format(L"%c", cByte); 551 csValue.Format(L"%c", cByte);
552 vRet = csValue.c_str(); 552 vRet = csValue.c_str();
553 return TRUE; 553 return TRUE;
554 } 554 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698