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