| 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 "util.h" | 7 #include "util.h" |
| 8 | 8 |
| 9 #include "../../../core/include/fxcrt/fx_ext.h" | |
| 10 #include "../../include/javascript/IJavaScript.h" | 9 #include "../../include/javascript/IJavaScript.h" |
| 11 #include "JS_Context.h" | 10 #include "JS_Context.h" |
| 12 #include "JS_Define.h" | 11 #include "JS_Define.h" |
| 13 #include "JS_EventHandler.h" | 12 #include "JS_EventHandler.h" |
| 14 #include "JS_Object.h" | 13 #include "JS_Object.h" |
| 15 #include "JS_Runtime.h" | 14 #include "JS_Runtime.h" |
| 16 #include "JS_Value.h" | 15 #include "JS_Value.h" |
| 17 #include "PublicMethods.h" | 16 #include "PublicMethods.h" |
| 18 #include "resource.h" | 17 #include "resource.h" |
| 19 | 18 |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 for (int iIndex = 0; iIndex < (int)cFormat.size() && itSource < iSize; | 418 for (int iIndex = 0; iIndex < (int)cFormat.size() && itSource < iSize; |
| 420 iIndex++) { | 419 iIndex++) { |
| 421 char letter = cFormat[iIndex]; | 420 char letter = cFormat[iIndex]; |
| 422 switch (letter) { | 421 switch (letter) { |
| 423 case '?': | 422 case '?': |
| 424 cPurpose += cSource[itSource]; | 423 cPurpose += cSource[itSource]; |
| 425 itSource++; | 424 itSource++; |
| 426 break; | 425 break; |
| 427 case 'X': { | 426 case 'X': { |
| 428 while (itSource < iSize) { | 427 while (itSource < iSize) { |
| 429 if (std::isdigit(cSource[itSource]) || | 428 if ((cSource[itSource] >= '0' && cSource[itSource] <= '9') || |
| 430 (cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || | 429 (cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || |
| 431 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { | 430 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { |
| 432 cPurpose += cSource[itSource]; | 431 cPurpose += cSource[itSource]; |
| 433 itSource++; | 432 itSource++; |
| 434 break; | 433 break; |
| 435 } | 434 } |
| 436 itSource++; | 435 itSource++; |
| 437 } | 436 } |
| 438 break; | 437 break; |
| 439 } break; | 438 } break; |
| 440 case 'A': { | 439 case 'A': { |
| 441 while (itSource < iSize) { | 440 while (itSource < iSize) { |
| 442 if ((cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || | 441 if ((cSource[itSource] >= 'a' && cSource[itSource] <= 'z') || |
| 443 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { | 442 (cSource[itSource] >= 'A' && cSource[itSource] <= 'Z')) { |
| 444 cPurpose += cSource[itSource]; | 443 cPurpose += cSource[itSource]; |
| 445 itSource++; | 444 itSource++; |
| 446 break; | 445 break; |
| 447 } | 446 } |
| 448 itSource++; | 447 itSource++; |
| 449 } | 448 } |
| 450 break; | 449 break; |
| 451 } break; | 450 } break; |
| 452 case '9': { | 451 case '9': { |
| 453 while (itSource < iSize) { | 452 while (itSource < iSize) { |
| 454 if (std::isdigit(cSource[itSource])) { | 453 if (cSource[itSource] >= '0' && cSource[itSource] <= '9') { |
| 455 cPurpose += cSource[itSource]; | 454 cPurpose += cSource[itSource]; |
| 456 itSource++; | 455 itSource++; |
| 457 break; | 456 break; |
| 458 } | 457 } |
| 459 itSource++; | 458 itSource++; |
| 460 } | 459 } |
| 461 break; | 460 break; |
| 462 } | 461 } |
| 463 case '*': { | 462 case '*': { |
| 464 cPurpose.append(cSource, itSource, iSize - itSource); | 463 cPurpose.append(cSource, itSource, iSize - itSource); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 ++nptr; | 524 ++nptr; |
| 526 | 525 |
| 527 c = (int)(unsigned char)*nptr++; | 526 c = (int)(unsigned char)*nptr++; |
| 528 sign = c; /* save sign indication */ | 527 sign = c; /* save sign indication */ |
| 529 if (c == '-' || c == '+') | 528 if (c == '-' || c == '+') |
| 530 c = (int)(unsigned char)*nptr++; /* skip sign */ | 529 c = (int)(unsigned char)*nptr++; /* skip sign */ |
| 531 | 530 |
| 532 total = 0; | 531 total = 0; |
| 533 | 532 |
| 534 while (isdigit(c)) { | 533 while (isdigit(c)) { |
| 535 total = 10 * total + FXSYS_toDecimalDigit(c); /* accumulate digit */ | 534 total = 10 * total + (c - '0'); /* accumulate digit */ |
| 536 c = (int)(unsigned char)*nptr++; /* get next char */ | 535 c = (int)(unsigned char)*nptr++; /* get next char */ |
| 537 } | 536 } |
| 538 | 537 |
| 539 return sign == '-' ? -total : total; | 538 return sign == '-' ? -total : total; |
| 540 } | 539 } |
| 541 | 540 |
| 542 FX_BOOL util::byteToChar(IJS_Context* cc, | 541 FX_BOOL util::byteToChar(IJS_Context* cc, |
| 543 const CJS_Parameters& params, | 542 const CJS_Parameters& params, |
| 544 CJS_Value& vRet, | 543 CJS_Value& vRet, |
| 545 CFX_WideString& sError) { | 544 CFX_WideString& sError) { |
| 546 int iSize = params.size(); | 545 int iSize = params.size(); |
| 547 if (iSize == 0) | 546 if (iSize == 0) |
| 548 return FALSE; | 547 return FALSE; |
| 549 int nByte = params[0].ToInt(); | 548 int nByte = params[0].ToInt(); |
| 550 unsigned char cByte = (unsigned char)nByte; | 549 unsigned char cByte = (unsigned char)nByte; |
| 551 CFX_WideString csValue; | 550 CFX_WideString csValue; |
| 552 csValue.Format(L"%c", cByte); | 551 csValue.Format(L"%c", cByte); |
| 553 vRet = csValue.c_str(); | 552 vRet = csValue.c_str(); |
| 554 return TRUE; | 553 return TRUE; |
| 555 } | 554 } |
| OLD | NEW |