Skip to content

Commit e90ce8a

Browse files
committed
Fixed digit bug
1 parent 0caf41d commit e90ce8a

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,16 @@ static inline bool c3_is_digit (char c) {
136136
}
137137

138138
static int32_t get_digit_long (char **p) {
139-
int32_t res = 0, dig = 1;
139+
int32_t res = 0;
140140
int sign = 1;
141141
if (**p == '-') {
142142
sign = -1;
143143
(*p)++;
144144
}
145145
//XXX may overflow. and must treat invalid num, like 8p30
146146
while (c3_is_digit (**p)) {
147-
res += (**p - '0') * dig;
148-
dig *= 10;
147+
res *= 10;
148+
res += (**p - '0');
149149
(*p)++;
150150
}
151151
res *= sign;

test/simple4.cnf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
c This is example of random form
2+
c Author rkx1209
3+
p cnf 20 5
4+
4 5 11 13 14 -11 17 -17 0
5+
3 -5 12 20 10 -1 7 4 0
6+
1 -19 18 15 -10 5 -17 4 0
7+
-12 5 0
8+
9 14 15 16 20 0

0 commit comments

Comments
 (0)