Re: [xml] Test comparison fails on value (-2147483648)
- From: Daniel Veillard <veillard redhat com>
- To: Chris_Poblete Dell com
- Cc: xml gnome org
- Subject: Re: [xml] Test comparison fails on value (-2147483648)
- Date: Sun, 26 Aug 2001 16:53:58 -0400
On Sun, Aug 26, 2001 at 12:37:55PM -0500, Chris_Poblete Dell com wrote:
VERSIONS: libxml2-2.4.3
libxslt-1.0.3
PROBLEM:
The tag <xsl:when test="OutputWatts < 0"> fails to evaluate correctly
when OutputWatts is equal to -2147483648.
Well OutputWatts will evaluate to a nodeset which then once
used in the comparison will end up being casted to a float. OutputWatts
cannot be equal to -2147483648 but it's float value may be equal to this
value.
I hope you understand that this compare a set of XML nodes with a value.
PROPOSED RESOLUTION:
xpath:xmlXPathStringEvalNumber(6567)
------------------------------------------------------------
< ret = (double) tmp;
----------
ret = (double) tmp;
// Variable tmp is declared as signed integer which may evaluate to
a negative
// number. We only need to calculate the absolute value of the
whole number since
// any negative character in the input string has been flagged
separately.
if (tmp < 0)
ret = -ret;
------------------------------------------------------------
This looks wrong to me. The sign is caught when beginning to parse
the string:
if (*cur == '-') {
isneg = 1;
cur++;
}
Then before returning the value
if (isneg) ret = -ret;
If we apply you suggested change we change the sign twice in all cases,
looks wrong to me.
The problem you're facing is an integer overflow. If you look at the
comment 5 lines before your suggested change you will get the explanation:
/*
* tmp is a workaroudn against a gcc compiler bug
*/
I spent a number of hours chasing it down and finding a workaround, your
problem case don't doesn't seems realistic and I would prefer not change
that part of the code.
Daniel
--
Daniel Veillard | Red Hat Network http://redhat.com/products/network/
veillard redhat com | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]