| 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 "PublicMethods.h" | 7 #include "PublicMethods.h" |
| 8 | 8 |
| 9 #include "../../../core/include/fxcrt/fx_ext.h" | |
| 10 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. | 9 #include "../../include/fsdk_mgr.h" // For CPDFDoc_Environment. |
| 11 #include "../../include/javascript/IJavaScript.h" | 10 #include "../../include/javascript/IJavaScript.h" |
| 12 #include "Field.h" | 11 #include "Field.h" |
| 13 #include "JS_Context.h" | 12 #include "JS_Context.h" |
| 14 #include "JS_Define.h" | 13 #include "JS_Define.h" |
| 15 #include "JS_EventHandler.h" | 14 #include "JS_EventHandler.h" |
| 16 #include "JS_Object.h" | 15 #include "JS_Object.h" |
| 17 #include "JS_Runtime.h" | 16 #include "JS_Runtime.h" |
| 18 #include "JS_Value.h" | 17 #include "JS_Value.h" |
| 19 #include "color.h" | 18 #include "color.h" |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 109 } |
| 111 | 110 |
| 112 return TRUE; | 111 return TRUE; |
| 113 } | 112 } |
| 114 | 113 |
| 115 FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) { | 114 FX_BOOL CJS_PublicMethods::IsDigit(wchar_t ch) { |
| 116 return (ch >= L'0' && ch <= L'9'); | 115 return (ch >= L'0' && ch <= L'9'); |
| 117 } | 116 } |
| 118 | 117 |
| 119 FX_BOOL CJS_PublicMethods::IsDigit(char ch) { | 118 FX_BOOL CJS_PublicMethods::IsDigit(char ch) { |
| 120 return std::isdigit(ch); | 119 return (ch >= '0' && ch <= '9'); |
| 121 } | 120 } |
| 122 | 121 |
| 123 FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) { | 122 FX_BOOL CJS_PublicMethods::IsAlphabetic(wchar_t ch) { |
| 124 return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z')); | 123 return ((ch >= L'a' && ch <= L'z') || (ch >= L'A' && ch <= L'Z')); |
| 125 } | 124 } |
| 126 | 125 |
| 127 FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) { | 126 FX_BOOL CJS_PublicMethods::IsAlphaNumeric(wchar_t ch) { |
| 128 return (IsDigit(ch) || IsAlphabetic(ch)); | 127 return (IsDigit(ch) || IsAlphabetic(ch)); |
| 129 } | 128 } |
| 130 | 129 |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 int& nSkip, | 389 int& nSkip, |
| 391 int nMaxStep) { | 390 int nMaxStep) { |
| 392 int nRet = 0; | 391 int nRet = 0; |
| 393 nSkip = 0; | 392 nSkip = 0; |
| 394 for (int i = nStart, sz = string.GetLength(); i < sz; i++) { | 393 for (int i = nStart, sz = string.GetLength(); i < sz; i++) { |
| 395 if (i - nStart > 10) | 394 if (i - nStart > 10) |
| 396 break; | 395 break; |
| 397 | 396 |
| 398 FX_WCHAR c = string.GetAt(i); | 397 FX_WCHAR c = string.GetAt(i); |
| 399 if (IsDigit((wchar_t)c)) { | 398 if (IsDigit((wchar_t)c)) { |
| 400 nRet = nRet * 10 + FXSYS_toDecimalDigit(c); | 399 nRet = nRet * 10 + (c - '0'); |
| 401 nSkip = i - nStart + 1; | 400 nSkip = i - nStart + 1; |
| 402 if (nSkip >= nMaxStep) | 401 if (nSkip >= nMaxStep) |
| 403 break; | 402 break; |
| 404 } else | 403 } else |
| 405 break; | 404 break; |
| 406 } | 405 } |
| 407 | 406 |
| 408 return nRet; | 407 return nRet; |
| 409 } | 408 } |
| 410 | 409 |
| (...skipping 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2078 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); | 2077 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); |
| 2079 } | 2078 } |
| 2080 | 2079 |
| 2081 if (nums.GetLength() > 0) | 2080 if (nums.GetLength() > 0) |
| 2082 vRet = nums; | 2081 vRet = nums; |
| 2083 else | 2082 else |
| 2084 vRet.SetNull(); | 2083 vRet.SetNull(); |
| 2085 | 2084 |
| 2086 return TRUE; | 2085 return TRUE; |
| 2087 } | 2086 } |
| OLD | NEW |