diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec index 3cc641ec2eb..6ead0a77f42 100644 --- a/dlls/msvcr80/msvcr80.spec +++ b/dlls/msvcr80/msvcr80.spec @@ -1106,13 +1106,13 @@ @ cdecl _wcsset(wstr long) msvcrt._wcsset @ stub _wcsset_s @ cdecl _wcstod_l(wstr ptr) msvcrt._wcstod_l -@ stub _wcstoi64 -@ stub _wcstoi64_l +@ cdecl _wcstoi64(wstr ptr long) msvcrt._wcstoi64 +@ cdecl _wcstoi64_l(wstr ptr long ptr) msvcrt._wcstoi64_l @ stub _wcstol_l @ stub _wcstombs_l @ stub _wcstombs_s_l -@ stub _wcstoui64 -@ stub _wcstoui64_l +@ cdecl _wcstoui64(wstr ptr long) msvcrt._wcstoui64 +@ cdecl _wcstoui64_l(wstr ptr long ptr) msvcrt._wcstoui64_l @ stub _wcstoul_l @ cdecl _wcsupr(wstr) msvcrt._wcsupr @ stub _wcsupr_l diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec index 59a71ba6feb..72dff798245 100644 --- a/dlls/msvcr90/msvcr90.spec +++ b/dlls/msvcr90/msvcr90.spec @@ -1093,13 +1093,13 @@ @ cdecl _wcsset(wstr long) msvcrt._wcsset @ stub _wcsset_s @ cdecl _wcstod_l(wstr ptr) msvcrt._wcstod_l -@ stub _wcstoi64 -@ stub _wcstoi64_l +@ cdecl _wcstoi64(wstr ptr long) msvcrt._wcstoi64 +@ cdecl _wcstoi64_l(wstr ptr long ptr) msvcrt._wcstoi64_l @ stub _wcstol_l @ stub _wcstombs_l @ stub _wcstombs_s_l -@ stub _wcstoui64 -@ stub _wcstoui64_l +@ cdecl _wcstoui64(wstr ptr long) msvcrt._wcstoui64 +@ cdecl _wcstoui64_l(wstr ptr long ptr) msvcrt._wcstoui64_l @ stub _wcstoul_l @ cdecl _wcsupr(wstr) msvcrt._wcsupr @ stub _wcsupr_l diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec index e5bbaf4dec4..5f82cf1b9e2 100644 --- a/dlls/msvcrt/msvcrt.spec +++ b/dlls/msvcrt/msvcrt.spec @@ -1035,13 +1035,13 @@ @ cdecl _wcsrev(wstr) @ cdecl _wcsset(wstr long) # stub _wcsset_s -# stub _wcstoi64 -# stub _wcstoi64_l +@ cdecl _wcstoi64(wstr ptr long) MSVCRT__wcstoi64 +@ cdecl _wcstoi64_l(wstr ptr long ptr) MSVCRT__wcstoi64_l # stub _wcstol_l # stub _wcstombs_l # stub _wcstombs_s_l -# stub _wcstoui64 -# stub _wcstoui64_l +@ cdecl _wcstoui64(wstr ptr long) MSVCRT__wcstoui64 +@ cdecl _wcstoui64_l(wstr ptr long ptr) MSVCRT__wcstoui64_l # stub _wcstoul_l @ cdecl _wcsupr(wstr) ntdll._wcsupr # stub _wcsupr_l diff --git a/dlls/msvcrt/string.c b/dlls/msvcrt/string.c index 459d1a1cd91..7d578a33bae 100644 --- a/dlls/msvcrt/string.c +++ b/dlls/msvcrt/string.c @@ -529,10 +529,10 @@ __int64 CDECL MSVCRT_strtoi64_l(const char *nptr, char **endptr, int base, MSVCR if(!negative && (ret>MSVCRT_I64_MAX/base || ret*base>MSVCRT_I64_MAX-v)) { ret = MSVCRT_I64_MAX; - *MSVCRT__errno() = ERANGE; + *MSVCRT__errno() = MSVCRT_ERANGE; } else if(negative && (retMSVCRT_UI64_MAX/base || ret*base>MSVCRT_UI64_MAX-v) { ret = MSVCRT_UI64_MAX; - *MSVCRT__errno() = ERANGE; + *MSVCRT__errno() = MSVCRT_ERANGE; } else ret = ret*base + v; } diff --git a/dlls/msvcrt/wcs.c b/dlls/msvcrt/wcs.c index 44a3b4d8b8d..04d90dea4b6 100644 --- a/dlls/msvcrt/wcs.c +++ b/dlls/msvcrt/wcs.c @@ -1408,3 +1408,161 @@ INT CDECL MSVCRT_wcscat_s(MSVCRT_wchar_t* dst, MSVCRT_size_t elem, const MSVCRT_ dst[0] = '\0'; return MSVCRT_ERANGE; } + +/********************************************************************* + * _wctoi64_l (MSVCR90.@) + * + * FIXME: locale parameter is ignored + */ +__int64 CDECL MSVCRT__wcstoi64_l(const MSVCRT_wchar_t *nptr, + MSVCRT_wchar_t **endptr, int base, MSVCRT__locale_t locale) +{ + BOOL negative = FALSE; + __int64 ret = 0; + + TRACE("(%s %p %d %p)\n", debugstr_w(nptr), endptr, base, locale); + + if(!nptr || base<0 || base>36 || base==1) { + MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0); + return 0; + } + + while(isspaceW(*nptr)) nptr++; + + if(*nptr == '-') { + negative = TRUE; + nptr++; + } else if(*nptr == '+') + nptr++; + + if((base==0 || base==16) && *nptr=='0' && tolowerW(*(nptr+1))=='x') { + base = 16; + nptr += 2; + } + + if(base == 0) { + if(*nptr=='0') + base = 8; + else + base = 10; + } + + while(*nptr) { + char cur = tolowerW(*nptr); + int v; + + if(isdigitW(cur)) { + if(cur >= '0'+base) + break; + v = cur-'0'; + } else { + if(cur<'a' || cur>='a'+base-10) + break; + v = cur-'a'+10; + } + + if(negative) + v = -v; + + nptr++; + + if(!negative && (ret>MSVCRT_I64_MAX/base || ret*base>MSVCRT_I64_MAX-v)) { + ret = MSVCRT_I64_MAX; + *MSVCRT__errno() = MSVCRT_ERANGE; + } else if(negative && (ret36 || base==1) { + MSVCRT__invalid_parameter(NULL, NULL, NULL, 0, 0); + return 0; + } + + while(isspaceW(*nptr)) nptr++; + + if(*nptr == '-') { + negative = TRUE; + nptr++; + } else if(*nptr == '+') + nptr++; + + if((base==0 || base==16) && *nptr=='0' && tolowerW(*(nptr+1))=='x') { + base = 16; + nptr += 2; + } + + if(base == 0) { + if(*nptr=='0') + base = 8; + else + base = 10; + } + + while(*nptr) { + char cur = tolowerW(*nptr); + int v; + + if(isdigit(cur)) { + if(cur >= '0'+base) + break; + v = *nptr-'0'; + } else { + if(cur<'a' || cur>='a'+base-10) + break; + v = cur-'a'+10; + } + + nptr++; + + if(ret>MSVCRT_UI64_MAX/base || ret*base>MSVCRT_UI64_MAX-v) { + ret = MSVCRT_UI64_MAX; + *MSVCRT__errno() = MSVCRT_ERANGE; + } else + ret = ret*base + v; + } + + if(endptr) + *endptr = (MSVCRT_wchar_t*)nptr; + + return negative ? -ret : ret; +} + +/********************************************************************* + * _wcstoui64 (MSVCR90.@) + */ +unsigned __int64 CDECL MSVCRT__wcstoui64(const MSVCRT_wchar_t *nptr, + MSVCRT_wchar_t **endptr, int base) +{ + return MSVCRT__wcstoui64_l(nptr, endptr, base, NULL); +}