Add configure guards around literal jv_numbers

Allow building jq in a mode that doesn't use decnumber for benchmarking
purposes. decnumber support is enabled by default, and this option is
meant to be removed once we're happy with the performance.
This commit is contained in:
William Langford committed 2019-10-22 14:11:04 -04:00
1 parent 4860ed4396
commit 74c44bc9a3
4 files changed
+25

No files matched your search

+9
View File
@@ -501,11 +501,20 @@ static pfunc check_literal(struct jv_parser* p) {
} else {
// FIXME: better parser
p->tokenbuf[p->tokenpos] = 0;
#ifdef USE_DECNUM
jv number = jv_number_with_literal(p->tokenbuf);
if (jv_get_kind(number) == JV_KIND_INVALID) {
return "Invalid numeric literal";
}
TRY(value(p, number));
#else
char *end = 0;
double d = jvp_strtod(&p->dtoa, p->tokenbuf, &end);
if (end == 0 || *end != 0) {
return "Invalid numeric literal";
}
TRY(value(p, jv_number(d)));
#endif
}
p->tokenpos = 0;
return 0;