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 "fpdfsdk/src/javascript/util.h" | 7 #include "fpdfsdk/src/javascript/util.h" |
8 | 8 |
9 #include <time.h> | 9 #include <time.h> |
10 | 10 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
510 } | 510 } |
511 | 511 |
512 return TRUE; | 512 return TRUE; |
513 } | 513 } |
514 | 514 |
515 int64_t FX_atoi64(const char* nptr) { | 515 int64_t FX_atoi64(const char* nptr) { |
516 int c; /* current char */ | 516 int c; /* current char */ |
517 int64_t total; /* current total */ | 517 int64_t total; /* current total */ |
518 int sign; /* if '-', then negative, otherwise positive */ | 518 int sign; /* if '-', then negative, otherwise positive */ |
519 | 519 |
520 /* skip whitespace */ | 520 /* skip whitespace */ |
Tom Sepez
2016/03/03 21:43:03
nit: I'd feel better here if we immediately create
dsinclair
2016/03/03 22:01:43
I'll do one better and just delete the whole metho
Tom Sepez
2016/03/03 22:10:31
Acknowledged.
| |
521 while (isspace((int)(unsigned char)*nptr)) | 521 while (isspace((int)(unsigned char)*nptr)) |
522 ++nptr; | 522 ++nptr; |
523 | 523 |
524 c = (int)(unsigned char)*nptr++; | 524 c = (int)(unsigned char)*nptr++; |
525 sign = c; /* save sign indication */ | 525 sign = c; /* save sign indication */ |
526 if (c == '-' || c == '+') | 526 if (c == '-' || c == '+') |
527 c = (int)(unsigned char)*nptr++; /* skip sign */ | 527 c = (int)(unsigned char)*nptr++; /* skip sign */ |
528 | 528 |
529 total = 0; | 529 total = 0; |
530 | 530 |
531 while (isdigit(c)) { | 531 while (isdigit(c)) { |
532 total = 10 * total + FXSYS_toDecimalDigit(c); /* accumulate digit */ | 532 total = 10 * total + FXSYS_toDecimalDigit(static_cast<FX_WCHAR>(c)); |
533 c = (int)(unsigned char)*nptr++; /* get next char */ | 533 c = (int)(unsigned char)*nptr++; |
534 } | 534 } |
535 | 535 |
536 return sign == '-' ? -total : total; | 536 return sign == '-' ? -total : total; |
537 } | 537 } |
538 | 538 |
539 FX_BOOL util::byteToChar(IJS_Context* cc, | 539 FX_BOOL util::byteToChar(IJS_Context* cc, |
540 const std::vector<CJS_Value>& params, | 540 const std::vector<CJS_Value>& params, |
541 CJS_Value& vRet, | 541 CJS_Value& vRet, |
542 CFX_WideString& sError) { | 542 CFX_WideString& sError) { |
543 int iSize = params.size(); | 543 int iSize = params.size(); |
544 if (iSize == 0) | 544 if (iSize == 0) |
545 return FALSE; | 545 return FALSE; |
546 int nByte = params[0].ToInt(); | 546 int nByte = params[0].ToInt(); |
547 unsigned char cByte = (unsigned char)nByte; | 547 unsigned char cByte = (unsigned char)nByte; |
548 CFX_WideString csValue; | 548 CFX_WideString csValue; |
549 csValue.Format(L"%c", cByte); | 549 csValue.Format(L"%c", cByte); |
550 vRet = csValue.c_str(); | 550 vRet = csValue.c_str(); |
551 return TRUE; | 551 return TRUE; |
552 } | 552 } |
OLD | NEW |