msvcrt: Added _wcstoi64 and _wcstoui64 implementation.

This commit is contained in:
Piotr Caban 2010-04-27 08:42:32 +02:00 committed by Alexandre Julliard
parent c4d6877894
commit 0ec1635172
5 changed files with 173 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 && (ret<MSVCRT_I64_MIN/base || ret*base<MSVCRT_I64_MIN-v)) {
ret = MSVCRT_I64_MIN;
*MSVCRT__errno() = ERANGE;
*MSVCRT__errno() = MSVCRT_ERANGE;
} else
ret = ret*base + v;
}
@ -606,7 +606,7 @@ unsigned __int64 CDECL MSVCRT_strtoui64_l(const char *nptr, char **endptr, int b
if(ret>MSVCRT_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;
}

View File

@ -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 && (ret<MSVCRT_I64_MIN/base || ret*base<MSVCRT_I64_MIN-v)) {
ret = MSVCRT_I64_MIN;
*MSVCRT__errno() = MSVCRT_ERANGE;
} else
ret = ret*base + v;
}
if(endptr)
*endptr = (MSVCRT_wchar_t*)nptr;
return ret;
}
/*********************************************************************
* _wcstoi64 (MSVCR90.@)
*/
__int64 CDECL MSVCRT__wcstoi64(const MSVCRT_wchar_t *nptr,
MSVCRT_wchar_t **endptr, int base)
{
return MSVCRT__wcstoi64_l(nptr, endptr, base, NULL);
}
/*********************************************************************
* _wcstoui64_l (MSVCR90.@)
*
* FIXME: locale parameter is ignored
*/
unsigned __int64 CDECL MSVCRT__wcstoui64_l(const MSVCRT_wchar_t *nptr,
MSVCRT_wchar_t **endptr, int base, MSVCRT__locale_t locale)
{
BOOL negative = FALSE;
unsigned __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(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);
}