--- ../old/libxml2-2.6.32/xpath.c	2008-04-03 00:37:47.000000000 -0400
+++ xpath.c	2010-09-13 11:08:28.000000000 -0400
@@ -9914,6 +9914,28 @@ static double my_pow10[MAX_FRAC+1] = {
 };
 
 /**
+ * xmlXPathStringIsNumber:
+ * @start: first character to test
+ * @end: one past last character to test
+ *
+ * Test the contents of the string between start and end to ensure
+ * they are valid XPath string characters.  This test is required
+ * since we are using strtod() which allows functionality not in
+ * the XPath spec (unary plus and 0x/0X prefixed hex numbers).
+ */
+static int
+xmlXPathStringIsNumber(const xmlChar *start, const xmlChar *end) {
+    xmlChar *cur;
+
+    for (cur = start; cur < end; cur++) {
+	xmlChar ch = *cur;
+	if (ch != '.' && ch != 'e' && ch != 'E' && ch != '-' && !isdigit(ch))
+	    return(0);
+    }
+    return(1);
+}
+
+/**
  * xmlXPathStringEvalNumber:
  * @str:  A string to scan
  *
@@ -9931,86 +9953,23 @@ static double my_pow10[MAX_FRAC+1] = {
  */
 double
 xmlXPathStringEvalNumber(const xmlChar *str) {
-    const xmlChar *cur = str;
+    const xmlChar *cur = str, *end;
     double ret;
-    int ok = 0;
-    int isneg = 0;
-    int exponent = 0;
-    int is_exponent_negative = 0;
-#ifdef __GNUC__
-    unsigned long tmp = 0;
-    double temp;
-#endif
+
     if (cur == NULL) return(0);
     while (IS_BLANK_CH(*cur)) cur++;
     if ((*cur != '.') && ((*cur < '0') || (*cur > '9')) && (*cur != '-')) {
         return(xmlXPathNAN);
     }
-    if (*cur == '-') {
-	isneg = 1;
-	cur++;
-    }
-
-#ifdef __GNUC__
-    /*
-     * tmp/temp is a workaround against a gcc compiler bug
-     * http://veillard.com/gcc.bug
-     */
-    ret = 0;
-    while ((*cur >= '0') && (*cur <= '9')) {
-	ret = ret * 10;
-	tmp = (*cur - '0');
-	ok = 1;
-	cur++;
-	temp = (double) tmp;
-	ret = ret + temp;
-    }
-#else
-    ret = 0;
-    while ((*cur >= '0') && (*cur <= '9')) {
-	ret = ret * 10 + (*cur - '0');
-	ok = 1;
-	cur++;
-    }
-#endif
 
-    if (*cur == '.') {
-	int v, frac = 0;
-	double fraction = 0;
+    ret = strtod(cur, &end);
+    if (cur == end || !xmlXPathStringIsNumber(cur, end))
+	return(xmlXPathNAN);
 
-        cur++;
-	if (((*cur < '0') || (*cur > '9')) && (!ok)) {
-	    return(xmlXPathNAN);
-	}
-	while (((*cur >= '0') && (*cur <= '9')) && (frac < MAX_FRAC)) {
-	    v = (*cur - '0');
-	    fraction = fraction * 10 + v;
-	    frac = frac + 1;
-	    cur++;
-	}
-	fraction /= my_pow10[frac];
-	ret = ret + fraction;
-	while ((*cur >= '0') && (*cur <= '9'))
-	    cur++;
-    }
-    if ((*cur == 'e') || (*cur == 'E')) {
-      cur++;
-      if (*cur == '-') {
-	is_exponent_negative = 1;
-	cur++;
-      } else if (*cur == '+') {
-        cur++;
-      }
-      while ((*cur >= '0') && (*cur <= '9')) {
-	exponent = exponent * 10 + (*cur - '0');
-	cur++;
-      }
-    }
+    cur = end;
     while (IS_BLANK_CH(*cur)) cur++;
     if (*cur != 0) return(xmlXPathNAN);
-    if (isneg) ret = -ret;
-    if (is_exponent_negative) exponent = -exponent;
-    ret *= pow(10.0, (double)exponent);
+
     return(ret);
 }
 
@@ -10029,68 +9988,13 @@ static void
 xmlXPathCompNumber(xmlXPathParserContextPtr ctxt)
 {
     double ret = 0.0;
-    double mult = 1;
-    int ok = 0;
-    int exponent = 0;
-    int is_exponent_negative = 0;
-#ifdef __GNUC__
-    unsigned long tmp = 0;
-    double temp;
-#endif
+    const xmlChar *cur = CUR_PTR, *end;
 
-    CHECK_ERROR;
-    if ((CUR != '.') && ((CUR < '0') || (CUR > '9'))) {
+    ret = strtod(cur, &end);
+    CUR_PTR = end;
+    if (cur == end || !xmlXPathStringIsNumber(cur, end))
         XP_ERROR(XPATH_NUMBER_ERROR);
-    }
-#ifdef __GNUC__
-    /*
-     * tmp/temp is a workaround against a gcc compiler bug
-     * http://veillard.com/gcc.bug
-     */
-    ret = 0;
-    while ((CUR >= '0') && (CUR <= '9')) {
-	ret = ret * 10;
-	tmp = (CUR - '0');
-        ok = 1;
-        NEXT;
-	temp = (double) tmp;
-	ret = ret + temp;
-    }
-#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)) {
-            XP_ERROR(XPATH_NUMBER_ERROR);
-        }
-        while ((CUR >= '0') && (CUR <= '9')) {
-            mult /= 10;
-            ret = ret + (CUR - '0') * mult;
-            NEXT;
-        }
-    }
-    if ((CUR == 'e') || (CUR == 'E')) {
-        NEXT;
-        if (CUR == '-') {
-            is_exponent_negative = 1;
-            NEXT;
-        } else if (CUR == '+') {
-	    NEXT;
-	}
-        while ((CUR >= '0') && (CUR <= '9')) {
-            exponent = exponent * 10 + (CUR - '0');
-            NEXT;
-        }
-        if (is_exponent_negative)
-            exponent = -exponent;
-        ret *= pow(10.0, (double) exponent);
-    }
+
     PUSH_LONG_EXPR(XPATH_OP_VALUE, XPATH_NUMBER, 0, 0,
                    xmlXPathCacheNewFloat(ctxt->context, ret), NULL);
 }
--- ../old/libxml2-2.6.32/configure.in	2010-05-24 23:32:58.000000000 -0400
+++ configure.in	2010-09-13 11:24:59.000000000 -0400
@@ -437,6 +437,7 @@ AC_CHECK_FUNCS(strdup strndup strerror)
 AC_CHECK_FUNCS(finite isnand fp_class class fpclass)
 AC_CHECK_FUNCS(strftime localtime gettimeofday ftime)
 AC_CHECK_FUNCS(stat _stat signal)
+AC_CHECK_FUNCS(strtod)
 
 dnl Checking the standard string functions availability
 AC_CHECK_FUNCS(printf sprintf fprintf snprintf vfprintf vsprintf vsnprintf sscanf,,
