Browse Source

Fixed bug in decimal number parser.

long_to_char
Cameron Weinfurt 3 years ago
parent
commit
2f79626c7a
  1. 4
      expr.c
  2. 6
      parse.c

4
expr.c

@ -46,7 +46,7 @@ void print_expr_tree(expr_t *t, int depth) {
print_expr_tree(t->left.expr, depth + 1);
}
else {
fprintf(stderr, "%ld\n", t->left.data);
fprintf(stderr, "%lu\n", t->left.data);
}
for(register int i = depth; i > 0; --i) fputs(" ", stderr);
fprintf(stderr, "");
@ -54,7 +54,7 @@ void print_expr_tree(expr_t *t, int depth) {
print_expr_tree(t->right.expr, depth + 1);
}
else {
fprintf(stderr, "%ld\n", t->right.data);
fprintf(stderr, "%lu\n", t->right.data);
}
}

6
parse.c

@ -31,10 +31,12 @@ expr_t *parse_hex_int() {
ptr++;
if (ptr == input_str) return bubble_expr(num, more_num);
more_num->right.data = more_num->right.data * 16 + fromhex(ptr);
num = bubble_expr(num, more_num);
}
ptr++;
num = bubble_expr(num, more_num);
}
return num;
}
expr_t *parse_decimal_int() {
@ -62,9 +64,9 @@ expr_t *parse_decimal_int() {
ptr++;
if (ptr == input_str) return bubble_expr(num, more_num);
more_num->right.data = more_num->right.data * 10 + *ptr - '0';
num = bubble_expr(num, more_num);
}
ptr++;
num = bubble_expr(num, more_num);
}
return num;

Loading…
Cancel
Save