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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 | 505 |
506 if (!JS_PortIsNan(dDate)) { | 506 if (!JS_PortIsNan(dDate)) { |
507 vRet = CJS_Date(CJS_Runtime::FromContext(cc), dDate); | 507 vRet = CJS_Date(CJS_Runtime::FromContext(cc), dDate); |
508 } else { | 508 } else { |
509 vRet.SetNull(); | 509 vRet.SetNull(); |
510 } | 510 } |
511 | 511 |
512 return TRUE; | 512 return TRUE; |
513 } | 513 } |
514 | 514 |
515 int64_t FX_atoi64(const char* nptr) { | |
516 int c; /* current char */ | |
517 int64_t total; /* current total */ | |
518 int sign; /* if '-', then negative, otherwise positive */ | |
519 | |
520 /* skip whitespace */ | |
521 while (isspace((int)(unsigned char)*nptr)) | |
522 ++nptr; | |
523 | |
524 c = (int)(unsigned char)*nptr++; | |
525 sign = c; /* save sign indication */ | |
526 if (c == '-' || c == '+') | |
527 c = (int)(unsigned char)*nptr++; /* skip sign */ | |
528 | |
529 total = 0; | |
530 | |
531 while (isdigit(c)) { | |
532 total = 10 * total + FXSYS_toDecimalDigit(c); /* accumulate digit */ | |
533 c = (int)(unsigned char)*nptr++; /* get next char */ | |
534 } | |
535 | |
536 return sign == '-' ? -total : total; | |
537 } | |
538 | |
539 FX_BOOL util::byteToChar(IJS_Context* cc, | 515 FX_BOOL util::byteToChar(IJS_Context* cc, |
540 const std::vector<CJS_Value>& params, | 516 const std::vector<CJS_Value>& params, |
541 CJS_Value& vRet, | 517 CJS_Value& vRet, |
542 CFX_WideString& sError) { | 518 CFX_WideString& sError) { |
543 int iSize = params.size(); | 519 int iSize = params.size(); |
544 if (iSize == 0) | 520 if (iSize == 0) |
545 return FALSE; | 521 return FALSE; |
546 int nByte = params[0].ToInt(); | 522 int nByte = params[0].ToInt(); |
547 unsigned char cByte = (unsigned char)nByte; | 523 unsigned char cByte = (unsigned char)nByte; |
548 CFX_WideString csValue; | 524 CFX_WideString csValue; |
549 csValue.Format(L"%c", cByte); | 525 csValue.Format(L"%c", cByte); |
550 vRet = csValue.c_str(); | 526 vRet = csValue.c_str(); |
551 return TRUE; | 527 return TRUE; |
552 } | 528 } |
OLD | NEW |