VirtualBox

Ignore:
Timestamp:
Aug 5, 2022 11:03:58 AM (2 years ago)
Author:
vboxsync
Message:

IPRT/nocrt: Added strtoll and strtoul. bugref:10261

Location:
trunk/src/VBox/Runtime/common/string
Files:
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/common/string/nocrt-strtoll.cpp

    r96053 r96056  
    11/* $Id$ */
    22/** @file
    3  * IPRT - No-CRT - strtol.
     3 * IPRT - No-CRT - strtoll.
    44 */
    55
     
    3737
    3838
    39 #undef strtol
    40 long RT_NOCRT(strtol)(const char *psz, char **ppszNext, int iBase)
     39#undef strtoll
     40long long RT_NOCRT(strtoll)(const char *psz, char **ppszNext, int iBase)
    4141{
    42 #if LONG_BIT == 64
     42#if LLONG_BIT == 64
    4343    int64_t iValue = 0;
    4444    int rc = RTStrToInt64Ex(psz, ppszNext, (unsigned)iBase, &iValue);
    45 #elif LONG_BIT == 32
    46     int32_t iValue = 0;
    47     int rc = RTStrToInt32Ex(psz, ppszNext, (unsigned)iBase, &iValue);
    4845#else
    49 # error "Unsupported LONG_BIT value"
     46# error "Unsupported LLONG_BIT value"
    5047#endif
    5148    if (rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS || rc == VWRN_TRAILING_SPACES)
  • trunk/src/VBox/Runtime/common/string/nocrt-strtoul.cpp

    r96053 r96056  
    11/* $Id$ */
    22/** @file
    3  * IPRT - No-CRT - strtol.
     3 * IPRT - No-CRT - strtoul.
    44 */
    55
     
    3737
    3838
    39 #undef strtol
    40 long RT_NOCRT(strtol)(const char *psz, char **ppszNext, int iBase)
     39#undef strtoul
     40long RT_NOCRT(strtoul)(const char *psz, char **ppszNext, int iBase)
    4141{
    42 #if LONG_BIT == 64
    43     int64_t iValue = 0;
    44     int rc = RTStrToInt64Ex(psz, ppszNext, (unsigned)iBase, &iValue);
    45 #elif LONG_BIT == 32
    46     int32_t iValue = 0;
    47     int rc = RTStrToInt32Ex(psz, ppszNext, (unsigned)iBase, &iValue);
     42#if ULONG_BIT == 64
     43    uint64_t uValue = 0;
     44    int rc = RTStrToUInt64Ex(psz, ppszNext, (unsigned)iBase, &uiValue);
     45#elif ULONG_BIT == 32
     46    int32_t uValue = 0;
     47    int rc = RTStrToUInt32Ex(psz, ppszNext, (unsigned)iBase, &uiValue);
    4848#else
    4949# error "Unsupported LONG_BIT value"
    5050#endif
    51     if (rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS || rc == VWRN_TRAILING_SPACES)
    52         return iValue;
     51    if (rc == VINF_SUCCESS || rc == VWRN_TRAILING_CHARS || rc == VWRN_TRAILING_SPACES || rc == VWRN_NEGATIVE_UNSIGNED)
     52        return uValue;
    5353    if (rc == VWRN_NUMBER_TOO_BIG)
    5454    {
    5555        errno = ERANGE;
    56         return iValue < 0 ? LONG_MIN : LONG_MAX;
     56        return ULONG_MAX;
    5757    }
    5858    errno = EINVAL;
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