-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathasn_strtoimax_lim_part.c
28 lines (28 loc) · 1.06 KB
/
asn_strtoimax_lim_part.c
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
for(value = 0; str < (*end); str++) {
if(*str >= 0x30 && *str <= 0x39) {
int d = *str - '0';
if(value < upper_boundary) {
value = value * 10 + d;
} else if(value == upper_boundary) {
if(d <= last_digit_max) {
if(sign > 0) { value = value * 10 + d;
} else { sign = 1;
value = -value * 10 - d; }
str += 1;
if(str < *end) {
// If digits continue, we're guaranteed out of range.
*end = str;
if(*str >= 0x30 && *str <= 0x39) { return ASN_STRTOX_ERROR_RANGE;
} else { *intp = sign * value;
return ASN_STRTOX_EXTRA_DATA; }}
break;
} else { *end = str;
return ASN_STRTOX_ERROR_RANGE; }
} else { *end = str;
return ASN_STRTOX_ERROR_RANGE; }
} else { *end = str;
*intp = sign * value;
return ASN_STRTOX_EXTRA_DATA; }}
*end = str;
*intp = sign * value;
return ASN_STRTOX_OK; }