Mostly minor updates to the source tree for portcls.
[reactos.git] / reactos / lib / string / wtol.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include <windows.h>
4
5 /*
6 * @implemented
7 */
8 long
9 _wtol(const wchar_t *str)
10 {
11 ULONG RunningTotal = 0;
12 char bMinus = 0;
13
14 while (iswctype(*str, _SPACE) ) {
15 str++;
16 } /* while */
17
18 if (*str == L'+') {
19 str++;
20 } else if (*str == L'-') {
21 bMinus = 1;
22 str++;
23 } /* if */
24
25 while (*str >= L'0' && *str <= L'9') {
26 RunningTotal = RunningTotal * 10 + *str - L'0';
27 str++;
28 } /* while */
29
30 return bMinus ? -RunningTotal : RunningTotal;
31 }
32
33