reactos/lib/sdk/crt/string/wtol.c
Amine Khaldi c424146e2c Create a branch for cmake bringup.
svn path=/branches/cmake-bringup/; revision=48236
2010-07-24 18:52:44 +00:00

38 lines
655 B
C

#include <string.h>
#include <ctype.h>
#include <basetsd.h>
/* Implementation comes from wine/dlls/ntdll/wcstring.c */
/*
* @implemented
*/
long
_wtol(const wchar_t *str)
{
unsigned long RunningTotal = 0;
char bMinus = 0;
if (str == NULL)
return 0;
while (iswctype(*str, _SPACE) ) {
str++;
} /* while */
if (*str == L'+') {
str++;
} else if (*str == L'-') {
bMinus = 1;
str++;
} /* if */
while (*str >= L'0' && *str <= L'9') {
RunningTotal = RunningTotal * 10 + *str - L'0';
str++;
} /* while */
return bMinus ? -RunningTotal : RunningTotal;
}