Menu

[0a35e6]: / src / rtlib / strw_convfrom_int.c  Maximize  Restore  History

Download this file

67 lines (54 with data), 958 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* valwint function */
#include "fb.h"
FBCALL int fb_WstrToInt( const FB_WCHAR *src, ssize_t len )
{
const FB_WCHAR *p, *r;
int radix;
/* skip white spc */
p = fb_wstr_SkipChar( src, len, 32 );
len -= fb_wstr_CalcDiff( src, p );
if( len < 1 )
return 0;
radix = 10;
r = p;
if( (len >= 2) && (*r++ == L'&') )
{
switch( *r++ )
{
case L'h':
case L'H':
radix = 16;
break;
case L'o':
case L'O':
radix = 8;
break;
case L'b':
case L'B':
radix = 2;
break;
default: /* assume octal */
radix = 8;
r--;
break;
}
if( radix != 10 )
p = r;
}
/* wcstol() saturates values outside [-2^31, 2^31)
so use wcstoul() instead */
return wcstoul( p, NULL, radix );
}
FBCALL int fb_WstrValInt( const FB_WCHAR *str )
{
ssize_t len;
int val;
if( str == NULL )
return 0;
len = fb_wstr_Len( str );
if( len == 0 )
val = 0;
else
val = fb_WstrToInt( str, len );
return val;
}
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.