Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(29)

Side by Side Diff: fpdfsdk/src/javascript/PublicMethods.cpp

Issue 1757283002: Combine StrToInt methods. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/PublicMethods.h" 7 #include "fpdfsdk/src/javascript/PublicMethods.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 int nRet = 0; 235 int nRet = 0;
236 nSkip = 0; 236 nSkip = 0;
237 for (int i = nStart, sz = string.GetLength(); i < sz; i++) { 237 for (int i = nStart, sz = string.GetLength(); i < sz; i++) {
238 if (i - nStart > 10) 238 if (i - nStart > 10)
239 break; 239 break;
240 240
241 FX_WCHAR c = string.GetAt(i); 241 FX_WCHAR c = string.GetAt(i);
242 if (!FXSYS_iswdigit(c)) 242 if (!FXSYS_iswdigit(c))
243 break; 243 break;
244 244
245 nRet = nRet * 10 + FXSYS_toDecimalDigitWide(c); 245 nRet = nRet * 10 + FXSYS_toDecimalDigit(c);
246 nSkip = i - nStart + 1; 246 nSkip = i - nStart + 1;
247 if (nSkip >= nMaxStep) 247 if (nSkip >= nMaxStep)
248 break; 248 break;
249 } 249 }
250 250
251 return nRet; 251 return nRet;
252 } 252 }
253 253
254 CFX_WideString CJS_PublicMethods::ParseStringString( 254 CFX_WideString CJS_PublicMethods::ParseStringString(
255 const CFX_WideString& string, 255 const CFX_WideString& string,
(...skipping 1650 matching lines...) Expand 10 before | Expand all | Expand 10 after
1906 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str())); 1906 nums.SetElement(nIndex, CJS_Value(pRuntime, sPart.c_str()));
1907 } 1907 }
1908 1908
1909 if (nums.GetLength() > 0) 1909 if (nums.GetLength() > 0)
1910 vRet = nums; 1910 vRet = nums;
1911 else 1911 else
1912 vRet.SetNull(); 1912 vRet.SetNull();
1913 1913
1914 return TRUE; 1914 return TRUE;
1915 } 1915 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698