629325 XPath rounding errors first cleanup
https://bugzilla.gnome.org/show_bug.cgi?id=629325
not a full solution as Vincent Lefevre pointed out but
an incremental improvement over the status-quo
diff --git a/xpath.c b/xpath.c
index 3352a5e..4d6826d 100644
--- a/xpath.c
+++ b/xpath.c
@@ -10080,15 +10080,23 @@
}
#endif
if (CUR == '.') {
+ int v, frac = 0;
+ double fraction = 0;
+
NEXT;
if (((CUR < '0') || (CUR > '9')) && (!ok)) {
XP_ERROR(XPATH_NUMBER_ERROR);
}
- while ((CUR >= '0') && (CUR <= '9')) {
- mult /= 10;
- ret = ret + (CUR - '0') * mult;
+ while ((CUR >= '0') && (CUR <= '9') && (frac < MAX_FRAC)) {
+ v = (CUR - '0');
+ fraction = fraction * 10 + v;
+ frac = frac + 1;
NEXT;
}
+ fraction /= my_pow10[frac];
+ ret = ret + fraction;
+ while ((CUR >= '0') && (CUR <= '9'))
+ NEXT;
}
if ((CUR == 'e') || (CUR == 'E')) {
NEXT;