update for HEAD-2003091401
[reactos.git] / lib / ntdll / stdlib / wtoi64.c
1 /* $Id$
2  *
3  * COPYRIGHT:       See COPYING in the top level directory
4  * PROJECT:         ReactOS kernel
5  * FILE:            lib/ntdll/stdlib/wtoi64.c
6  * PURPOSE:         converts a unicode string to 64 bit integer
7  */
8
9 #include <stdlib.h>
10 #include <ctype.h>
11
12 /*
13  * @implemented
14  */
15 __int64
16 _wtoi64 (const wchar_t *nptr)
17 {
18    int c;
19    __int64 value;
20    int sign;
21
22    while (iswctype((int)*nptr, _SPACE))
23         ++nptr;
24
25    c = (int)*nptr++;
26    sign = c;
27    if (c == L'-' || c == L'+')
28         c = (int)*nptr++;
29
30    value = 0;
31
32    while (iswctype(c, _DIGIT))
33      {
34         value = 10 * value + (c - L'0');
35         c = (int)*nptr++;
36      }
37
38    if (sign == L'-')
39        return -value;
40    else
41        return value;
42 }
43
44 /* EOF */