FreeBASIC
0.91.0
Main Page
Data Structures
Files
File List
Globals
strw_convfrom_lng.c
Go to the documentation of this file.
1
/* valwlng function */
2
3
#include "
fb.h
"
4
5
FBCALL
long
long
fb_WstrToLongint
(
const
FB_WCHAR
*src, ssize_t len )
6
{
7
const
FB_WCHAR
*
p
, *r;
8
int
radix;
9
10
/* skip white spc */
11
p =
fb_wstr_SkipChar
( src, len, 32 );
12
13
len -=
fb_wstr_CalcDiff
( src, p );
14
if
( len < 1 )
15
return
0;
16
17
radix = 10;
18
r =
p
;
19
if
( (len >= 2) && (*r++ == L
'&'
) )
20
{
21
switch
( *r++ )
22
{
23
case
L
'h'
:
24
case
L
'H'
:
25
radix = 16;
26
break
;
27
case
L
'o'
:
28
case
L
'O'
:
29
radix = 8;
30
break
;
31
case
L
'b'
:
32
case
L
'B'
:
33
radix = 2;
34
break
;
35
36
default
:
/* assume octal */
37
radix = 8;
38
r--;
39
break
;
40
}
41
42
if
( radix != 10 )
43
{
44
#ifdef HOST_MINGW
45
return
fb_WstrRadix2Longint
( r, len -
fb_wstr_CalcDiff
( p, r ), radix );
46
#else
47
p = r;
48
#endif
49
}
50
}
51
52
/* wcstoll() saturates values outside [-2^63, 2^63)
53
so use wcstoull() instead */
54
return
(
long
long
)
wcstoull
( p,
NULL
, radix );
55
}
56
57
FBCALL
long
long
fb_WstrValLng
(
const
FB_WCHAR
*str )
58
{
59
long
long
val;
60
ssize_t len;
61
62
if
( str ==
NULL
)
63
return
0;
64
65
len =
fb_wstr_Len
( str );
66
if
( len == 0 )
67
val = 0;
68
else
69
val =
fb_WstrToLongint
( str, len );
70
71
return
val;
72
}
rtlib
strw_convfrom_lng.c
Generated on Thu Jan 23 2014 19:40:13 for FreeBASIC by
1.8.4