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 | |
226 while (*p) p++; | 225 while (*p) p++; |
227 » p--; | 226 » while (p > pStr && *(p - 1) == L' ') p--; |
jun_fang
2014/07/23 07:04:18
can you add a blank line between while and return?
Tom Sepez
2014/07/23 16:56:49
Done.
| |
228 » if (p >= pStr) | 227 » return CFX_WideString(pStr, p - pStr); |
229 » {» » | |
230 » » while (*p && *p == L' ') p--; | |
231 » » p++; | |
232 » » return CFX_WideString(pStr,p-pStr); | |
233 » } | |
234 » return L""; | |
235 } | 228 } |
236 | 229 |
237 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) | 230 CFX_WideString CJS_PublicMethods::StrTrim(FX_LPCWSTR pStr) |
238 { | 231 { |
239 return StrRTrim(StrLTrim(pStr)); | 232 return StrRTrim(StrLTrim(pStr)); |
240 } | 233 } |
241 | 234 |
242 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) | 235 CFX_ByteString CJS_PublicMethods::StrLTrim(FX_LPCSTR pStr) |
243 { | 236 { |
244 while (*pStr && *pStr == ' ') pStr++; | 237 while (*pStr && *pStr == ' ') pStr++; |
245 | 238 |
246 return pStr; | 239 return pStr; |
247 } | 240 } |
248 | 241 |
249 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) | 242 CFX_ByteString CJS_PublicMethods::StrRTrim(FX_LPCSTR pStr) |
250 { | 243 { |
251 FX_LPCSTR p = pStr; | 244 FX_LPCSTR p = pStr; |
252 | |
253 while (*p) p++; | 245 while (*p) p++; |
254 » p--; | 246 » while (p > pStr && *(p - 1) == L' ') p--; |
jun_fang
2014/07/23 07:04:18
The same as the previous one.
Tom Sepez
2014/07/23 16:56:49
Done.
| |
255 » if (p >= pStr) | 247 » return CFX_ByteString(pStr,p-pStr); |
256 » {» » | |
257 » » while (*p && *p == ' ') p--; | |
258 » » p++; | |
259 » » return CFX_ByteString(pStr,p-pStr); | |
260 » } | |
261 » return ""; | |
262 } | 248 } |
263 | 249 |
264 CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr) | 250 CFX_ByteString CJS_PublicMethods::StrTrim(FX_LPCSTR pStr) |
265 { | 251 { |
266 return StrRTrim(StrLTrim(pStr)); | 252 return StrRTrim(StrLTrim(pStr)); |
267 } | 253 } |
268 | 254 |
269 double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) | 255 double CJS_PublicMethods::ParseNumber(FX_LPCWSTR swSource, FX_BOOL& bAllDigits, FX_BOOL& bDot, FX_BOOL& bSign, FX_BOOL& bKXJS) |
270 { | 256 { |
271 bDot = FALSE; | 257 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)); | 2313 nums.SetElement(nIndex,CJS_Value(isolate,(FX_LPCWSTR)sPart)); |
2328 } | 2314 } |
2329 | 2315 |
2330 if (nums.GetLength() > 0) | 2316 if (nums.GetLength() > 0) |
2331 vRet = nums; | 2317 vRet = nums; |
2332 else | 2318 else |
2333 vRet.SetNull(); | 2319 vRet.SetNull(); |
2334 | 2320 |
2335 return TRUE; | 2321 return TRUE; |
2336 } | 2322 } |
OLD | NEW |