Permalink
Browse files

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
  • Loading branch information...
philatjuniper authored and veillard committed Nov 3, 2010
1 parent ad4f0a2 commit ee32ad3c0f6dfbb1b0e57db63d16f6455d6416df
Showing with 11 additions and 3 deletions.
  1. +11 −3 xpath.c
View
14 xpath.c
@@ -10080,15 +10080,23 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
} }
#endif #endif
if (CUR == '.') { if (CUR == '.') {
int v, frac = 0;
double fraction = 0;
NEXT; NEXT;
if (((CUR < '0') || (CUR > '9')) && (!ok)) { if (((CUR < '0') || (CUR > '9')) && (!ok)) {
XP_ERROR(XPATH_NUMBER_ERROR); XP_ERROR(XPATH_NUMBER_ERROR);
} }
while ((CUR >= '0') && (CUR <= '9')) { while ((CUR >= '0') && (CUR <= '9') && (frac < MAX_FRAC)) {
mult /= 10; v = (CUR - '0');
ret = ret + (CUR - '0') * mult; fraction = fraction * 10 + v;
frac = frac + 1;
NEXT; NEXT;
} }
fraction /= my_pow10[frac];
ret = ret + fraction;
while ((CUR >= '0') && (CUR <= '9'))
NEXT;
} }
if ((CUR == 'e') || (CUR == 'E')) { if ((CUR == 'e') || (CUR == 'E')) {
NEXT; NEXT;

0 comments on commit ee32ad3

Please sign in to comment.