diff options
author | Phil Shafer <phil@juniper.net> | 2010-11-03 20:53:55 +0100 |
---|---|---|
committer | Daniel Veillard <veillard@redhat.com> | 2010-11-03 20:53:55 +0100 |
commit | ee32ad3c0f6dfbb1b0e57db63d16f6455d6416df (patch) | |
tree | a4d35c5c67761d0aed5e327e6a4564dfe4214d13 /xpath.c | |
parent | ad4f0a2dc893cb01af35361c0349227fd6c765b5 (diff) | |
download | libxml2-ee32ad3c0f6dfbb1b0e57db63d16f6455d6416df.tar.gz |
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
Diffstat (limited to 'xpath.c')
-rw-r--r-- | xpath.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -10080,15 +10080,23 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) } #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; |