Commit c3c44544 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Call MSVCRT_strtoi64_l in strtol implementation.

parent b01f8881
...@@ -727,40 +727,6 @@ int CDECL __STRINGTOLD( MSVCRT__LDOUBLE *value, char **endptr, const char *str, ...@@ -727,40 +727,6 @@ int CDECL __STRINGTOLD( MSVCRT__LDOUBLE *value, char **endptr, const char *str,
} }
/****************************************************************** /******************************************************************
* 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.@) * strtoul (MSVCRT.@)
*/ */
MSVCRT_ulong CDECL MSVCRT_strtoul(const char* nptr, char** end, int base) MSVCRT_ulong CDECL MSVCRT_strtoul(const char* nptr, char** end, int base)
...@@ -934,6 +900,24 @@ int __cdecl MSVCRT_atoi(const char *str) ...@@ -934,6 +900,24 @@ int __cdecl MSVCRT_atoi(const char *str)
return minus ? -ret : ret; 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.@) * _strtoui64_l (MSVCRT.@)
* *
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment