ReactOS  0.4.15-dev-341-g17c5fb8
wtol.c
Go to the documentation of this file.
1 #include <string.h>
2 #include <ctype.h>
3 #include <basetsd.h>
4 
5 /* Implementation comes from wine/dlls/ntdll/wcstring.c */
6 
7 /*
8  * @implemented
9  */
10 long
11 _wtol(const wchar_t *str)
12 {
13  unsigned long RunningTotal = 0;
14  char bMinus = 0;
15 
16  if (str == NULL)
17  return 0;
18 
19  while (iswctype(*str, _SPACE) ) {
20  str++;
21  } /* while */
22 
23  if (*str == L'+') {
24  str++;
25  } else if (*str == L'-') {
26  bMinus = 1;
27  str++;
28  } /* if */
29 
30  while (*str >= L'0' && *str <= L'9') {
31  RunningTotal = RunningTotal * 10 + *str - L'0';
32  str++;
33  } /* while */
34 
35  return bMinus ? 0-RunningTotal : RunningTotal;
36 }
37 
38 
long _wtol(const wchar_t *str)
Definition: wtol.c:11
#define _SPACE
Definition: ctype.h:68
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
Definition: freeldr.c:97
static const WCHAR L[]
Definition: oid.c:1250