| 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 <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "../../include/fxcrt/fx_ext.h" | 9 #include "../../include/fxcrt/fx_ext.h" |
| 10 #include "../../include/fxcrt/fx_string.h" | 10 #include "../../include/fxcrt/fx_string.h" |
| 11 | 11 |
| 12 template <class T, class STR_T> | 12 template <class T, class STR_T> |
| 13 T FXSYS_StrToInt(STR_T str) | 13 T FXSYS_StrToInt(STR_T str) |
| 14 { | 14 { |
| 15 FX_BOOL neg = FALSE; | 15 bool neg = false; |
| 16 if (str == NULL) { | 16 if (str == NULL) { |
| 17 return 0; | 17 return 0; |
| 18 } | 18 } |
| 19 if (*str == '-') { | 19 if (*str == '-') { |
| 20 neg = TRUE; | 20 neg = true; |
| 21 str ++; | 21 str ++; |
| 22 } | 22 } |
| 23 T num = 0; | 23 T num = 0; |
| 24 while (*str) { | 24 while (*str) { |
| 25 if ((*str) < '0' || (*str) > '9') { | 25 if ((*str) < '0' || (*str) > '9') { |
| 26 break; | 26 break; |
| 27 } | 27 } |
| 28 if (num > (std::numeric_limits<T>::max() - 9) / 10) { | 28 if (num > (std::numeric_limits<T>::max() - 9) / 10) { |
| 29 break; | 29 break; |
| 30 } | 30 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 buf[wlen] = bstr[i]; | 230 buf[wlen] = bstr[i]; |
| 231 } | 231 } |
| 232 wlen ++; | 232 wlen ++; |
| 233 } | 233 } |
| 234 return wlen; | 234 return wlen; |
| 235 } | 235 } |
| 236 #ifdef __cplusplus | 236 #ifdef __cplusplus |
| 237 } | 237 } |
| 238 #endif | 238 #endif |
| 239 #endif | 239 #endif |
| OLD | NEW |