ReactOS 0.4.15-dev-7934-g1dc8d80
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 */
10long
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
#define NULL
Definition: types.h:112
int __cdecl iswctype(wint_t wc, wctype_t wctypeFlags)
Definition: freeldr.c:99
#define _SPACE
Definition: ctype.h:68
#define L(x)
Definition: ntvdm.h:50
const WCHAR * str
long _wtol(const wchar_t *str)
Definition: wtol.c:11