diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index d3bde66205e..cdce4a2786d 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -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.@) *