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 "../../include/javascript/JavaScript.h" | 7 #include "../../include/javascript/JavaScript.h" |
8 #include "../../include/javascript/IJavaScript.h" | 8 #include "../../include/javascript/IJavaScript.h" |
9 #include "../../include/javascript/JS_Define.h" | 9 #include "../../include/javascript/JS_Define.h" |
10 #include "../../include/javascript/JS_Object.h" | 10 #include "../../include/javascript/JS_Object.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 CFX_WideString CJS_PublicMethods::StrLTrim(FX_LPCWSTR pStr) | 215 CFX_WideString CJS_PublicMethods::StrLTrim(FX_LPCWSTR pStr) |
216 { | 216 { |
217 while (*pStr && *pStr == L' ') pStr++; | 217 while (*pStr && *pStr == L' ') pStr++; |
218 | 218 |
219 return pStr; | 219 return pStr; |
220 } | 220 } |
221 | 221 |
222 CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr) | 222 CFX_WideString CJS_PublicMethods::StrRTrim(FX_LPCWSTR pStr) |
223 { | 223 { |
224 FX_LPCWSTR p = pStr; | 224 FX_LPCWSTR p = pStr; |
| 225 while (*p) p++; |
| 226 while (p > pStr && *(p - 1) == L' ') p--; |
225 | 227 |
226 » while (*p) p++; | 228 » return CFX_WideString(pStr, p - pStr); |
227 » p--; | |
228 » if (p >= pStr) | |
229 » {» » | |
230 » » while (*p && *p == L' ') p--; | |
231 » » p++; | |
232 » » return CFX_WideString(pStr,p-pStr); | |
233 » } | |
234 » return L""; | |
235 } | 229 } |
236 | 230 |
237 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) | 231 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) |
238 { | 232 { |
239 return StrRTrim(StrLTrim(pStr)); | 233 return StrRTrim(StrLTrim(pStr)); |
240 } | 234 } |
241 | 235 |
242 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) | 236 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) |
243 { | 237 { |
244 while (*pStr && *pStr == ' ') pStr++; | 238 while (*pStr && *pStr == ' ') pStr++; |
245 | 239 |
246 return pStr; | 240 return pStr; |
247 } | 241 } |
248 | 242 |
249 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) | 243 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) |
250 { | 244 { |
251 FX_LPCSTR p = pStr; | 245 FX_LPCSTR p = pStr; |
| 246 while (*p) p++; |
| 247 while (p > pStr && *(p - 1) == L' ') p--; |
252 | 248 |
253 » while (*p) p++; | 249 » return CFX_ByteString(pStr,p-pStr); |
254 » p--; | |
255 » if (p >= pStr) | |
256 » {» » | |
257 » » while (*p && *p == ' ') p--; | |
258 » » p++; | |
259 » » return CFX_ByteString(pStr,p-pStr); | |
260 » } | |
261 » return ""; | |
262 } | 250 } |
263 | 251 |
264 CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr) | 252 CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr) |
265 { | 253 { |
266 return StrRTrim(StrLTrim(pStr)); | 254 return StrRTrim(StrLTrim(pStr)); |
267 } | 255 } |
268 | 256 |
269 double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits,
FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) | 257 double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits,
FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) |
270 { | 258 { |
271 bDot = FALSE; | 259 bDot = FALSE; |
(...skipping 2055 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2327 nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart)); | 2315 nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart)); |
2328 } | 2316 } |
2329 | 2317 |
2330 if (nums.GetLength() > 0) | 2318 if (nums.GetLength() > 0) |
2331 vRet = nums; | 2319 vRet = nums; |
2332 else | 2320 else |
2333 vRet.SetNull(); | 2321 vRet.SetNull(); |
2334 | 2322 |
2335 return TRUE; | 2323 return TRUE; |
2336 } | 2324 } |
OLD | NEW |