Changeset 96059 in vbox for trunk/src/VBox/Runtime/common/string/atoi.cpp
- Timestamp:
- Aug 5, 2022 11:27:49 AM (3 years ago)
- svn:sync-xref-src-repo-rev:
- 152858
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/string/atoi.cpp
r96053 r96059 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - No-CRT - strtol.3 * IPRT - No-CRT - atoi. 4 4 */ 5 5 … … 33 33 #include <iprt/nocrt/stdlib.h> 34 34 #include <iprt/nocrt/limits.h> 35 #include <iprt/nocrt/errno.h>36 35 #include <iprt/string.h> 37 36 38 37 39 #undef strtol40 long RT_NOCRT(strtol)(const char *psz, char **ppszNext, int iBase)38 #undef atoi 39 int RT_NOCRT(atoi)(const char *psz) 41 40 { 42 #if LONG_BIT == 64 43 int64_t iValue = 0; 44 int rc = RTStrToInt64Ex(psz, ppszNext, (unsigned)iBase, &iValue); 45 #elif LONG_BIT == 32 41 #if INT_MAX == INT32_MAX 46 42 int32_t iValue = 0; 47 int rc = RTStrToInt32Ex(psz, ppszNext, (unsigned)iBase, &iValue);43 int rc = RTStrToInt32Ex(psz, NULL, 10, &iValue); 48 44 #else 49 # error "Unsupported LONG_BIT value"45 # error "Unsupported integer size" 50 46 #endif 51 47 if (rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS || rc == VWRN_TRAILING_SPACES) 52 48 return iValue; 53 49 if (rc == VWRN_NUMBER_TOO_BIG) 54 { 55 errno = ERANGE; 56 return iValue < 0 ? LONG_MIN : LONG_MAX; 57 } 58 errno = EINVAL; 50 return iValue < 0 ? INT_MIN : INT_MAX; 59 51 return 0; 60 52 } 53 RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(atoi); 61 54
Note:
See TracChangeset
for help on using the changeset viewer.