File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,17 @@ long strtol_deci(const char *nptr)
27
27
* Skip white space and pick up leading +/- sign if any.
28
28
*/
29
29
do {
30
- c = * s ++ ;
30
+ c = * s ;
31
+ s ++ ;
31
32
} while (ISSPACE (c ));
32
33
if (c == '-' ) {
33
34
neg = 1 ;
34
- c = * s ++ ;
35
- } else if (c == '+' )
36
- c = * s ++ ;
35
+ c = * s ;
36
+ s ++ ;
37
+ } else if (c == '+' ) {
38
+ c = * s ;
39
+ s ++ ;
40
+ }
37
41
/*
38
42
* Compute the cutoff value between legal numbers and illegal
39
43
* numbers. That is the largest legal value, divided by the
@@ -54,7 +58,9 @@ long strtol_deci(const char *nptr)
54
58
cutoff = (neg != 0 ) ? - (uint64_t )LONG_MIN : LONG_MAX ;
55
59
cutlim = cutoff % (uint64_t )base ;
56
60
cutoff /= (uint64_t )base ;
57
- for (acc = 0 , any = 0 ;; c = * s ++ ) {
61
+ acc = 0 ;
62
+ any = 0 ;
63
+ do {
58
64
if (c >= '0' && c <= '9' )
59
65
c -= '0' ;
60
66
else
@@ -68,7 +74,11 @@ long strtol_deci(const char *nptr)
68
74
acc *= base ;
69
75
acc += c ;
70
76
}
71
- }
77
+
78
+ c = * s ;
79
+ s ++ ;
80
+ } while (true);
81
+
72
82
if (any < 0 )
73
83
acc = (neg != 0 ) ? LONG_MIN : LONG_MAX ;
74
84
else if (neg != 0 )
@@ -101,7 +111,9 @@ uint64_t strtoul_hex(const char *nptr)
101
111
102
112
cutoff = (uint64_t )ULONG_MAX / (uint64_t )base ;
103
113
cutlim = (uint64_t )ULONG_MAX % (uint64_t )base ;
104
- for (acc = 0 , any = 0 ;; c = * s ++ ) {
114
+ acc = 0 ;
115
+ any = 0 ;
116
+ do {
105
117
if (c >= '0' && c <= '9' )
106
118
c -= '0' ;
107
119
else if (c >= 'A' && c <= 'F' )
@@ -119,7 +131,10 @@ uint64_t strtoul_hex(const char *nptr)
119
131
acc *= base ;
120
132
acc += c ;
121
133
}
122
- }
134
+
135
+ c = * s ;
136
+ s ++ ;
137
+ } while (true);
123
138
124
139
if (any <= 0 )
125
140
acc = ULONG_MAX ;
You can’t perform that action at this time.
0 commit comments