VirtualBox

Changeset 96059 in vbox for trunk


Ignore:
Timestamp:
Aug 5, 2022 11:27:49 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
152858
Message:

IPRT/nocrt: Added atoi and corrected strto* aliasing. bugref:10261

Location:
trunk/src/VBox/Runtime
Files:
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/Makefile.kmk

    r96058 r96059  
    18061806        common/string/nocrt-strtoul.cpp \
    18071807        common/string/nocrt-strtoull.cpp \
     1808        common/string/atoi.cpp \
    18081809        common/string/strtok_r.cpp \
    18091810        r3/nocrt-per-thread-1.cpp \
  • trunk/src/VBox/Runtime/common/string/atoi.cpp

    r96053 r96059  
    11/* $Id$ */
    22/** @file
    3  * IPRT - No-CRT - strtol.
     3 * IPRT - No-CRT - atoi.
    44 */
    55
     
    3333#include <iprt/nocrt/stdlib.h>
    3434#include <iprt/nocrt/limits.h>
    35 #include <iprt/nocrt/errno.h>
    3635#include <iprt/string.h>
    3736
    3837
    39 #undef strtol
    40 long RT_NOCRT(strtol)(const char *psz, char **ppszNext, int iBase)
     38#undef atoi
     39int RT_NOCRT(atoi)(const char *psz)
    4140{
    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
    4642    int32_t iValue = 0;
    47     int rc = RTStrToInt32Ex(psz, ppszNext, (unsigned)iBase, &iValue);
     43    int rc = RTStrToInt32Ex(psz, NULL, 10, &iValue);
    4844#else
    49 # error "Unsupported LONG_BIT value"
     45# error "Unsupported integer size"
    5046#endif
    5147    if (rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS || rc == VWRN_TRAILING_SPACES)
    5248        return iValue;
    5349    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;
    5951    return 0;
    6052}
     53RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(atoi);
    6154
  • trunk/src/VBox/Runtime/common/string/nocrt-strtol.cpp

    r96053 r96059  
    5959    return 0;
    6060}
     61RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strtol);
    6162
  • trunk/src/VBox/Runtime/common/string/nocrt-strtoll.cpp

    r96056 r96059  
    5656    return 0;
    5757}
     58RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strtoll);
    5859
  • trunk/src/VBox/Runtime/common/string/nocrt-strtoul.cpp

    r96057 r96059  
    6060    return 0;
    6161}
     62RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strtoul);
    6263
  • trunk/src/VBox/Runtime/common/string/nocrt-strtoull.cpp

    r96058 r96059  
    5757    return 0;
    5858}
     59RT_ALIAS_AND_EXPORT_NOCRT_SYMBOL(strtoull);
    5960
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette