msvcrt: Call MSVCRT_strtoi64_l in strtol implementation.
This commit is contained in:
parent
b01f888129
commit
c3c44544ff
|
@ -726,40 +726,6 @@ int CDECL __STRINGTOLD( MSVCRT__LDOUBLE *value, char **endptr, const char *str,
|
|||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* strtol (MSVCRT.@)
|
||||
*/
|
||||
MSVCRT_long CDECL MSVCRT_strtol(const char* nptr, char** end, int base)
|
||||
{
|
||||
/* wrapper to forward libc error code to msvcrt's error codes */
|
||||
long ret;
|
||||
|
||||
errno = 0;
|
||||
ret = strtol(nptr, end, base);
|
||||
switch (errno)
|
||||
{
|
||||
case ERANGE: *MSVCRT__errno() = MSVCRT_ERANGE; break;
|
||||
case EINVAL: *MSVCRT__errno() = MSVCRT_EINVAL; break;
|
||||
default:
|
||||
/* cope with the fact that we may use 64bit long integers on libc
|
||||
* while msvcrt always uses 32bit long integers
|
||||
*/
|
||||
if (ret > MSVCRT_LONG_MAX)
|
||||
{
|
||||
ret = MSVCRT_LONG_MAX;
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
}
|
||||
else if (ret < -MSVCRT_LONG_MAX - 1)
|
||||
{
|
||||
ret = -MSVCRT_LONG_MAX - 1;
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* strtoul (MSVCRT.@)
|
||||
*/
|
||||
|
@ -934,6 +900,24 @@ int __cdecl MSVCRT_atoi(const char *str)
|
|||
return minus ? -ret : ret;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* strtol (MSVCRT.@)
|
||||
*/
|
||||
MSVCRT_long CDECL MSVCRT_strtol(const char* nptr, char** end, int base)
|
||||
{
|
||||
__int64 ret = MSVCRT_strtoi64_l(nptr, end, base, NULL);
|
||||
|
||||
if(ret > MSVCRT_LONG_MAX) {
|
||||
ret = MSVCRT_LONG_MAX;
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
} else if(ret < MSVCRT_LONG_MIN) {
|
||||
ret = MSVCRT_LONG_MIN;
|
||||
*MSVCRT__errno() = MSVCRT_ERANGE;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _strtoui64_l (MSVCRT.@)
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue