[xml] XPath Infinities

Hello Daniel, everybody

I encountered a slight difficulty while building version 2.3.7 under
Win32/MSCC. The compiler refuses to divide a constant by zero. The recent
changes in xpath.c which introduce these divisions broke the build under

Namely, if you let MSCC divide a variable by zero, you get a NaN or
positive/negative infinity, depends on what the variable contains, as was
the intention. For some reason, MSCC considers it an error to divide a
constant by zero and assign the result to a variable.

Are there other compilers out there which behave similarily? What is the
difference anyway? I mean the two lines:

    xmlXPathNAN = 0.0, xmlXPathNAN /= 0.0;
    xmlXPathNAN = 0.0 / 0.0; 

look quite the same to me. Why MSCC handles the first line but breaks on the
second is lost on me, but the fact is that it does. So far I have heard,
someone with Linux on alpha recently said that his setup wants this to be
just the other way around? 

I would suggest the following patch to xpath.c. It makes no difference to
those who succeed compiling 2.3.7 as it is. Those of us who use MSCC and
similar compilers would then be responsible to define this
XPATH_USE_DIVISION_SHORTCUTS macro somewhere. The alternative to this seems
to be disabling XPath under Win32/MSCC.

What do you think? 


*** libxml2-2.3.7.orig\xpath.c Sun Apr 22 2001 09:31:36 PM
--- libxml2-2.3.7\xpath.c Fri Apr 27 2001 03:38:04 PM
*** 157,169 ****
--- 156,175 ----
      static int initialized = 0;

      if (initialized) return;

+     xmlXPathNAN /= 0.0;
+     xmlXPathPINF /= 0.0;
+     xmlXPathNINF /= 0.0;
+ #else
      xmlXPathNAN = 0.0 / 0.0;

      xmlXPathPINF = 1 / 0.0;

      xmlXPathNINF = -1 / 0.0;
+ #endif

     initialized = 1;

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]