diff --git a/ChangeLog b/ChangeLog index c2190b25..752a24de 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Thu Mar 7 09:34:16 CET 2002 Daniel Veillard + + * xpath.c: trying to avoid bug #72150 which was apparently + caused by a gcc bug (or a processor problem) as detailed + at http://veillard.com/gcc.bug + Thu Mar 7 01:02:37 CET 2002 Daniel Veillard * tree.c python/tests/Makefile.am python/tests/cutnpaste.py: diff --git a/xpath.c b/xpath.c index 6930812b..5baacf0b 100644 --- a/xpath.c +++ b/xpath.c @@ -6779,7 +6779,7 @@ xmlXPathParseNameComplex(xmlXPathParserContextPtr ctxt, int qualified) { double xmlXPathStringEvalNumber(const xmlChar *str) { const xmlChar *cur = str; - double ret = 0.0; + double ret; double mult = 1; int ok = 0; int isneg = 0; @@ -6787,6 +6787,7 @@ xmlXPathStringEvalNumber(const xmlChar *str) { int is_exponent_negative = 0; #ifdef __GNUC__ unsigned long tmp = 0; + double temp; #endif while (IS_BLANK(*cur)) cur++; @@ -6800,15 +6801,20 @@ xmlXPathStringEvalNumber(const xmlChar *str) { #ifdef __GNUC__ /* - * tmp is a workaround against a gcc compiler bug + * tmp/temp is a workaround against a gcc compiler bug + * http://veillard.com/gcc.bug */ + ret = 0; while ((*cur >= '0') && (*cur <= '9')) { - tmp = tmp * 10 + (*cur - '0'); + ret = ret * 10; + tmp = (*cur - '0'); ok = 1; cur++; + temp = (double) tmp; + ret = ret + temp; } - ret = (double) tmp; #else + ret = 0; while ((*cur >= '0') && (*cur <= '9')) { ret = ret * 10 + (*cur - '0'); ok = 1; @@ -6862,23 +6868,40 @@ xmlXPathCompNumber(xmlXPathParserContextPtr ctxt) { double ret = 0.0; double mult = 1; - int ok = 0, tmp = 0; + int ok = 0; int exponent = 0; int is_exponent_negative = 0; +#ifdef __GNUC__ + unsigned long tmp = 0; + double temp; +#endif CHECK_ERROR; if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) { XP_ERROR(XPATH_NUMBER_ERROR); } +#ifdef __GNUC__ /* - * Try to work around a gcc optimizer bug + * tmp/temp is a workaround against a gcc compiler bug + * http://veillard.com/gcc.bug */ + ret = 0; while ((CUR >= '0') && (CUR <= '9')) { - tmp = tmp * 10 + (CUR - '0'); + ret = ret * 10; + tmp = (CUR - '0'); ok = 1; NEXT; + temp = (double) tmp; + ret = ret + temp; } - ret = (double) tmp; +#else + ret = 0; + while ((CUR >= '0') && (CUR <= '9')) { + ret = ret * 10 + (CUR - '0'); + ok = 1; + NEXT; + } +#endif if (CUR == '.') { NEXT; if (((CUR < '0') || (CUR > '9')) && (!ok)) {