[Expat-discuss] XML_ParseBuffer

Fred L. Drake, Jr. fdrake@acm.org
Wed Oct 24 13:36:06 2001


Carlos Pereira writes:
 > According to the manual, XML_ParseBuffer 
 > returns 0 for bad formation and "non zero" otherwise.
 > A quick printf test shows this "non-zero" to be 1 on
 > my Linux system.
 > 
 > Can I rely on this? a successful XML_ParseBuffer 
 > always returns 1? or is it more safe to test
 > always against 0?

  The documentation doesn't say it is, so assume it's an
implementation detail.  The right way to test this is to use the
result as a boolean, not to compare it to a specific value:

    if (XML_ParseBuffer(...)) {
        /* handle the error */
        ...
    }
    else {
        /* do useful work */
        ...
    }


  -Fred

-- 
Fred L. Drake, Jr.  <fdrake at acm.org>
PythonLabs at Zope Corporation