ref: 0a1e5ecfd2a34a31c9f66d66490fa0d94737a700
parent: b53996849e0119bbd9572c220e31f2dd86834738
author: Ori Bernstein <[email protected]>
date: Mon Jul 23 21:25:16 EDT 2012
Do proper base conversion. Oops.
--- a/parse/gram.y
+++ b/parse/gram.y
@@ -542,9 +542,9 @@
;
littok : Tstrlit {$$ = mkstr($1->line, $1->str);}
- | Tintlit {$$ = mkint($1->line, strtol($1->str, NULL, 0));}
+ | Tintlit {$$ = mkint($1->line, $1->intval);}
| Tchrlit {$$ = mkchar($1->line, *$1->str);} /* FIXME: expand escapes, unicode */
- | Tfloatlit {$$ = mkfloat($1->line, strtod($1->str, NULL));}
+ | Tfloatlit {$$ = mkfloat($1->line, $1->fltval);}
| Tboollit {$$ = mkbool($1->line, !strcmp($1->str, "true"));}
;
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -73,6 +73,8 @@
int type;
int line;
char *str;
+ vlong intval;
+ double fltval;
};
struct Stab {
--- a/parse/tok.c
+++ b/parse/tok.c
@@ -431,9 +431,11 @@
if (isfloat && base == 10) {
t = mktok(Tfloatlit);
t->str = strdupn(&fbuf[start], fidx - start);
+ t->fltval = strtod(t->str, NULL);
} else {
t = mktok(Tintlit);
t->str = strdupn(&fbuf[start], fidx - start);
+ t->intval = strtol(t->str, NULL, base);
}
return t;