Upgrade to expat-1.9.7.
authorjbj <devnull@localhost>
Sun, 30 May 2004 22:27:38 +0000 (22:27 +0000)
committerjbj <devnull@localhost>
Sun, 30 May 2004 22:27:38 +0000 (22:27 +0000)
CVS patchset: 7281
CVS date: 2004/05/30 22:27:38

22 files changed:
expat/Changes
expat/README
expat/configure.ac
expat/doc/reference.html
expat/doc/style.css
expat/examples/elements.c
expat/examples/outline.c
expat/lib/expat.h
expat/lib/internal.h
expat/lib/xmlparse.c
expat/lib/xmlrole.c
expat/lib/xmlrole.h
expat/lib/xmltok.c
expat/lib/xmltok.h
expat/lib/xmltok_impl.c
expat/tests/Makefile.am
expat/tests/chardata.c
expat/tests/runtests.c
expat/vms/descrip.mms
expat/win32/expat.iss
expat/xmlwf/xmlfile.c
expat/xmlwf/xmlwf.c

index e3c5c17..b724f96 100644 (file)
+Release 1.95.7 Mon Oct 20 2003
+        - Fixed enum XML_Status issue (reported on SourceForge many
+          times), so compilers that are properly picky will be happy.
+        - Introduced an XMLCALL macro to control the calling
+          convention used by the Expat API; this macro should be used
+          to annotate prototypes and definitions of callback
+          implementations in code compiled with a calling convention
+          other than the default convention for the host platform.
+        - Improved ability to build without the configure-generated
+          expat_config.h header.  This is useful for applications
+          which embed Expat rather than linking in the library.
+        - Fixed a variety of bugs: see SF issues 458907, 609603,
+          676844, 679754, 692878, 692964, 695401, 699323, 699487,
+          820946.
+        - Improved hash table lookups.
+        - Added more regression tests and improved documentation.
+
+Release 1.95.6 Tue Jan 28 2003
+        - Added XML_FreeContentModel().
+        - Added XML_MemMalloc(), XML_MemRealloc(), XML_MemFree().
+        - Fixed a variety of bugs: see SF issues 615606, 616863,
+          618199, 653180, 673791.
+        - Enhanced the regression test suite.
+        - Man page improvements: includes SF issue 632146.
+
+Release 1.95.5 Fri Sep 6 2002
+        - Added XML_UseForeignDTD() for improved SAX2 support.
+        - Added XML_GetFeatureList().
+        - Defined XML_Bool type and the values XML_TRUE and XML_FALSE.
+        - Use an incomplete struct instead of a void* for the parser
+          (may not retain).
+        - Fixed UTF-8 decoding bug that caused legal UTF-8 to be rejected.
+        - Finally fixed bug where default handler would report DTD
+          events that were already handled by another handler.
+          Initial patch contributed by Darryl Miles.
+        - Removed unnecessary DllMain() function that caused static
+          linking into a DLL to be difficult.
+        - Added VC++ projects for building static libraries.
+        - Reduced line-length for all source code and headers to be
+          no longer than 80 characters, to help with AS/400 support.
+        - Reduced memory copying during parsing (SF patch #600964).
+        - Fixed a variety of bugs: see SF issues 580793, 434664,
+          483514, 580503, 581069, 584041, 584183, 584832, 585537,
+          596555, 596678, 598352, 598944, 599715, 600479, 600971.
+
+Release 1.95.4 Fri Jul 12 2002
+        - Added support for VMS, contributed by Craig Berry.  See
+          vms/README.vms for more information.
+        - Added Mac OS (classic) support, with a makefile for MPW,
+          contributed by Thomas Wegner and Daryle Walker.
+        - Added Borland C++ Builder 5 / BCC 5.5 support, contributed
+          by Patrick McConnell (SF patch #538032).
+        - Fixed a variety of bugs: see SF issues 441449, 563184,
+          564342, 566334, 566901, 569461, 570263, 575168, 579196.
+        - Made skippedEntityHandler conform to SAX2 (see source comment)
+        - Re-implemented WFC: Entity Declared from XML 1.0 spec and
+          added a new error "entity declared in parameter entity":
+          see SF bug report 569461 and SF patch 578161
+        - Re-implemented section 5.1 from XML 1.0 spec:
+          see SF bug report 570263 and SF patch 578161
+
+Release 1.95.3 Mon Jun 3 2002
+        - Added a project to the MSVC workspace to create a wchar_t
+          version of the library; the DLLs are named libexpatw.dll.
+        - Changed the name of the Windows DLLs from expat.dll to
+          libexpat.dll; this fixes SF bug #432456.
+        - Added the XML_ParserReset() API function.
+        - Fixed XML_SetReturnNSTriplet() to work for element names.
+        - Made the XML_UNICODE builds usable (thanks, Karl!).
+        - Allow xmlwf to read from standard input.
+        - Install a man page for xmlwf on Unix systems.
+        - Fixed many bugs; see SF bug reports 231864, 461380, 464837,
+          466885, 469226, 477667, 484419, 487840, 494749, 496505,
+          547350.  Other bugs which we can't test as easily may also
+          have been fixed, especially in the area of build support.
+
+Release 1.95.2 Fri Jul 27 2001
+        - More changes to make MSVC happy with the build; add a single
+          workspace to support both the library and xmlwf application.
+        - Added a Windows installer for Windows users; includes
+          xmlwf.exe.
+        - Added compile-time constants that can be used to determine the
+          Expat version
+        - Removed a lot of GNU-specific dependencies to aide portability
+          among the various Unix flavors.
+        - Fix the UTF-8 BOM bug.
+        - Cleaned up warning messages for several compilers.
+        - Added the -Wall, -Wstrict-prototypes options for GCC.
+
+Release 1.95.1 Sun Oct 22 15:11:36 EDT 2000
+        - Changes to get expat to build under Microsoft compiler
+        - Removed all aborts and instead return an UNEXPECTED_STATE error.
+        - Fixed a bug where a stray '%' in an entity value would cause an
+          abort.
+        - Defined XML_SetEndNamespaceDeclHandler. Thanks to Darryl Miles for
+          finding this oversight.
+        - Changed default patterns in lib/Makefile.in to fit non-GNU makes
+          Thanks to robin@unrated.net for reporting and providing an
+          account to test on.
+        - The reference had the wrong label for XML_SetStartNamespaceDecl.
+          Reported by an anonymous user.
+
 Release 1.95.0 Fri Sep 29 2000
-       - XML_ParserCreate_MM
-               Allows you to set a memory management suite to replace the
-               standard malloc,realloc, and free.
-       - XML_SetReturnNSTriplet
-               If you turn this feature on when namespace processing is in
-               effect, then qualified, prefixed element and attribute names
-               are returned as "uri|name|prefix" where '|' is whatever
-               separator character is used in namespace processing.
-       - Merged in features from perl-expat
-               o XML_SetElementDeclHandler
-               o XML_SetAttlistDeclHandler
-               o XML_SetXmlDeclHandler
-               o XML_SetEntityDeclHandler
-               o StartDoctypeDeclHandler takes 3 additional parameters:
-                       sysid, pubid, has_internal_subset
-               o Many paired handler setters (like XML_SetElementHandler)
-                 now have corresponding individual handler setters
-               o XML_GetInputContext for getting the input context of
-                 the current parse position.
-       - Added reference material
-       - Packaged into a distribution that builds a sharable library
\ No newline at end of file
+        - XML_ParserCreate_MM
+                Allows you to set a memory management suite to replace the
+                standard malloc,realloc, and free.
+        - XML_SetReturnNSTriplet
+                If you turn this feature on when namespace processing is in
+                effect, then qualified, prefixed element and attribute names
+                are returned as "uri|name|prefix" where '|' is whatever
+                separator character is used in namespace processing.
+        - Merged in features from perl-expat
+                o XML_SetElementDeclHandler
+                o XML_SetAttlistDeclHandler
+                o XML_SetXmlDeclHandler
+                o XML_SetEntityDeclHandler
+                o StartDoctypeDeclHandler takes 3 additional parameters:
+                        sysid, pubid, has_internal_subset
+                o Many paired handler setters (like XML_SetElementHandler)
+                  now have corresponding individual handler setters
+                o XML_GetInputContext for getting the input context of
+                  the current parse position.
+        - Added reference material
+        - Packaged into a distribution that builds a sharable library
index 96e3a7c..d391c7e 100644 (file)
 
-                       Expat, Release 1.95.0
+                        Expat, Release 1.95.7
 
-This is expat, the C library for parsing XML, written by James Clark. Expat
-is a stream oriented XML parser. This means that you register handlers with
-the parser prior to starting the parse. These handlers are called when
-the parser discovers the associated structures in the document being parsed.
-A start tag is an example of the kind of structures for which you may
-register handlers.
+This is Expat, a C library for parsing XML, written by James Clark.
+Expat is a stream-oriented XML parser.  This means that you register
+handlers with the parser before starting the parse.  These handlers
+are called when the parser discovers the associated structures in the
+document being parsed.  A start tag is an example of the kind of
+structures for which you may register handlers.
 
-Expat is free software. You may copy, distribute, and modify it under the
-terms of the License contained in the file, COPYING, distributed with this
-package. This license is the same as the MIT/X Consortium license.
+Windows users should use the expat_win32bin package, which includes
+both precompiled libraries and executalbes, and source code for
+developers.
 
-Versions of expat that have an odd minor version (the middle number in the
-release above), are development releases and should be considered as
-beta software. Releases with even minor version numbers are intended to be
-production grade software.
+Expat is free software.  You may copy, distribute, and modify it under
+the terms of the License contained in the file COPYING distributed
+with this package.  This license is the same as the MIT/X Consortium
+license.
 
-To build expat, you first run the configuration shell script in the top
-level distribution directory:
+Versions of Expat that have an odd minor version (the middle number in
+the release above), are development releases and should be considered
+as beta software.  Releases with even minor version numbers are
+intended to be production grade software.
 
-       ./configure
+If you are building Expat from a check-out from the CVS repository,
+you need to run a script that generates the configure script using the
+GNU autoconf and libtool tools.  To do this, you need to have
+autoconf 2.52 or newer and libtool 1.4 or newer.  Run the script like
+this:
 
-There are many options which you may provide to configure (which you can
-discover by running configure with the --help option.) But the one of most
-interest is the one that sets the installation directory. By default,
-the configure script will set things up to install libexpat into
-/usr/local/lib and expat.h into /usr/local/include. If, for example, you'd
-prefer to install into /home/me/mystuff/lib and /home/me/mystuff/include,
-you can tell configure about that with:
+        ./buildconf.sh
 
-       ./configure --prefix=/home/me/mystuff
+Once this has been done, follow the same instructions as for building
+from a source distribution.
 
-After running the configure script, the "make" command will build things and
-"make install" will install things into their proper location. Note that
-you need to have write permission into the directories into which things
-will be installed.
+To build Expat from a source distribution, you first run the
+configuration shell script in the top level distribution directory:
 
-A reference manual is available in the doc/reference.html in this
+        ./configure
+
+There are many options which you may provide to configure (which you
+can discover by running configure with the --help option).  But the
+one of most interest is the one that sets the installation directory.
+By default, the configure script will set things up to install
+libexpat into /usr/local/lib, expat.h into /usr/local/include, and
+xmlwf into /usr/local/bin.  If, for example, you'd prefer to install
+into /home/me/mystuff/lib, /home/me/mystuff/include, and
+/home/me/mystuff/bin, you can tell configure about that with:
+
+        ./configure --prefix=/home/me/mystuff
+
+After running the configure script, the "make" command will build
+things and "make install" will install things into their proper
+location.  Note that you need to have write permission into the
+directories into which things will be installed.
+
+If you are interested in building Expat to provide document
+information in UTF-16 rather than the default UTF-8, following these
+instructions:
+
+        1. For UTF-16 output as unsigned short (and version/error
+           strings as char), run:
+
+               ./configure CPPFLAGS=-DXML_UNICODE
+
+           For UTF-16 output as wchar_t (incl. version/error strings),
+           run:
+
+               ./configure CFLAGS="-g -O2 -fshort-wchar" \
+                           CPPFLAGS=-DXML_UNICODE_WCHAR_T
+
+        2. Edit the MakeFile, changing:
+
+               LIBRARY = libexpat.la
+
+           to:
+
+               LIBRARY = libexpatw.la
+
+           (Note the additional "w" in the library name.)
+
+        3. Run "make buildlib" (which builds the library only).
+
+        4. Run "make installlib" (which installs the library only).
+
+Note for Solaris users:  The "ar" command is usually located in
+"/usr/ccs/bin", which is not in the default PATH.  You will need to
+add this to your path for the "make" command, and probably also switch
+to GNU make (the "make" found in /usr/ccs/bin does not seem to work
+properly -- appearantly it does not understand .PHONY directives).  If
+you're using ksh or bash, use this command to build:
+
+        PATH=/usr/ccs/bin:$PATH make
+
+The unit and regression tests for Expat require the "check" library on
+Unix; more information is available at http://check.sourceforge.net/,
+and downloadable packages are available from the library's project
+page on SourceForge: http://sourceforge.net/projects/check/.  You do
+not need to install the check library to build and use Expat, only to
+build and run Expat's test suite.
+
+When using Expat with a project using autoconf for configuration, you
+can use the probing macro in conftools/expat.m4 to determine how to
+include Expat.  See the comments at the top of that file for more
+information.
+
+A reference manual is available in the file doc/reference.html in this
 distribution.
 
-The homepage for this project is http://expat.sourceforge.net. There are
-links there to connect you to the bug reports page. If you need to report
-a bug when you don't have access to a browser, you may also send a bug
-report by email to expat-bugs@lists.sourceforge.net.
+The homepage for this project is http://www.libexpat.org/.  There
+are links there to connect you to the bug reports page.  If you need
+to report a bug when you don't have access to a browser, you may also
+send a bug report by email to expat-bugs@mail.libexpat.org.
+
+Discussion related to the direction of future expat development takes
+place on expat-discuss@mail.libexpat.org.  Archives of this list and
+other Expat-related lists may be found at:
 
-Discussion related to the direction of future expat development takes place
-on expat-discuss@lists.sourceforge.net. Archives of this list may be found
-at http://www.geocrawler.com/redir-sf.php3?list=expat-discuss.
+        http://mail.libexpat.org/mailman-21/listinfo/
index 1478dea..55ac307 100644 (file)
@@ -10,18 +10,19 @@ dnl   under the terms of the License (based on the MIT/X license) contained
 dnl   in the file COPYING that comes with this distribution.
 dnl
 
-
 AC_PREREQ(2.52)
-AC_INIT(expat, 1.95.6, expat-bugs@mail.libexpat.org)
+AC_INIT(expat, 1.95.7, expat-bugs@mail.libexpat.org)
+
 AC_CONFIG_SRCDIR(Makefile.in)
 AC_CONFIG_AUX_DIR(conftools)
-AM_CONFIG_HEADER(expat_config.h)
+AC_CONFIG_HEADER(config.h)
 
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE
 
 AC_LIBTOOL_WIN32_DLL
 
+
 dnl
 dnl Increment LIBREVISION if source code has changed at all
 dnl
@@ -33,13 +34,15 @@ dnl
 dnl If the API changes incompatibly set LIBAGE back to 0
 dnl
 
-LIBCURRENT=4
+LIBCURRENT=5
 LIBREVISION=0
-LIBAGE=4
+LIBAGE=5
+
 
 sinclude(conftools/libtool.m4)
 sinclude(conftools/ac_c_bigendian_cross.m4)
 
+
 AC_SUBST(LIBCURRENT)
 AC_SUBST(LIBREVISION)
 AC_SUBST(LIBAGE)
@@ -66,7 +69,6 @@ fi
 
 dnl Checks for header files.
 AC_HEADER_STDC
-AC_CHECK_HEADERS(fcntl.h unistd.h)
 
 dnl Checks for typedefs, structures, and compiler characteristics.
 
@@ -75,12 +77,12 @@ dnl work in a cross compile.
 AC_C_BIGENDIAN_CROSS
 
 AC_C_CONST
-AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
+AC_CHECK_FUNCS(memmove bcopy)
 
-dnl Checks for library functions.
-
-AC_FUNC_MEMCMP
+dnl Only needed for xmlwf:
+AC_CHECK_HEADERS(fcntl.h unistd.h)
+AC_TYPE_OFF_T
 AC_FUNC_MMAP
 
 if test "$ac_cv_func_mmap_fixed_mapped" = "yes"; then
@@ -90,9 +92,10 @@ else
 fi
 AC_SUBST(FILEMAP)
 
-AC_CHECK_FUNCS(memmove bcopy)
+dnl Only needed for regression tests:
+AC_CHECK_HEADERS(check.h)
 
-dnl some basic configuration
+dnl Some basic configuration:
 AC_DEFINE([XML_NS], 1,
           [Define to make XML Namespaces functionality available.])
 AC_DEFINE([XML_DTD], 1,
index bf73a70..9ed9f90 100644 (file)
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
-                "http://www.w3.org/TR/REC-html40/loose.dtd">
+<?xml version="1.0" encoding="iso-8859-1"?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head>
-
 <!-- Copyright 1999,2000 Clark Cooper <coopercc@netheaven.com>
      All rights reserved.
      This is free software. You may distribute or modify according to
      the terms of the MIT/X License -->
   <title>Expat XML Parser</title>
-  <meta name="author" content="Clark Cooper, coopercc@netheaven.com">
-  <meta http-equiv="Content-Style-Type" content="text/css">
-  <link href="style.css" rel="stylesheet" type="text/css">
+  <meta name="author" content="Clark Cooper, coopercc@netheaven.com" />
+  <meta http-equiv="Content-Style-Type" content="text/css" />
+  <link href="style.css" rel="stylesheet" type="text/css" />
 </head>
 <body>
-<h1>Expat XML Parser</h1>
-
-<p>Expat is a library, written in C, for parsing XML documents. It's the
-underlying XML parser for the open source Mozilla project, perl's
-XML::Parser, and other open-source XML parsers.</p>
+  <table cellspacing="0" cellpadding="0" width="100%">
+    <tr>
+      <td class="corner"><img src="expat.png" alt="(Expat logo)" /></td>
+      <td class="banner"><h1>The Expat XML Parser</h1></td>
+    </tr>
+    <tr>
+      <td class="releaseno">Release 1.95.7</td>
+      <td></td>
+    </tr>
+  </table>
+<div class="content">
+
+<p>Expat is a library, written in C, for parsing XML documents. It's
+the underlying XML parser for the open source Mozilla project, Perl's
+<code>XML::Parser</code>, Python's <code>xml.parsers.expat</code>, and
+other open-source XML parsers.</p>
 
 <p>This library is the creation of James Clark, who's also given us
-groff (an nroff look-alike), Jade (an implemention of ISO's DSSSL stylesheet
-language for SGML), XP (a Java XML parser package), XT (a Java XSL engine).
-James was also the technical lead on the XML Working Group at W3 that produced
-the XML specification.</p>
-
-<p>This is free software, licensed under the
-<a href="../COPYING">MIT/X Consortium license</a>. You may download it from
-<a href="http://expat.sourceforge.net">the expat homepage on Source Forge</a>.
+groff (an nroff look-alike), Jade (an implemention of ISO's DSSSL
+stylesheet language for SGML), XP (a Java XML parser package), XT (a
+Java XSL engine).  James was also the technical lead on the XML
+Working Group at W3C that produced the XML specification.</p>
+
+<p>This is free software, licensed under the <a
+href="../COPYING">MIT/X Consortium license</a>. You may download it
+from <a href="http://www.libexpat.org/">the Expat home page</a>.
 </p>
 
-<p>The bulk of this document was originally commissioned as an article by
-<a href="http://www.xml.com/">XML.com</a>. They graciously allowed me to retain
-copyright and to distribute it with expat.
+<p>The bulk of this document was originally commissioned as an article
+by <a href="http://www.xml.com/">XML.com</a>. They graciously allowed
+Clark Cooper to retain copyright and to distribute it with Expat.
+This version has been substantially extended to include documentation
+on features which have been added since the original article was
+published, and additional information on using the original
+interface.</p>
 
-<hr>
+<hr />
 <h2>Table of Contents</h2>
 <ul>
   <li><a href="#overview">Overview</a></li>
   <li><a href="#building">Building and Installing</a></li>
-  <li><a href="#using">Using expat</a></li>
-  <li><a href="#examples">Some examples</a></li>
+  <li><a href="#using">Using Expat</a></li>
   <li><a href="#reference">Reference</a>
-      <ul>
-          <li><a href="#creation">Parser Creation Functions</a>
-              <ul>
-                  <li><a href="#XML_ParserCreate">XML_ParserCreate</a></li>
-                 <li><a href="#XML_ParserCreateNS">XML_ParserCreateNS</a></li>
-                 <li><a href="#XML_ParserCreate_MM">XML_ParserCreate_MM</a></li>
-                 <li><a href="#XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</a></li>
-                 <li><a href="#XML_ParserFree">XML_ParserFree</a></li>
-              </ul>
-          </li>
-         <li><a href="#parsing">Parsing Functions</a>
-             <ul>
-                 <li><a href="#XML_Parse">XML_Parse</a></li>
-                 <li><a href="#XML_ParseBuffer">XML_ParseBuffer</a></li>
-                 <li><a href="#XML_GetBuffer">XML_GetBuffer</a></li>
-              </ul>
-         </li>
-         <li><a href="#setting">Handler Setting Functions</a>
-             <ul>
-                 <li><a href="#XML_SetStartElementHandler">XML_SetStartElementHandler</a></li>
-                 <li><a href="#XML_SetEndElementHandler">XML_SetEndElementHandler</a></li>
-                 <li><a href="#XML_SetElementHandler">XML_SetElementHandler</a></li>
-                 <li><a href="#XML_SetCharacterDataHandler">XML_SetCharacterDataHandler</a></li>
-                 <li><a href="#XML_SetProcessingInstructionHandler">XML_SetProcessingInstructionHandler</a></li>
-                 <li><a href="#XML_SetCommentHandler">XML_SetCommentHandler</a></li>
-                 <li><a href="#XML_SetStartCdataSectionHandler">XML_SetStartCdataSectionHandler</a></li>
-                 <li><a href="#XML_SetEndCdataSectionHandler">XML_SetEndCdataSectionHandler</a></li>
-                 <li><a href="#XML_SetCdataSectionHandler">XML_SetCdataSectionHandler</a></li>
-                 <li><a href="#XML_SetDefaultHandler">XML_SetDefaultHandler</a></li>
-                 <li><a href="#XML_SetDefaultHandlerExpand">XML_SetDefaultHandlerExpand</a></li>
-                 <li><a href="#XML_SetExternalEntityRefHandler">XML_SetExternalEntityRefHandler</a></li>
-                 <li><a href="#XML_SetUnknownEncodingHandler">XML_SetUnknownEncodingHandler</a></li>
-                 <li><a href="#XML_SetStartCdataSectionHandler">XML_SetStartCdataSectionHandler</a></li>
-                 <li><a href="#XML_SetEndNamespaceDeclHandler">XML_SetEndNamespaceDeclHandler</a></li>
-                 <li><a href="#XML_SetNamespaceDeclHandler">XML_SetNamespaceDeclHandler</a></li>
-                 <li><a href="#XML_SetXmlDeclHandler">XML_SetXmlDeclHandler</a></li>             
-                 <li><a href="#XML_SetStartDoctypeDeclHandler">XML_SetStartDoctypeDeclHandler</a></li>
-                 <li><a href="#XML_SetEndDoctypeDeclHandler">XML_SetEndDoctypeDeclHandler</a></li>
-                 <li><a href="#XML_SetDoctypeDeclHandler">XML_SetDoctypeDeclHandler</a></li>
-                 <li><a href="#XML_SetElementDeclHandler">XML_SetElementDeclHandler</a></li>
-                 <li><a href="#XML_SetAttlistDeclHandler">XML_SetAttlistDeclHandler</a></li>
-                 <li><a href="#XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</a></li>
-                 <li><a href="#XML_SetUnparsedEntityDeclHandler">XML_SetUnparsedEntityDeclHandler</a></li>
-                 <li><a href="#XML_SetNotationDeclHandler">XML_SetNotationDeclHandler</a></li>
-                 <li><a href="#XML_SetNotStandaloneHandler">XML_SetNotStandaloneHandler</a></li>
-             </ul>
-         </li>
-         <li><a href="#position">Parse Position and Error Reporting Functions</a>
-             <ul>
-                 <li><a href="#XML_GetErrorCode">XML_GetErrorCode</a></li>
-                 <li><a href="#XML_ErrorString">XML_ErrorString</a></li>
-                 <li><a href="#XML_GetCurrentByteIndex">XML_GetCurrentByteIndex</a></li>
-                 <li><a href="#XML_GetCurrentLineNumber">XML_GetCurrentLineNumber</a></li>
-                 <li><a href="#XML_GetCurrentColumnNumber">XML_GetCurrentColumnNumber</a></li>
-                 <li><a href="#XML_GetCurrentByteCount">XML_GetCurrentByteCount</a></li>
-                 <li><a href="#XML_GetInputContext">XML_GetInputContext</a></li>
-             </ul>
-         </li>
-         <li><a href="#miscellaneous">Miscellaneous Functions</a>
-             <ul>
-                 <li><a href="#XML_SetUserData">XML_SetUserData</a></li>
-                 <li><a href="#XML_GetUserData">XML_GetUserData</a></li>
-                 <li><a href="#XML_UseParserAsHandlerArg">XML_UseParserAsHandlerArg</a></li>
-                 <li><a href="#XML_SetBase">XML_SetBase</a></li>
-                 <li><a href="#XML_GetBase">XML_GetBase</a></li>
-                 <li><a href="#XML_GetSpecifiedAttributeCount">XML_GetSpecifiedAttributeCount</a></li>
-                 <li><a href="#XML_GetIdAttributeIndex">XML_GetIdAttributeIndex</a></li>
-                 <li><a href="#XML_SetEncoding">XML_SetEncoding</a></li>
-                 <li><a href="#XML_SetParamEntityParsing">XML_SetParamEntityParsing</a></li>
-                 <li><a href="#XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a></li>
-                 <li><a href="#XML_ExpatVersion">XML_ExpatVersion</a></li>
-             </ul>
-         </li>
-      </ul>  
+  <ul>
+    <li><a href="#creation">Parser Creation Functions</a>
+    <ul>
+      <li><a href="#XML_ParserCreate">XML_ParserCreate</a></li>
+      <li><a href="#XML_ParserCreateNS">XML_ParserCreateNS</a></li>
+      <li><a href="#XML_ParserCreate_MM">XML_ParserCreate_MM</a></li>
+      <li><a href="#XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</a></li>
+      <li><a href="#XML_ParserFree">XML_ParserFree</a></li>
+      <li><a href="#XML_ParserReset">XML_ParserReset</a></li>
+    </ul>
+    </li>
+    <li><a href="#parsing">Parsing Functions</a>
+    <ul>
+      <li><a href="#XML_Parse">XML_Parse</a></li>
+      <li><a href="#XML_ParseBuffer">XML_ParseBuffer</a></li>
+      <li><a href="#XML_GetBuffer">XML_GetBuffer</a></li>
+    </ul>
+    </li>
+    <li><a href="#setting">Handler Setting Functions</a>
+    <ul>
+      <li><a href="#XML_SetStartElementHandler">XML_SetStartElementHandler</a></li>
+      <li><a href="#XML_SetEndElementHandler">XML_SetEndElementHandler</a></li>
+      <li><a href="#XML_SetElementHandler">XML_SetElementHandler</a></li>
+      <li><a href="#XML_SetCharacterDataHandler">XML_SetCharacterDataHandler</a></li>
+      <li><a href="#XML_SetProcessingInstructionHandler">XML_SetProcessingInstructionHandler</a></li>
+      <li><a href="#XML_SetCommentHandler">XML_SetCommentHandler</a></li>
+      <li><a href="#XML_SetStartCdataSectionHandler">XML_SetStartCdataSectionHandler</a></li>
+      <li><a href="#XML_SetEndCdataSectionHandler">XML_SetEndCdataSectionHandler</a></li>
+      <li><a href="#XML_SetCdataSectionHandler">XML_SetCdataSectionHandler</a></li>
+      <li><a href="#XML_SetDefaultHandler">XML_SetDefaultHandler</a></li>
+      <li><a href="#XML_SetDefaultHandlerExpand">XML_SetDefaultHandlerExpand</a></li>
+      <li><a href="#XML_SetExternalEntityRefHandler">XML_SetExternalEntityRefHandler</a></li>
+      <li><a href="#XML_SetExternalEntityRefHandlerArg">XML_SetExternalEntityRefHandlerArg</a></li>
+      <li><a href="#XML_SetSkippedEntityHandler">XML_SetSkippedEntityHandler</a></li>
+      <li><a href="#XML_SetUnknownEncodingHandler">XML_SetUnknownEncodingHandler</a></li>
+      <li><a href="#XML_SetStartNamespaceDeclHandler">XML_SetStartNamespaceDeclHandler</a></li>
+      <li><a href="#XML_SetEndNamespaceDeclHandler">XML_SetEndNamespaceDeclHandler</a></li>
+      <li><a href="#XML_SetNamespaceDeclHandler">XML_SetNamespaceDeclHandler</a></li>
+      <li><a href="#XML_SetXmlDeclHandler">XML_SetXmlDeclHandler</a></li>                
+      <li><a href="#XML_SetStartDoctypeDeclHandler">XML_SetStartDoctypeDeclHandler</a></li>
+      <li><a href="#XML_SetEndDoctypeDeclHandler">XML_SetEndDoctypeDeclHandler</a></li>
+      <li><a href="#XML_SetDoctypeDeclHandler">XML_SetDoctypeDeclHandler</a></li>
+      <li><a href="#XML_SetElementDeclHandler">XML_SetElementDeclHandler</a></li>
+      <li><a href="#XML_SetAttlistDeclHandler">XML_SetAttlistDeclHandler</a></li>
+      <li><a href="#XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</a></li>
+      <li><a href="#XML_SetUnparsedEntityDeclHandler">XML_SetUnparsedEntityDeclHandler</a></li>
+      <li><a href="#XML_SetNotationDeclHandler">XML_SetNotationDeclHandler</a></li>
+      <li><a href="#XML_SetNotStandaloneHandler">XML_SetNotStandaloneHandler</a></li>
+    </ul>
+    </li>
+    <li><a href="#position">Parse Position and Error Reporting Functions</a>
+    <ul>
+      <li><a href="#XML_GetErrorCode">XML_GetErrorCode</a></li>
+      <li><a href="#XML_ErrorString">XML_ErrorString</a></li>
+      <li><a href="#XML_GetCurrentByteIndex">XML_GetCurrentByteIndex</a></li>
+      <li><a href="#XML_GetCurrentLineNumber">XML_GetCurrentLineNumber</a></li>
+      <li><a href="#XML_GetCurrentColumnNumber">XML_GetCurrentColumnNumber</a></li>
+      <li><a href="#XML_GetCurrentByteCount">XML_GetCurrentByteCount</a></li>
+      <li><a href="#XML_GetInputContext">XML_GetInputContext</a></li>
+    </ul>
+    </li>
+    <li><a href="#miscellaneous">Miscellaneous Functions</a>
+    <ul>
+      <li><a href="#XML_SetUserData">XML_SetUserData</a></li>
+      <li><a href="#XML_GetUserData">XML_GetUserData</a></li>
+      <li><a href="#XML_UseParserAsHandlerArg">XML_UseParserAsHandlerArg</a></li>
+      <li><a href="#XML_SetBase">XML_SetBase</a></li>
+      <li><a href="#XML_GetBase">XML_GetBase</a></li>
+      <li><a href="#XML_GetSpecifiedAttributeCount">XML_GetSpecifiedAttributeCount</a></li>
+      <li><a href="#XML_GetIdAttributeIndex">XML_GetIdAttributeIndex</a></li>
+      <li><a href="#XML_SetEncoding">XML_SetEncoding</a></li>
+      <li><a href="#XML_SetParamEntityParsing">XML_SetParamEntityParsing</a></li>
+      <li><a href="#XML_UseForeignDTD">XML_UseForeignDTD</a></li>
+      <li><a href="#XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a></li>
+      <li><a href="#XML_DefaultCurrent">XML_DefaultCurrent</a></li>
+      <li><a href="#XML_ExpatVersion">XML_ExpatVersion</a></li>
+      <li><a href="#XML_ExpatVersionInfo">XML_ExpatVersionInfo</a></li>
+      <li><a href="#XML_GetFeatureList">XML_GetFeatureList</a></li>
+      <li><a href="#XML_FreeContentModel">XML_FreeContentModel</a></li>
+      <li><a href="#XML_MemMalloc">XML_MemMalloc</a></li>
+      <li><a href="#XML_MemRealloc">XML_MemRealloc</a></li>
+      <li><a href="#XML_MemFree">XML_MemFree</a></li>
+    </ul>
+    </li>
+  </ul>  
   </li>
 </ul>
 
-<hr>
+<hr />
 <h2><a name="overview">Overview</a></h2>
-<p>Expat is a stream-oriented parser. You register callback (or handler) 
-functions with
-the parser and then start feeding it the document.
-As the parser recognizes parts of
-the document, it will call the appropriate handler for that part (if you've
-registered one.) The document is fed to the parser in pieces, so you can
-start parsing before you have all the document. This also allows you to
-parse really huge documents that won't fit into memory.</p>
-
-<p>Expat can be intimidating due to the many kinds of handlers and options
-you can set. But you only need to learn four functions in order to do 90%
-of what you'll want to do with it:</p>
+
+<p>Expat is a stream-oriented parser. You register callback (or
+handler) functions with the parser and then start feeding it the
+document.  As the parser recognizes parts of the document, it will
+call the appropriate handler for that part (if you've registered one.) 
+The document is fed to the parser in pieces, so you can start parsing
+before you have all the document. This also allows you to parse really
+huge documents that won't fit into memory.</p>
+
+<p>Expat can be intimidating due to the many kinds of handlers and
+options you can set. But you only need to learn four functions in
+order to do 90% of what you'll want to do with it:</p>
 
 <dl>
 
-<dt><code>XML_ParserCreate</code></dt>
+<dt><code><a href= "#XML_ParserCreate"
+             >XML_ParserCreate</a></code></dt>
   <dd>Create a new parser object.</dd>
 
-<dt><code>XML_SetElementHandler</code></dt>
+<dt><code><a href= "#XML_SetElementHandler"
+             >XML_SetElementHandler</a></code></dt>
   <dd>Set handlers for start and end tags.</dd>
 
-<dt><code>XML_SetCharacterDataHandler</code></dt>
+<dt><code><a href= "#XML_SetCharacterDataHandler"
+             >XML_SetCharacterDataHandler</a></code></dt>
   <dd>Set handler for text.</dd>
 
-<dt><code>XML_Parse</code></dt>
+<dt><code><a href= "#XML_Parse"
+             >XML_Parse</a></code></dt>
   <dd>Pass a buffer full of document to the parser</dd>
 </dl>
 
-<p>These functions and others are described in the
-<a href="#reference">reference</a> part of this document. The reference
-section also describes in detail the parameters passed to the different
-types of handlers.
-
-<p>Let's look at a very simple example program that only uses 3 of the above
-functions (it doesn't need to set a character handler.) The program
-<a href="../examples/outline.c">outline.c</a>
-prints an element outline, indenting child elements to distinguish them from
-the parent element that contains them. The start handler does all the work.
-It prints two indenting spaces for every level of ancestor elements, then
-it prints the element and attribute information. Finally it increments the
-global Depth variable.
-
-<div class="eg">
-<pre>
+<p>These functions and others are described in the <a
+href="#reference">reference</a> part of this document. The reference
+section also describes in detail the parameters passed to the
+different types of handlers.</p>
+
+<p>Let's look at a very simple example program that only uses 3 of the
+above functions (it doesn't need to set a character handler.) The
+program <a href="../examples/outline.c">outline.c</a> prints an
+element outline, indenting child elements to distinguish them from the
+parent element that contains them. The start handler does all the
+work.  It prints two indenting spaces for every level of ancestor
+elements, then it prints the element and attribute
+information. Finally it increments the global <code>Depth</code>
+variable.</p>
+
+<pre class="eg">
 int Depth;
 
-void
+void XMLCALL
 start(void *data, const char *el, const char **attr) {
   int i;
 
@@ -184,83 +213,181 @@ start(void *data, const char *el, const char **attr) {
   Depth++;
 }  /* End of start handler */
 </pre>
-</div>
 
-<p>The end tag simply does the bookkeeping work of decrementing the Depth.
-<div class="eg">
-<pre>
-void
+<p>The end tag simply does the bookkeeping work of decrementing
+<code>Depth</code>.</p>
+<pre class="eg">
+void XMLCALL
 end(void *data, const char *el) {
   Depth--;
 }  /* End of end handler */
 </pre>
-</div>
+
+<p>Note the <code>XMLCALL</code> annotation used for the callbacks.
+This is used to ensure that the Expat and the callbacks are using the
+same calling convention in case the compiler options used for Expat
+itself and the client code are different.  Expat tries not to care
+what the default calling convention is, though it may require that it
+be compiled with a default convention of "cdecl" on some platforms.
+For code which uses Expat, however, the calling convention is
+specified by the <code>XMLCALL</code> annotation on most platforms;
+callbacks should be defined using this annotation.</p>
+
+<p>The <code>XMLCALL</code> annotation was added in Expat 1.95.7, but
+existing working Expat applications don't need to add it (since they
+are already using the "cdecl" calling convention, or they wouldn't be
+working).  The annotation is only needed if the default calling
+convention may be something other than "cdecl".  To use the annotation
+safely with older versions of Expat, you can conditionally define it
+<em>after</em> including Expat's header file:</p>
+
+<pre class="eg">
+#include &lt;expat.h&gt;
+
+#ifndef XMLCALL
+#if defined(_MSC_EXTENSIONS) &amp;&amp; !defined(__BEOS__) &amp;&amp; !defined(__CYGWIN__)
+#define XMLCALL __cdecl
+#elif defined(__GNUC__)
+#define XMLCALL __attribute__((cdecl))
+#else
+#define XMLCALL
+#endif
+#endif
+</pre>
 
 <p>After creating the parser, the main program just has the job of
-shoveling the document to the parser so that it can do its work.
+shoveling the document to the parser so that it can do its work.</p>
+
+<hr />
+<h2><a name="building">Building and Installing Expat</a></h2>
+
+<p>The Expat distribution comes as a compressed (with GNU gzip) tar
+file.  You may download the latest version from <a href=
+"http://sourceforge.net/projects/expat/" >Source Forge</a>.  After
+unpacking this, cd into the directory. Then follow either the Win32
+directions or Unix directions below.</p>
+
+<h3>Building under Win32</h3>
+
+<p>If you're using the GNU compiler under cygwin, follow the Unix
+directions in the next section. Otherwise if you have Microsoft's
+Developer Studio installed, then from Windows Explorer double-click on
+"expat.dsp" in the lib directory and build and install in the usual
+manner.</p>
+
+<p>Alternatively, you may download the Win32 binary package that
+contains the "expat.h" include file and a pre-built DLL.</p>
+
+<h3>Building under Unix (or GNU)</h3>
+
+<p>First you'll need to run the configure shell script in order to
+configure the Makefiles and headers for your system.</p>
 
-<hr>
-<h2><a name="building">Building and Installing expat</a></h2>
-<p>The expat distribution comes as a compressed (with GNU gzip) tar file.
-After unpacking this, cd into the directory and run the configure shell
-script.
-</p>
 <p>If you're happy with all the defaults that configure picks for you,
-and you have permission on your system to install into /usr/local, you can
-install expat with this sequence of commands:</p>
+and you have permission on your system to install into /usr/local, you
+can install Expat with this sequence of commands:</p>
 
-<pre>
-   ./configure
-   make
-   make install
+<pre class="eg">
+./configure
+make
+make install
 </pre>
 
 <p>There are some options that you can provide to this script, but the
-only one we'll mention here is the <code>--prefix</code> option. You can
-find out all the options available by running configure with just the
-<code>--help</code> option.
-</p>
-
-By default, the configure script sets things up so that the library gets
-installed in <code>/usr/local/lib</code> and the associated header file in
-<code>/usr/local/include</code>.
-But if you were to give the option, <code>--prefix=/home/me/mystuff</code>,
-then the library and header would get installed in
-<code>/home/me/mystuff/lib</code> and <code>/home/me/mystuff/include</code>
-respectively.
-</p>
+only one we'll mention here is the <code>--prefix</code> option. You
+can find out all the options available by running configure with just
+the <code>--help</code> option.</p>
+
+<p>By default, the configure script sets things up so that the library
+gets installed in <code>/usr/local/lib</code> and the associated
+header file in <code>/usr/local/include</code>.  But if you were to
+give the option, <code>--prefix=/home/me/mystuff</code>, then the
+library and header would get installed in
+<code>/home/me/mystuff/lib</code> and
+<code>/home/me/mystuff/include</code> respectively.</p>
+
+<h3>Configuring Expat Using the Pre-Processor</h3>
+
+<p>Expat's feature set can be configured using a small number of
+pre-processor definitions.  The definition of this symbols does not
+affect the set of entry points for Expat, only the behavior of the API
+and the definition of character types in the case of
+<code>XML_UNICODE_WCHAR_T</code>.  The symbols are:</p>
+
+<dl class="cpp-symbols">
+<dt>XML_DTD</dt>
+<dd>Include support for using and reporting DTD-based content.  If
+this is defined, default attribute values from the DTD are reported
+and attribute value normalization occurs based on the type of
+attributes.  Callbacks can be registered which report information from
+the DTD (including content models and attribute definitions) only if
+this is defined.  Without this, Expat has a smaller memory footprint
+and can be faster.</dd>
+
+<dt>XML_NS</dt>
+<dd>When defined, support for the <cite><a href=
+"http://www.w3.org/TR/REC-xml-names/" >Namespaces in XML</a></cite>
+specification is included.</dd>
+
+<dt>XML_UNICODE</dt>
+<dd>When defined, character data reported to the application is
+encoded in UTF-16 using wide characters of the type
+<code>XML_Char</code>.  This is implied if
+<code>XML_UNICODE_WCHAR_T</code> is defined.</dd>
+
+<dt>XML_UNICODE_WCHAR_T</dt>
+<dd>If defined, causes the <code>XML_Char</code> character type to be
+defined using the <code>wchar_t</code> type; otherwise, <code>unsigned
+short</code> is used.  Defining this implies
+<code>XML_UNICODE</code>.</dd>
+
+<dt>XML_CONTEXT_BYTES</dt>
+<dd>The number of input bytes of markup context which the parser will
+ensure are available for reporting via <code><a href=
+"#XML_GetInputContext" >XML_GetInputContext</a></code>.  This is
+normally set to 1024.  If this is not defined, the input context will
+not be available and <code><a href= "#XML_GetInputContext"
+>XML_GetInputContext</a></code> will always report NULL.  Without
+this, Expat has a smaller memory footprint and can be faster.</dd>
+
+<dt>XML_STATIC</dt>
+<dd>On Windows, this should be set if Expat is going to be linked
+statically with the code that calls it; this is required to get all
+the right MSVC magic annotations correct.  This is ignored on other
+platforms.</dd>
+</dl>
 
-<hr>
+<hr />
 <h2><a name="using">Using Expat</a></h2>
-<h3>Compiling and Linking against expat</h3>
-<p>Unless you installed expat in a location not expected by your compiler
-and linker, all you have to do to use expat in your programs is to include
-the expat header (<code>#include &lt;expat.h&gt;</code>) in your files that
-make calls to it and to tell the linker
-that it needs to link against the expat library. On Unix systems, this would
-be the <code>-lexpat</code> argument.
-Otherwise, you'll need to tell the compiler where to look for the expat header
-and the linker where to find the expat library. You may also need to take
-steps to tell the operating system where to find this libary at run time.
-</p>
-<p>On a Unix based system, here's what a Makefile might look like when expat
-is installed in a standard location:</p>
 
-<div class="eg">
-<pre>
+<h3>Compiling and Linking Against Expat</h3>
+
+<p>Unless you installed Expat in a location not expected by your
+compiler and linker, all you have to do to use Expat in your programs
+is to include the Expat header (<code>#include &lt;expat.h&gt;</code>)
+in your files that make calls to it and to tell the linker that it
+needs to link against the Expat library.  On Unix systems, this would
+usually be done with the <code>-lexpat</code> argument.  Otherwise,
+you'll need to tell the compiler where to look for the Expat header
+and the linker where to find the Expat library.  You may also need to
+take steps to tell the operating system where to find this libary at
+run time.</p>
+
+<p>On a Unix-based system, here's what a Makefile might look like when
+Expat is installed in a standard location:</p>
+
+<pre class="eg">
 CC=cc
 LDFLAGS=
 LIBS= -lexpat
 xmlapp: xmlapp.o
         $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS)
 </pre>
-</div>
 
-<p>If you installed expat in, say, <code>/home/me/mystuff</code>, then
+<p>If you installed Expat in, say, <code>/home/me/mystuff</code>, then
 the Makefile would look like this:</p>
 
-<div class="eg">
-<pre>
+<pre class="eg">
 CC=cc
 CFLAGS= -I/home/me/mystuff/include
 LDFLAGS=
@@ -268,62 +395,61 @@ LIBS= -L/home/me/mystuff/lib -lexpat
 xmlapp: xmlapp.o
         $(CC) $(LDFLAGS) -o xmlapp xmlapp.o $(LIBS)
 </pre>
-</div>
 
-<p>You'd also have to set the environment variable <code>LD_LIBRARY_PATH</code>
-to <code>/home/me/mystuff/lib</code> (or to
-<code>${LD_LIBRARY_PATH}:/home/me/mystuff/lib</code> if LD_LIBRARY_PATH
-already has some directories in it) in order to run your application.
-</p>
+<p>You'd also have to set the environment variable
+<code>LD_LIBRARY_PATH</code> to <code>/home/me/mystuff/lib</code> (or
+to <code>${LD_LIBRARY_PATH}:/home/me/mystuff/lib</code> if
+LD_LIBRARY_PATH already has some directories in it) in order to run
+your application.</p>
 
 <h3>Expat Basics</h3>
-<p>As we saw in the example in the overview, the first step in parsing an
-XML document with expat is to create a parser object. There are
-<a href="#creation">three functions</a> in the expat API for creating a
-parser object.
-However, only two of these
-(<a href="#XML_ParserCreate"><code>XML_ParserCreate</code></a> and
-<a href="#XML_ParserCreateNS"><code>XML_ParserCreateNS</code></a>)
-can be used for constructing a parser for a top-level document.
-The object returned by these functions is an opaque pointer
-(i.e. expat.h declares it as void *) to data with further internal structure. 
-In order to free the memory associated with this object you must call
-<a href="#XML_ParserFree"><code>XML_ParserFree</code></a>. Note that if
-you have provided any <a href="userdata">user data</a> that gets stored
-in the parser, then your application is responsible for freeing it prior to
-calling XML_ParserFree.
-</p>
+
+<p>As we saw in the example in the overview, the first step in parsing
+an XML document with Expat is to create a parser object. There are <a
+href="#creation">three functions</a> in the Expat API for creating a
+parser object.  However, only two of these (<code><a href=
+"#XML_ParserCreate" >XML_ParserCreate</a></code> and <code><a href=
+"#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>) can be used for
+constructing a parser for a top-level document.  The object returned
+by these functions is an opaque pointer (i.e. "expat.h" declares it as
+void *) to data with further internal structure. In order to free the
+memory associated with this object you must call <code><a href=
+"#XML_ParserFree" >XML_ParserFree</a></code>. Note that if you have
+provided any <a href="userdata">user data</a> that gets stored in the
+parser, then your application is responsible for freeing it prior to
+calling <code>XML_ParserFree</code>.</p>
 
 <p>The objects returned by the parser creation functions are good for
-parsing only one XML document or external parsed entity. If your application
-needs to parse many XML documents, then it needs to create a parser object
-for each one. The best way to deal with this is to create a higher level
-object that contains all the default initialization you want for your parser
-objects.
-
-<p>Walking through a document hierarchy with a stream oriented parser will
-require a good stack mechanism in order to keep track of current context.
-For instance, to answer the simple question,
-"What element does this text belong to?" requires a stack, since the
-parser may have descended into other elements that are children of the
-current one and has encountered this text on the way out.
-
-<p>The things you're likely to want to keep on a stack are the currently
-opened element and it's attributes. You push this information onto the
-stack in the start handler and you pop it off in the end handler.
-
-<p>For some tasks, it is sufficient to just keep information on what the
-depth of the stack is (or would be if you had one.) The outline program shown
-above presents one example. Another such task would be skipping over a
-complete element. When you see the start tag for the element you want to
-skip, you set a skip flag and record the depth at which the element started.
-When the end tag handler encounters the same depth, the skipped element has
-ended and the flag may be cleared. If you follow the convention that the
-root element starts at 1, then you can use the same variable for skip flag
-and skip depth.
-
-<div class="eg">
-<pre>
+parsing only one XML document or external parsed entity. If your
+application needs to parse many XML documents, then it needs to create
+a parser object for each one. The best way to deal with this is to
+create a higher level object that contains all the default
+initialization you want for your parser objects.</p>
+
+<p>Walking through a document hierarchy with a stream oriented parser
+will require a good stack mechanism in order to keep track of current
+context.  For instance, to answer the simple question, "What element
+does this text belong to?" requires a stack, since the parser may have
+descended into other elements that are children of the current one and
+has encountered this text on the way out.</p>
+
+<p>The things you're likely to want to keep on a stack are the
+currently opened element and it's attributes. You push this
+information onto the stack in the start handler and you pop it off in
+the end handler.</p>
+
+<p>For some tasks, it is sufficient to just keep information on what
+the depth of the stack is (or would be if you had one.) The outline
+program shown above presents one example. Another such task would be
+skipping over a complete element. When you see the start tag for the
+element you want to skip, you set a skip flag and record the depth at
+which the element started.  When the end tag handler encounters the
+same depth, the skipped element has ended and the flag may be
+cleared. If you follow the convention that the root element starts at
+1, then you can use the same variable for skip flag and skip
+depth.</p>
+
+<pre class="eg">
 void
 init_info(Parseinfo *info) {
   info->skip = 0;
@@ -331,7 +457,7 @@ init_info(Parseinfo *info) {
   /* Other initializations here */
 }  /* End of init_info */
 
-void
+void XMLCALL
 rawstart(void *data, const char *el, const char **attr) {
   Parseinfo *inf = (Parseinfo *) data;
 
@@ -346,7 +472,7 @@ rawstart(void *data, const char *el, const char **attr) {
   inf->depth++;
 }  /* End of rawstart */
 
-void
+void XMLCALL
 rawend(void *data, const char *el) {
   Parseinfo *inf = (Parseinfo *) data;
 
@@ -358,119 +484,159 @@ rawend(void *data, const char *el) {
   if (inf->skip == inf->depth)
     inf->skip = 0;
 }  /* End rawend */
-
 </pre>
-</div>
 
-<p>Notice in the above example the difference in how depth is manipulated
-in the start and end handlers. The end tag handler should be the mirror
-image of the start tag handler. This is necessary to properly model
-containment. Since, in the start tag handler, we
-incremented depth <em>after</em> the main body of start tag code, then in
-the end handler, we need to manipulate it <em>before</em> the main body.
-If we'd decided to increment it first thing in the start handler, then
-we'd have had to decrement it last thing in the end handler.
+<p>Notice in the above example the difference in how depth is
+manipulated in the start and end handlers. The end tag handler should
+be the mirror image of the start tag handler. This is necessary to
+properly model containment. Since, in the start tag handler, we
+incremented depth <em>after</em> the main body of start tag code, then
+in the end handler, we need to manipulate it <em>before</em> the main
+body.  If we'd decided to increment it first thing in the start
+handler, then we'd have had to decrement it last thing in the end
+handler.</p>
 
-<h3>Communicating between handlers</h3>
+<h3 id="userdata">Communicating between handlers</h3>
 
 <p>In order to be able to pass information between different handlers
 without using globals, you'll need to define a data structure to hold
-the shared variables. You can then tell expat (with the XML_SetUserData
-function) to pass a pointer to this
-structure to the handlers. This is typically the first argument received
-by most handlers.
+the shared variables. You can then tell Expat (with the <code><a href=
+"#XML_SetUserData" >XML_SetUserData</a></code> function) to pass a
+pointer to this structure to the handlers. This is typically the first
+argument received by most handlers.</p>
+
+<h3>XML Version</h3>
+
+<p>Expat is an XML 1.0 parser, and as such never complains based on
+the value of the <code>version</code> pseudo-attribute in the XML
+declaration, if present.</p>
+
+<p>If an application needs to check the version number (to support
+alternate processing), it should use the <code><a href=
+"#XML_SetXmlDeclHandler" >XML_SetXmlDeclHandler</a></code> function to
+set a handler that uses the information in the XML declaration to
+determine what to do.  This example shows how to check that only a
+version number of <code>"1.0"</code> is accepted:</p>
+
+<pre class="eg">
+static int wrong_version;
+static XML_Parser parser;
+
+static void XMLCALL
+xmldecl_handler(void            *userData,
+                const XML_Char  *version,
+                const XML_Char  *encoding,
+                int              standalone)
+{
+  static const XML_Char Version_1_0[] = {'1', '.', '0', 0};
+
+  int i;
+
+  for (i = 0; i &lt; (sizeof(Version_1_0) / sizeof(Version_1_0[0])); ++i) {
+    if (version[i] != Version_1_0[i]) {
+      wrong_version = 1;
+      /* also clear all other handlers: */
+      XML_SetCharacterDataHandler(parser, NULL);
+      ...
+      return;
+    }
+  }
+  ...
+}
+</pre>
 
 <h3>Namespace Processing</h3>
 
-<p>When the parser is created using the <code>XML_ParserCreateNS</code>,
-function, expat performs namespace processing. Under namespace processing,
-expat consumes <code>xmlns</code> and <code>xmlns:...</code> attributes,
+<p>When the parser is created using the <code><a href=
+"#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>, function, Expat
+performs namespace processing. Under namespace processing, Expat
+consumes <code>xmlns</code> and <code>xmlns:...</code> attributes,
 which declare namespaces for the scope of the element in which they
-occur. This means that your start handler will not see these attributes.
-Your application can still be informed of these declarations by setting
-namespace declaration handlers with
-<a href="#XML_SetNamespaceDeclHandler">
-<code>XML_SetNamespaceDeclHandler</code></a>.
-
-<p>Element type and attribute names that belong to a given namespace are
-passed to the appropriate handler in expanded form. By default this expanded
-form is a concatenation of the namespace URI, the separator character (which
-is the 2nd argument to <code>XML_ParserCreateNS</code>), and the local
-name (i.e. the part after the colon). Names with undeclared prefixes are
-passed through to the handlers unchanged, with the prefix and colon still
-attached. Unprefixed attribute names are never expanded, and unprefixed
-element names are only expanded when they are in the scope of a default
-namespace.
-
-<p>However if <a href="XML_SetReturnNSTriplet">XML_SetReturnNSTriplet</a>
-has been called with a non-zero <code>do_nst</code> parameter, then the
-expanded form for names with an explicit prefix is a concatenation of:
-URI, separator, local name, separator, prefix.
-</p>
-
-<p>You can set handlers for the start of a namespace declaration and for
-the end of a scope of a declaration with the
-<code>XML_SetNamespaceDeclHandler</code> function.
-The StartNamespaceDeclHandler is called prior to the start tag handler
-and the EndNamespaceDeclHandler is called before the corresponding end tag
-that ends the namespace's scope.
-The namespace start handler gets passed the prefix and URI for the namespace.
-For a default namespace declaration (xmlns='...'), the prefix will be null.
-The URI will be null for the case where the default namespace is being unset.
-The namespace end handler just gets the prefix for the closing scope.
-
-<p>These handlers are called for each declaration. So if, for instance, a
-start tag had three namespace declarations, then the StartNamespaceDeclHandler
-would be called three times before the start tag handler is called, once for
-each declaration.
-
-<p>The <a href="src/namespace.c">namespace.c</a> example demonstrates the
-use of these features. Like outline.c, it produces an outline, but
-in addition it annotates when a namespace scope starts and when it ends.
-This example also demonstrates use of application user data.
+occur. This means that your start handler will not see these
+attributes.  Your application can still be informed of these
+declarations by setting namespace declaration handlers with <a href=
+"#XML_SetNamespaceDeclHandler"
+><code>XML_SetNamespaceDeclHandler</code></a>.</p>
+
+<p>Element type and attribute names that belong to a given namespace
+are passed to the appropriate handler in expanded form. By default
+this expanded form is a concatenation of the namespace URI, the
+separator character (which is the 2nd argument to <code><a href=
+"#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>), and the local
+name (i.e. the part after the colon). Names with undeclared prefixes
+are passed through to the handlers unchanged, with the prefix and
+colon still attached. Unprefixed attribute names are never expanded,
+and unprefixed element names are only expanded when they are in the
+scope of a default namespace.</p>
+
+<p>However if <code><a href= "XML_SetReturnNSTriplet"
+>XML_SetReturnNSTriplet</a></code> has been called with a non-zero
+<code>do_nst</code> parameter, then the expanded form for names with
+an explicit prefix is a concatenation of: URI, separator, local name,
+separator, prefix.</p>
+
+<p>You can set handlers for the start of a namespace declaration and
+for the end of a scope of a declaration with the <code><a href=
+"#XML_SetNamespaceDeclHandler" >XML_SetNamespaceDeclHandler</a></code>
+function.  The StartNamespaceDeclHandler is called prior to the start
+tag handler and the EndNamespaceDeclHandler is called before the
+corresponding end tag that ends the namespace's scope.  The namespace
+start handler gets passed the prefix and URI for the namespace.  For a
+default namespace declaration (xmlns='...'), the prefix will be null.
+The URI will be null for the case where the default namespace is being
+unset.  The namespace end handler just gets the prefix for the closing
+scope.</p>
+
+<p>These handlers are called for each declaration. So if, for
+instance, a start tag had three namespace declarations, then the
+StartNamespaceDeclHandler would be called three times before the start
+tag handler is called, once for each declaration.</p>
 
 <h3>Character Encodings</h3>
 
-<p>While XML is based on Unicode, and every XML processor is required to
-recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode), other
-encodings may be declared in XML documents or entities. For the main
-document, an XML declaration may contain an encoding declaration:
+<p>While XML is based on Unicode, and every XML processor is required
+to recognized UTF-8 and UTF-16 (1 and 2 byte encodings of Unicode),
+other encodings may be declared in XML documents or entities. For the
+main document, an XML declaration may contain an encoding
+declaration:</p>
 <pre>
 &lt;?xml version="1.0" encoding="ISO-8859-2"?&gt;
 </pre>
 
 <p>External parsed entities may begin with a text declaration, which
-looks like an XML declaration with just an encoding declaration:
+looks like an XML declaration with just an encoding declaration:</p>
 <pre>
 &lt;?xml encoding="Big5"?&gt;
 </pre>
 
-<p>With expat, you may also specify an encoding at the time of creating a
-parser. This is useful when the encoding information may come from a source
-outside the document itself (like a higher level protocol.)
+<p>With Expat, you may also specify an encoding at the time of
+creating a parser. This is useful when the encoding information may
+come from a source outside the document itself (like a higher level
+protocol.)</p>
 
-<p><a name="builtin_encodings"></a>There are four built-in encodings in expat:
+<p><a name="builtin_encodings"></a>There are four built-in encodings
+in Expat:</p>
 <ul>
-<li>UTF-8
-<li>UTF-16
-<li>ISO-8859-1
-<li>US-ASCII
+<li>UTF-8</li>
+<li>UTF-16</li>
+<li>ISO-8859-1</li>
+<li>US-ASCII</li>
 </ul>
 
 <p>Anything else discovered in an encoding declaration or in the
 protocol encoding specified in the parser constructor, triggers a call
 to the <code>UnknownEncodingHandler</code>. This handler gets passed
 the encoding name and a pointer to an <code>XML_Encoding</code> data
-structure. Your handler must fill in this structure and return 1 if 
-it knows how to deal with the encoding. Otherwise the handler should
-return 0.
-The handler also gets passed a pointer to an
-optional application data structure that you may indicate when you set
-the handler.
-
-<p>Expat places restrictions on character encodings that it can support
-by filling in the <code>XML_Encoding</code> structure.
-include file:
+structure. Your handler must fill in this structure and return
+<code>XML_STATUS_OK</code> if it knows how to deal with the
+encoding. Otherwise the handler should return
+<code>XML_STATUS_ERROR</code>.  The handler also gets passed a pointer
+to an optional application data structure that you may indicate when
+you set the handler.</p>
+
+<p>Expat places restrictions on character encodings that it can
+support by filling in the <code>XML_Encoding</code> structure.
+include file:</p>
 <ol>
 <li>Every ASCII character that can appear in a well-formed XML document
 must be represented by a single byte, and that byte must correspond to
@@ -483,44 +649,48 @@ for UTF-16 and UTF-8</em></li>
 bytes</li>
 </ol>
 
-<p><code>XML_Encoding</code> contains an array of integers that correspond
-to the 1st byte of an encoding sequence. If the value in the array for a
-byte is zero or positive, then the byte is a single byte encoding that
-encodes the Unicode scalar value contained in the array. A -1 in this array
-indicates a malformed byte. If the value is
--2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte sequence
-respectively. Multi-byte sequences are sent to the convert function pointed
-at in the <code>XML_Encoding</code> structure. This function should return
-the Unicode scalar value for the sequence or -1 if the sequence is malformed.
-
-<p>One pitfall that novice expat users are likely to fall into is that
-although expat may accept input in various encodings, the strings that it
-passes to the handlers are always encoded in UTF-8. Your application is
-responsible for any translation of these strings into other encodings.
+<p><code>XML_Encoding</code> contains an array of integers that
+correspond to the 1st byte of an encoding sequence. If the value in
+the array for a byte is zero or positive, then the byte is a single
+byte encoding that encodes the Unicode scalar value contained in the
+array. A -1 in this array indicates a malformed byte. If the value is
+-2, -3, or -4, then the byte is the beginning of a 2, 3, or 4 byte
+sequence respectively. Multi-byte sequences are sent to the convert
+function pointed at in the <code>XML_Encoding</code> structure. This
+function should return the Unicode scalar value for the sequence or -1
+if the sequence is malformed.</p>
+
+<p>One pitfall that novice Expat users are likely to fall into is that
+although Expat may accept input in various encodings, the strings that
+it passes to the handlers are always encoded in UTF-8 or UTF-16
+(depending on how Expat was compiled). Your application is responsible
+for any translation of these strings into other encodings.</p>
 
 <h3>Handling External Entity References</h3>
 
-<p>Expat does not read or parse external entities directly. Note that any
-external DTD is a special case of an external entity.
-If you've set no <code>ExternalEntityRefHandler</code>, then external
-entity references are silently ignored. Otherwise, it calls your handler with
-the information needed to read and parse the external entity.
-
-<p>Your handler
-isn't actually responsible for parsing the entity, but it is responsible
-for creating a subsidiary parser with
-<code>XML_ExternalEntityParserCreate</code> that will do the job. This returns
-an instance of <code>XML_Parser</code> that has handlers and other data
-structures initialized from the parent parser. You may then use
-<code>XML_Parse</code> or <code>XML_ParseBuffer</code> calls against this
-parser.
-Since external entities my refer to other external entities, your handler
-should be prepared to be called recursively.
+<p>Expat does not read or parse external entities directly. Note that
+any external DTD is a special case of an external entity.  If you've
+set no <code>ExternalEntityRefHandler</code>, then external entity
+references are silently ignored. Otherwise, it calls your handler with
+the information needed to read and parse the external entity.</p>
+
+<p>Your handler isn't actually responsible for parsing the entity, but
+it is responsible for creating a subsidiary parser with <code><a href=
+"#XML_ExternalEntityParserCreate"
+>XML_ExternalEntityParserCreate</a></code> that will do the job. This
+returns an instance of <code>XML_Parser</code> that has handlers and
+other data structures initialized from the parent parser. You may then
+use <code><a href= "#XML_Parse" >XML_Parse</a></code> or <code><a
+href= "#XML_ParseBuffer">XML_ParseBuffer</a></code> calls against this
+parser.  Since external entities my refer to other external entities,
+your handler should be prepared to be called recursively.</p>
 
 <h3>Parsing DTDs</h3>
-<p>In order to parse parameter entities,  before starting the parse, you must
-call <code>XML_SetParamEntityParsing</code> with one of the following
-arguments:
+
+<p>In order to parse parameter entities, before starting the parse,
+you must call <code><a href= "#XML_SetParamEntityParsing"
+>XML_SetParamEntityParsing</a></code> with one of the following
+arguments:</p>
 <dl>
 <dt><code>XML_PARAM_ENTITY_PARSING_NEVER</code></dt>
 <dd>Don't parse parameter entities or the external subset</dd>
@@ -531,41 +701,38 @@ arguments:
 <dd>Always parse parameter entities and the external subset</dd>
 </dl>
 
-<p>In order to read an external DTD, you also have to set an
-external entity reference handler as described above.
+<p>In order to read an external DTD, you also have to set an external
+entity reference handler as described above.</p>
 
-<hr>
-<h2><a name="examples">Some expat Examples</a></h2>
-
-<hr>
+<hr />
 <!-- ================================================================ -->
 
 <h2><a name="reference">Expat Reference</a></h2>
 
 <h3><a name="creation">Parser Creation</a></h3>
 
-<div class="fcndec"><a name="XML_ParserCreate"><pre>
-XML_Parser
-XML_ParserCreate(const XML_Char *encoding)
-</pre></a></div>
+<pre class="fcndec" id="XML_ParserCreate">
+XML_Parser XMLCALL
+XML_ParserCreate(const XML_Char *encoding);
+</pre>
 <div class="fcndef">
 Construct a new parser. If encoding is non-null, it specifies a
 character encoding to use for the document. This overrides the document
 encoding declaration. There are four built-in encodings:
 <ul>
-<li>US-ASCII
-<li>UTF-8
-<li>UTF-16
-<li>ISO-8859-1
+<li>US-ASCII</li>
+<li>UTF-8</li>
+<li>UTF-16</li>
+<li>ISO-8859-1</li>
 </ul>
 Any other value will invoke a call to the UnknownEncodingHandler.
 </div>
 
-<div class="fcndec"><a name="XML_ParserCreateNS"><pre>
-XML_Parser
+<pre class="fcndec" id="XML_ParserCreateNS">
+XML_Parser XMLCALL
 XML_ParserCreateNS(const XML_Char *encoding,
-                   XML_Char sep)
-</pre></a></div>
+                   XML_Char sep);
+</pre>
 <div class="fcndef">
 Constructs a new parser that has namespace processing in effect. Namespace
 expanded element names and attribute names are returned as a concatenation
@@ -573,63 +740,95 @@ of the namespace URI, <em>sep</em>, and the local part of the name. This
 means that you should pick a character for <em>sep</em> that can't be
 part of a legal URI.</div>
 
-<div class="fcndec"><a name="XML_ParserCreate_MM"><pre>
-XML_Parser
+<pre class="fcndec" id="XML_ParserCreate_MM">
+XML_Parser XMLCALL
 XML_ParserCreate_MM(const XML_Char *encoding,
                     const XML_Memory_Handling_Suite *ms,
-                   const XML_Char *sep)
-</pre></a></div>
+                   const XML_Char *sep);
+</pre>
+<pre class="signature">
+typedef struct {
+  void *(XMLCALL *malloc_fcn)(size_t size);
+  void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
+  void (XMLCALL *free_fcn)(void *ptr);
+} XML_Memory_Handling_Suite;
+</pre>
 <div class="fcndef">
 <p>Construct a new parser using the suite of memory handling functions
 specified in <code>ms</code>. If <code>ms</code> is NULL, then use the
 standard set of memory management functions. If <code>sep</code> is
 non NULL, then namespace processing is enabled in the created parser
 and the character pointed at by sep is used as the separator between
-the namespace URI and the local part of the name</p>
-<div class="eg"><pre>
-typedef struct {
-  void *(*malloc_fcn)(size_t size);
-  void *(*realloc_fcn)(void *ptr, size_t size);
-  void (*free_fcn)(void *ptr);
-} XML_Memory_Handling_Suite;
-</pre></div>
+the namespace URI and the local part of the name.</p>
 </div>
 
-<div class="fcndec"><a name="XML_ExternalEntityParserCreate"><pre>
-XML_Parser
+<pre class="fcndec" id="XML_ExternalEntityParserCreate">
+XML_Parser XMLCALL
 XML_ExternalEntityParserCreate(XML_Parser p,
                                const XML_Char *context,
-                               const XML_Char *encoding)
-</pre></a></div>
+                               const XML_Char *encoding);
+</pre>
 <div class="fcndef">
-Construct a new XML_Parser object for parsing an external general
-entity. Context is the context argument passed in a call to a
-ExternalEntityRefHandler. Other state information such as handlers, user data,
-namespace processing is inherited from the parser passed as the 1st
-argument. So you shouldn't need to call any of the behavior changing
-functions on this parser (unless you want it to act differently than the
-parent parser.)
+Construct a new <code>XML_Parser</code> object for parsing an external
+general entity. Context is the context argument passed in a call to a
+ExternalEntityRefHandler. Other state information such as handlers,
+user data, namespace processing is inherited from the parser passed as
+the 1st argument. So you shouldn't need to call any of the behavior
+changing functions on this parser (unless you want it to act
+differently than the parent parser).
 </div>
 
-<div class="fcndec"><a name="XML_ParserFree"><pre>
-void
-XML_ParserFree(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_ParserFree">
+void XMLCALL
+XML_ParserFree(XML_Parser p);
+</pre>
 <div class="fcndef">
 Free memory used by the parser. Your application is responsible for
-freeing any memory associated with <a href="#userdata">UserData</a>.
+freeing any memory associated with <a href="#userdata">user data</a>.
 </div>
 
-<h3><a name="parsing">Parsing</a></h3>
+<pre class="fcndec" id="XML_ParserReset">
+XML_Bool XMLCALL
+XML_ParserReset(XML_Parser p,
+                const XML_Char *encoding);
+</pre>
+<div class="fcndef">
+Clean up the memory structures maintained by the parser so that it may
+be used again.  After this has been called, <code>parser</code> is
+ready to start parsing a new document.  This function may not be used
+on a parser created using <code><a href=
+"#XML_ExternalEntityParserCreate" >XML_ExternalEntityParserCreate</a
+></code>; it will return <code>XML_FALSE</code> in that case.  Returns
+<code>XML_TRUE</code> on success.  Your application is responsible for
+dealing with any memory associated with <a href="#userdata">user data</a>.
+</div>
 
+<h3><a name="parsing">Parsing</a></h3>
 
-<div class="fcndec"><a name="XML_Parse"><pre>
-int
+<p>To state the obvious: the three parsing functions <code><a href=
+"#XML_Parse" >XML_Parse</a></code>, <code><a href= "#XML_ParseBuffer">
+XML_ParseBuffer</a></code> and <code><a href= "#XML_GetBuffer">
+XML_GetBuffer</a></code> must not be
+called from within a handler unless they operate on a separate parser
+instance, that is, one that did not call the handler. For example, it
+is OK to call the parsing functions from within an
+<code>XML_ExternalEntityRefHandler</code>, if they apply to the parser
+created by <code><a href= "#XML_ExternalEntityParserCreate"
+>XML_ExternalEntityParserCreate</a></code>.</p>
+
+<pre class="fcndec" id="XML_Parse">
+enum XML_Status XMLCALL
 XML_Parse(XML_Parser p,
           const char *s,
           int len,
-          int isFinal)
-</pre></a></div>
+          int isFinal);
+</pre>
+<pre class="signature">
+enum XML_Status {
+  XML_STATUS_ERROR = 0,
+  XML_STATUS_OK = 1
+};
+</pre>
 <div class="fcndef">
 Parse some more of the document. The string <code>s</code> is a buffer
 containing part (or perhaps all) of the document. The number of bytes of s
@@ -640,35 +839,37 @@ memory that <code>s</code> points at, then a memory fault is likely. The
 <code>isFinal</code> parameter informs the parser that this is the last
 piece of the document. Frequently, the last piece is empty (i.e.
 <code>len</code> is zero.)
-If a parse error occurred, it returns 0. Otherwise it returns a non-zero
-value.
+If a parse error occurred, it returns <code>XML_STATUS_ERROR</code>.
+Otherwise it returns <code>XML_STATUS_OK</code> value.
 </div>
 
-<div class="fcndec"><a name="XML_ParseBuffer"><pre>
-int
+<pre class="fcndec" id="XML_ParseBuffer">
+enum XML_Status XMLCALL
 XML_ParseBuffer(XML_Parser p,
                 int len,
-                int isFinal)
-</pre></a></div>
+                int isFinal);
+</pre>
 <div class="fcndef">
-This is just like XML_Parse, except in this case expat provides the buffer.
-By obtaining the buffer from expat with the <code>XML_GetBuffer</code>
-function, the application can avoid double copying of the input.
+This is just like <code><a href= "#XML_Parse" >XML_Parse</a></code>,
+except in this case Expat provides the buffer.  By obtaining the
+buffer from Expat with the <code><a href= "#XML_GetBuffer"
+>XML_GetBuffer</a></code> function, the application can avoid double
+copying of the input.
 </div>
 
-<div class="fcndec"><a name="XML_GetBuffer"><pre>
-void *
+<pre class="fcndec" id="XML_GetBuffer">
+void * XMLCALL
 XML_GetBuffer(XML_Parser p,
-              int len)
-</pre></a></div>
+              int len);
+</pre>
 <div class="fcndef">
 Obtain a buffer of size <code>len</code> to read a piece of the document
-into. A NULL value is returned if expat can't allocate enough memory for
+into. A NULL value is returned if Expat can't allocate enough memory for
 this buffer. This has to be called prior to every call to
-<code>XML_ParseBuffer</code>. A typical use would look like this:
+<code><a href= "#XML_ParseBuffer" >XML_ParseBuffer</a></code>. A
+typical use would look like this:
 
-<div id="eg">
-<pre>
+<pre class="eg">
 for (;;) {
   int bytes_read;
   void *buff = XML_GetBuffer(p, BUFF_SIZE);
@@ -677,7 +878,7 @@ for (;;) {
   }
 
   bytes_read = read(docfd, buff, BUFF_SIZE);
-  if (bytes_read < 0) {
+  if (bytes_read &lt; 0) {
     /* handle error */
   }
 
@@ -687,40 +888,41 @@ for (;;) {
 
   if (bytes_read == 0)
     break;
-}  
+}
 </pre>
 </div>
-</div>
 
 <h3><a name="setting">Handler Setting</a></h3>
+
 <p>Although handlers are typically set prior to parsing and left alone, an
 application may choose to set or change the handler for a parsing event
 while the parse is in progress. For instance, your application may choose
 to ignore all text not descended from a <code>para</code> element. One
 way it could do this is to set the character handler when a para start tag
-is seen, and unset it for the corresponding end tag.
+is seen, and unset it for the corresponding end tag.</p>
 
 <p>A handler may be <em>unset</em> by providing a NULL pointer to the
 appropriate handler setter. None of the handler setting functions have
-a return value.
+a return value.</p>
 
 <p>Your handlers will be receiving strings in arrays of type
-<code>XML_Char</code>. This type is defined in expat.h as <code>char *</code>
-and contains bytes encoding UTF-8.
-Note that you'll receive them in this form independent of the original
-encoding of the document.</p>
+<code>XML_Char</code>. This type is defined in expat.h as <code>char
+*</code> and contains bytes encoding UTF-8.  Note that you'll receive
+them in this form independent of the original encoding of the
+document.</p>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetStartElementHandler"><pre>
+<pre class="setter" id="XML_SetStartElementHandler">
+void XMLCALL
 XML_SetStartElementHandler(XML_Parser p,
                            XML_StartElementHandler start);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_StartElementHandler)(void *userData,
-                           const XML_Char *name,
-                           const XML_Char **atts);
-</pre></div>
+(XMLCALL *XML_StartElementHandler)(void *userData,
+                                   const XML_Char *name,
+                                   const XML_Char **atts);
+</pre>
 <p>Set handler for start (and empty) tags. Attributes are passed to the start
 handler as a pointer to a vector of char pointers. Each attribute seen in
 a start (or empty) tag occupies 2 consecutive places in this vector: the
@@ -731,41 +933,44 @@ by a null pointer.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetEndElementHandler"><pre>
+<pre class="setter" id="XML_SetEndElementHandler">
+void XMLCALL
 XML_SetEndElementHandler(XML_Parser p,
                          XML_EndElementHandler);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_EndElementHandler)(void *userData,
-                         const XML_Char *name);
-</pre></div>
+(XMLCALL *XML_EndElementHandler)(void *userData,
+                                 const XML_Char *name);
+</pre>
 <p>Set handler for end (and empty) tags. As noted above, an empty tag
 generates a call to both start and end handlers.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetElementHandler"><pre>
+<pre class="setter" id="XML_SetElementHandler">
+void XMLCALL
 XML_SetElementHandler(XML_Parser p,
                       XML_StartElementHandler start,
                       XML_EndElementHandler end);
-</pre></a></div>
+</pre>
 <p>Set handlers for start and end tags with one call.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetCharacterDataHandler"><pre>
+<pre class="setter" id="XML_SetCharacterDataHandler">
+void XMLCALL
 XML_SetCharacterDataHandler(XML_Parser p,
                             XML_CharacterDataHandler charhndl)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_CharacterDataHandler)(void *userData,
-                            const XML_Char *s,
-                            int len);
-</pre></div>
+(XMLCALL *XML_CharacterDataHandler)(void *userData,
+                                    const XML_Char *s,
+                                    int len);
+</pre>
 <p>Set a text handler. The string your handler receives
-is <em>NOT zero terminated</em>. You have to use the length argument
+is <em>NOT nul-terminated</em>. You have to use the length argument
 to deal with the end of the string. A single block of contiguous text
 free of markup may still result in a sequence of calls to this handler.
 In other words, if you're searching for a pattern in the text, it may
@@ -773,173 +978,262 @@ be split across calls to this handler.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetProcessingInstructionHandler"><pre>
+<pre class="setter" id="XML_SetProcessingInstructionHandler">
+void XMLCALL
 XML_SetProcessingInstructionHandler(XML_Parser p,
                                     XML_ProcessingInstructionHandler proc)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_ProcessingInstructionHandler)(void *userData,
-                                    const XML_Char *target,
-                                    const XML_Char *data);
+(XMLCALL *XML_ProcessingInstructionHandler)(void *userData,
+                                            const XML_Char *target,
+                                            const XML_Char *data);
 
-</pre></div>
+</pre>
 <p>Set a handler for processing instructions. The target is the first word
 in the processing instruction. The data is the rest of the characters in
 it after skipping all whitespace after the initial word.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetCommentHandler"><pre>
+<pre class="setter" id="XML_SetCommentHandler">
+void XMLCALL
 XML_SetCommentHandler(XML_Parser p,
                       XML_CommentHandler cmnt)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_CommentHandler)(void *userData,
-                      const XML_Char *data);
-</pre></div>
+(XMLCALL *XML_CommentHandler)(void *userData,
+                              const XML_Char *data);
+</pre>
 <p>Set a handler for comments. The data is all text inside the comment
 delimiters.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetStartCdataSectionHandler"><pre>
+<pre class="setter" id="XML_SetStartCdataSectionHandler">
+void XMLCALL
 XML_SetStartCdataSectionHandler(XML_Parser p,
                                 XML_StartCdataSectionHandler start);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_StartCdataSectionHandler)(void *userData);
-</pre></div>
+(XMLCALL *XML_StartCdataSectionHandler)(void *userData);
+</pre>
 <p>Set a handler that gets called at the beginning of a CDATA section.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetEndCdataSectionHandler"><pre>
+<pre class="setter" id="XML_SetEndCdataSectionHandler">
+void XMLCALL
 XML_SetEndCdataSectionHandler(XML_Parser p,
                               XML_EndCdataSectionHandler end);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_EndCdataSectionHandler)(void *userData);
-</pre></div>
+(XMLCALL *XML_EndCdataSectionHandler)(void *userData);
+</pre>
 <p>Set a handler that gets called at the end of a CDATA section.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetCdataSectionHandler"><pre>
+<pre class="setter" id="XML_SetCdataSectionHandler">
+void XMLCALL
 XML_SetCdataSectionHandler(XML_Parser p,
                            XML_StartCdataSectionHandler start,
                            XML_EndCdataSectionHandler end)
-</pre></a></div>
+</pre>
 <p>Sets both CDATA section handlers with one call.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetDefaultHandler"><pre>
+<pre class="setter" id="XML_SetDefaultHandler">
+void XMLCALL
 XML_SetDefaultHandler(XML_Parser p,
                       XML_DefaultHandler hndl)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_DefaultHandler)(void *userData,
-                      const XML_Char *s,
-                      int len);
-</pre></div>
+(XMLCALL *XML_DefaultHandler)(void *userData,
+                              const XML_Char *s,
+                              int len);
+</pre>
+
 <p>Sets a handler for any characters in the document which wouldn't
-otherwise be handled. This includes both data for which no handlers can be
-set (like some kinds of DTD declarations) and data which could be reported
-but which currently has no handler set. Note that a contiguous piece of
-data that is destined to be reported to the default handler may actually
-be reported over several calls to the handler. Setting the handler with
+otherwise be handled. This includes both data for which no handlers
+can be set (like some kinds of DTD declarations) and data which could
+be reported but which currently has no handler set.  The characters
+are passed exactly as they were present in the XML document except
+that they will be encoded in UTF-8 or UTF-16. Line boundaries are not
+normalized. Note that a byte order mark character is not passed to the
+default handler. There are no guarantees about how characters are
+divided between calls to the default handler: for example, a comment
+might be split between multiple calls.  Setting the handler with
 this call has the side effect of turning off expansion of references
 to internally defined general entities. Instead these references are
 passed to the default handler.</p>
+
+<p>See also <code><a
+href="#XML_DefaultCurrent">XML_DefaultCurrent</a></code>.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetDefaultHandlerExpand"><pre>
+<pre class="setter" id="XML_SetDefaultHandlerExpand">
+void XMLCALL
 XML_SetDefaultHandlerExpand(XML_Parser p,
                             XML_DefaultHandler hndl)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_DefaultHandler)(void *userData,
-                      const XML_Char *s,
-                      int len);
-</pre></div>
-<p>This sets a default handler, but doesn't affect expansion of internal
-entity references.</p>
+(XMLCALL *XML_DefaultHandler)(void *userData,
+                              const XML_Char *s,
+                              int len);
+</pre>
+<p>This sets a default handler, but doesn't inhibit the expansion of
+internal entity references.  The entity reference will not be passed
+to the default handler.</p>
+
+<p>See also <code><a
+href="#XML_DefaultCurrent">XML_DefaultCurrent</a></code>.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetExternalEntityRefHandler"><pre>
+<pre class="setter" id="XML_SetExternalEntityRefHandler">
+void XMLCALL
 XML_SetExternalEntityRefHandler(XML_Parser p,
                                 XML_ExternalEntityRefHandler hndl)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef int
-(*XML_ExternalEntityRefHandler)(XML_Parser p,
-                                const XML_Char *context,
-                                const XML_Char *base,
-                                const XML_Char *systemId,
-                                const XML_Char *publicId);
-</pre></div>
+(XMLCALL *XML_ExternalEntityRefHandler)(XML_Parser p,
+                                        const XML_Char *context,
+                                        const XML_Char *base,
+                                        const XML_Char *systemId,
+                                        const XML_Char *publicId);
+</pre>
 <p>Set an external entity reference handler. This handler is also
 called for processing an external DTD subset if parameter entity parsing
 is in effect. (See <a href="#XML_SetParamEntityParsing">
 <code>XML_SetParamEntityParsing</code></a>.)</p>
 
-
-<p>The base parameter is the base to use for relative system identifiers.
-It is set by <a href="#XML_SetBase">XML_SetBase</a> and may be null. The
-public id parameter is the public id given in the entity declaration and
-may be null. The system id is the system identifier specified in the entity
-declaration and is never null.</p>
-
-<p>There are a couple of ways in which this handler differs from others.
-First, this handler returns an integer. A non-zero value should be returned
-for successful handling of the external entity reference. Returning a zero
-indicates failure, and causes the calling parser to return
-an XML_ERROR_EXTERNAL_ENTITY_HANDLING error.</p>
-
-<p>Second, instead of having userData as its first argument, it receives the
-parser that encountered the entity reference. This, along with the context
-parameter, may be used as arguments to a call to
-<a href="#XML_ExternalEntityParserCreate">XML_ExternalEntityParserCreate</a>.
-Using the returned parser, the body of the external entity can be recursively
-parsed.</p>
+<p>The <code>context</code> parameter specifies the parsing context in
+the format expected by the <code>context</code> argument to <code><a
+href="#XML_ExternalEntityParserCreate"
+>XML_ExternalEntityParserCreate</a></code>.  <code>code</code> is
+valid only until the handler returns, so if the referenced entity is
+to be parsed later, it must be copied.  <code>context</code> is NULL
+only when the entity is a parameter entity, which is how one can
+differentiate between general and parameter entities.</p>
+
+<p>The <code>base</code> parameter is the base to use for relative
+system identifiers.  It is set by <code><a
+href="#XML_SetBase">XML_SetBase</a></code> and may be NULL. The
+<code>publicId</code> parameter is the public id given in the entity
+declaration and may be NULL.  <code>systemId</code> is the system
+identifier specified in the entity declaration and is never NULL.</p>
+
+<p>There are a couple of ways in which this handler differs from
+others.  First, this handler returns a status indicator (an
+integer). <code>XML_STATUS_OK</code> should be returned for successful
+handling of the external entity reference.  Returning
+<code>XML_STATUS_ERROR</code> indicates failure, and causes the
+calling parser to return an
+<code>XML_ERROR_EXTERNAL_ENTITY_HANDLING</code> error.</p>
+
+<p>Second, instead of having the user data as its first argument, it
+receives the parser that encountered the entity reference. This, along
+with the context parameter, may be used as arguments to a call to
+<code><a href= "#XML_ExternalEntityParserCreate"
+>XML_ExternalEntityParserCreate</a></code>.  Using the returned
+parser, the body of the external entity can be recursively parsed.</p>
 
 <p>Since this handler may be called recursively, it should not be saving
 information into global or static variables.</p>
 </div>
 
+<pre class="fcndec" id="XML_SetExternalEntityRefHandlerArg">
+void XMLCALL
+XML_SetExternalEntityRefHandlerArg(XML_Parser p,
+                                   void *arg)
+</pre>
+<div class="fcndef">
+<p>Set the argument passed to the ExternalEntityRefHandler.  If
+<code>arg</code> is not NULL, it is the new value passed to the
+handler set using <code><a href="#XML_SetExternalEntityRefHandler"
+>XML_SetExternalEntityRefHandler</a></code>; if <code>arg</code> is
+NULL, the argument passed to the handler function will be the parser
+object itself.</p>
+
+<p><strong>Note:</strong>
+The type of <code>arg</code> and the type of the first argument to the
+ExternalEntityRefHandler do not match.  This function takes a
+<code>void *</code> to be passed to the handler, while the handler
+accepts an <code>XML_Parser</code>.  This is a historical accident,
+but will not be corrected before Expat 2.0 (at the earliest) to avoid
+causing compiler warnings for code that's known to work with this
+API.  It is the responsibility of the application code to know the
+actual type of the argument passed to the handler and to manage it
+properly.</p>
+</div>
+
+<div class="handler">
+<pre class="setter" id="XML_SetSkippedEntityHandler">
+void XMLCALL
+XML_SetSkippedEntityHandler(XML_Parser p,
+                            XML_SkippedEntityHandler handler)
+</pre>
+<pre class="signature">
+typedef void
+(XMLCALL *XML_SkippedEntityHandler)(void *userData,
+                                    const XML_Char *entityName,
+                                    int is_parameter_entity);
+</pre>
+<p>Set a skipped entity handler. This is called in two situations:</p>
+<ol>
+   <li>An entity reference is encountered for which no declaration
+       has been read <em>and</em> this is not an error.</li>
+   <li>An internal entity reference is read, but not expanded, because
+       <a href="#XML_SetDefaultHandler"><code>XML_SetDefaultHandler</code></a>
+          has been called.</li>
+</ol>
+<p>The <code>is_parameter_entity</code> argument will be non-zero for
+a parameter entity and zero for a general entity.</p> <p>Note: skipped
+parameter entities in declarations and skipped general entities in
+attribute values cannot be reported, because the event would be out of
+sync with the reporting of the declarations or attribute values</p>
+</div>
+
 <div class="handler">
-<div class="setter"><a name="XML_SetUnknownEncodingHandler"><pre>
+<pre class="setter" id="XML_SetUnknownEncodingHandler">
+void XMLCALL
 XML_SetUnknownEncodingHandler(XML_Parser p,
                               XML_UnknownEncodingHandler enchandler,
                              void *encodingHandlerData)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef int
-(*XML_UnknownEncodingHandler)(void *encodingHandlerData,
-                              const XML_Char *name,
-                              XML_Encoding *info);
-</pre></div>
-<p>Set a handler to deal with encodings other than the
-<a href="#builtin_encodings">built in set</a>. If the handler knows how
-to deal with an encoding with the given name, it should fill in the info
-data structure and return 1. Otherwise it should return 0.</p>
+(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
+                                      const XML_Char *name,
+                                      XML_Encoding *info);
 
-<pre>
-    typedef struct {
-      int map[256];
-      void *data;
-      int (*convert)(void *data, const char *s);
-      void (*release)(void *data);
-    } XML_Encoding;
+typedef struct {
+  int map[256];
+  void *data;
+  int (XMLCALL *convert)(void *data, const char *s);
+  void (XMLCALL *release)(void *data);
+} XML_Encoding;
 </pre>
+<p>Set a handler to deal with encodings other than the <a
+href="#builtin_encodings">built in set</a>. This should be done before
+<code><a href= "#XML_Parse" >XML_Parse</a></code> or <code><a href=
+"#XML_ParseBuffer" >XML_ParseBuffer</a></code> have been called on the
+given parser.</p> <p>If the handler knows how to deal with an encoding
+with the given name, it should fill in the <code>info</code> data
+structure and return <code>XML_STATUS_ERROR</code>. Otherwise it
+should return <code>XML_STATUS_OK</code>. The handler will be called
+at most once per parsed (external) entity. The optional application
+data pointer <code>encodingHandlerData</code> will be passed back to
+the handler.</p>
 
 <p>The map array contains information for every possible possible leading
 byte in a byte sequence. If the corresponding value is &gt;= 0, then it's
@@ -950,24 +1244,26 @@ bytes in the sequence and the actual conversion is accomplished by a
 call to the function pointed at by convert. This function may return -1
 if the sequence itself is invalid. The convert pointer may be null if
 there are only single byte codes. The data parameter passed to the convert
-function is the data pointer from XML_Encoding. The string s is <em>NOT</em>
-null terminated and points at the sequence of bytes to be converted.</p>
+function is the data pointer from <code>XML_Encoding</code>. The
+string s is <em>NOT</em> nul-terminated and points at the sequence of
+bytes to be converted.</p>
 
-<p>The function pointed at by release is called by the parser when it is
-finished with the encoding. It may be null.</p>
+<p>The function pointed at by <code>release</code> is called by the
+parser when it is finished with the encoding. It may be NULL.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetStartCdataSectionHandler"><pre>
-XML_SetStartCdataSectionHandler(XML_Parser p,
-                                XML_StartCdataSectionHandler start);
-</pre></a></div>
-<div class="signature"><pre>
+<pre class="setter" id="XML_SetStartNamespaceDeclHandler">
+void XMLCALL
+XML_SetStartNamespaceDeclHandler(XML_Parser p,
+                                XML_StartNamespaceDeclHandler start);
+</pre>
+<pre class="signature">
 typedef void
-(*XML_StartNamespaceDeclHandler)(void *userData,
-                                 const XML_Char *prefix,
-                                 const XML_Char *uri);
-</pre></div>
+(XMLCALL *XML_StartNamespaceDeclHandler)(void *userData,
+                                         const XML_Char *prefix,
+                                         const XML_Char *uri);
+</pre>
 <p>Set a handler to be called when a namespace is declared. Namespace
 declarations occur inside start tags. But the namespace declaration start
 handler is called before the start tag handler for each namespace declared
@@ -975,64 +1271,69 @@ in that start tag.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetEndNamespaceDeclHandler"><pre>
+<pre class="setter" id="XML_SetEndNamespaceDeclHandler">
+void XMLCALL
 XML_SetEndNamespaceDeclHandler(XML_Parser p,
                               XML_EndNamespaceDeclHandler end);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_EndNamespaceDeclHandler)(void *userData,
-                               const XML_Char *prefix);
-</pre></div>
+(XMLCALL *XML_EndNamespaceDeclHandler)(void *userData,
+                                       const XML_Char *prefix);
+</pre>
 <p>Set a handler to be called when leaving the scope of a namespace
-declaration. This will be called, for each namespace declaration, after
-the handler for the end tag of the element in which the namespace was declared.
-</p>
+declaration. This will be called, for each namespace declaration,
+after the handler for the end tag of the element in which the
+namespace was declared.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetNamespaceDeclHandler"><pre>
+<pre class="setter" id="XML_SetNamespaceDeclHandler">
+void XMLCALL
 XML_SetNamespaceDeclHandler(XML_Parser p,
                             XML_StartNamespaceDeclHandler start,
                             XML_EndNamespaceDeclHandler end)
-</pre></a></div>
-<p>Sets both namespace declaration handlers with a single call</p>
+</pre>
+<p>Sets both namespace declaration handlers with a single call.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetXmlDeclHandler"><pre>
+<pre class="setter" id="XML_SetXmlDeclHandler">
+void XMLCALL
 XML_SetXmlDeclHandler(XML_Parser p,
                      XML_XmlDeclHandler xmldecl);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_XmlDeclHandler) (void            *userData,
-                       const XML_Char  *version,
-                       const XML_Char  *encoding,
-                       int             standalone);
-</pre></div>
+(XMLCALL *XML_XmlDeclHandler)(void            *userData,
+                              const XML_Char  *version,
+                              const XML_Char  *encoding,
+                              int             standalone);
+</pre>
 <p>Sets a handler that is called for XML declarations and also for
-text declarations discovered in external entities. The way to distinguish
-is that the <code>version</code> parameter will be NULL for text
-declarations. The <code>encoding</code> parameter may be NULL for
-an XML declaration. The <code>standalone</code> argument will contain
--1, 0, or 1  indicating respectively that there was no standalone parameter in
-the declaration, that it was given as no, or that it was given as yes.</p>
+text declarations discovered in external entities. The way to
+distinguish is that the <code>version</code> parameter will be NULL
+for text declarations. The <code>encoding</code> parameter may be NULL
+for an XML declaration. The <code>standalone</code> argument will
+contain -1, 0, or 1 indicating respectively that there was no
+standalone parameter in the declaration, that it was given as no, or
+that it was given as yes.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetStartDoctypeDeclHandler"><pre>
+<pre class="setter" id="XML_SetStartDoctypeDeclHandler">
+void XMLCALL
 XML_SetStartDoctypeDeclHandler(XML_Parser p,
                               XML_StartDoctypeDeclHandler start);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_StartDoctypeDeclHandler)(void           *userData,
-                               const XML_Char *doctypeName,
-                               const XML_Char *sysid,
-                               const XML_Char *pubid,
-                               int            has_internal_subset);
-</pre></div>
+(XMLCALL *XML_StartDoctypeDeclHandler)(void           *userData,
+                                       const XML_Char *doctypeName,
+                                       const XML_Char *sysid,
+                                       const XML_Char *pubid,
+                                       int            has_internal_subset);
+</pre>
 <p>Set a handler that is called at the start of a DOCTYPE declaration,
 before any external or internal subset is parsed. Both <code>sysid</code>
 and <code>pubid</code> may be NULL. The <code>has_internal_subset</code>
@@ -1040,39 +1341,42 @@ will be non-zero if the DOCTYPE declaration has an internal subset.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetEndDoctypeDeclHandler"><pre>
+<pre class="setter" id="XML_SetEndDoctypeDeclHandler">
+void XMLCALL
 XML_SetEndDoctypeDeclHandler(XML_Parser p,
                             XML_EndDoctypeDeclHandler end);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_EndDoctypeDeclHandler)(void *userData);
-</pre></div>
+(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
+</pre>
 <p>Set a handler that is called at the end of a DOCTYPE declaration,
 after parsing any external subset.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetDoctypeDeclHandler"><pre>
+<pre class="setter" id="XML_SetDoctypeDeclHandler">
+void XMLCALL
 XML_SetDoctypeDeclHandler(XML_Parser p,
                          XML_StartDoctypeDeclHandler start,
                          XML_EndDoctypeDeclHandler end);
-</pre></a></div>
+</pre>
 <p>Set both doctype handlers with one call.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetElementDeclHandler"><pre>
+<pre class="setter" id="XML_SetElementDeclHandler">
+void XMLCALL
 XML_SetElementDeclHandler(XML_Parser p,
                          XML_ElementDeclHandler eldecl);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_ElementDeclHandler)(void *userData,
-                          const XML_Char *name,
-                          XML_Content *model);
-</pre></div>
-<div class="signature"><pre>
+(XMLCALL *XML_ElementDeclHandler)(void *userData,
+                                  const XML_Char *name,
+                                  XML_Content *model);
+</pre>
+<pre class="signature">
 enum XML_Content_Type {
   XML_CTYPE_EMPTY = 1,
   XML_CTYPE_ANY,
@@ -1098,380 +1402,611 @@ struct XML_cp {
   unsigned int                 numchildren;
   XML_Content *                        children;
 };
-</pre></div>
-<p>Sets a handler for element declarations in a DTD. The handler gets called
-with the name of the element in the declaration and a pointer to a structure
-that contains the element model. It is the application's responsibility to
-free this data structure.</p>
+</pre>
+<p>Sets a handler for element declarations in a DTD. The handler gets
+called with the name of the element in the declaration and a pointer
+to a structure that contains the element model. It is the
+application's responsibility to free this data structure using
+<code><a href="#XML_FreeContentModel"
+>XML_FreeContentModel</a></code>.</p>
 
 <p>The <code>model</code> argument is the root of a tree of
 <code>XML_Content</code> nodes. If <code>type</code> equals
 <code>XML_CTYPE_EMPTY</code> or <code>XML_CTYPE_ANY</code>, then
-<code>quant</code> will be <code>XML_CQUANT_NONE</code>, and the other fields
-will be zero or NULL.
-If <code>type</code> is <code>XML_CTYPE_MIXED</code>, then <code>quant</code>
-will be <code>XML_CQUANT_NONE</code> or <code>XML_CQUANT_REP</code> and
-<code>numchildren</code> will contain the number of elements that are allowed
-to be mixed in and <code>children</code> points to an array of
-<code>XML_Content</code> structures that will all have type XML_CTYPE_NAME
-with no quantification.
-Only the root node can be type <code>XML_CTYPE_EMPTY</code>, <code>XML_CTYPE_ANY</code>, or <code>XML_CTYPE_MIXED</code>.</p>
-
-<p>For type <code>XML_CTYPE_NAME</code>, the <code>name</code> field points
-to the name and the <code>numchildren</code> and <code>children</code> fields
-will be zero and NULL. The <code>quant</code> field will indicate any
-quantifiers placed on the name.</p>
+<code>quant</code> will be <code>XML_CQUANT_NONE</code>, and the other
+fields will be zero or NULL.  If <code>type</code> is
+<code>XML_CTYPE_MIXED</code>, then <code>quant</code> will be
+<code>XML_CQUANT_NONE</code> or <code>XML_CQUANT_REP</code> and
+<code>numchildren</code> will contain the number of elements that are
+allowed to be mixed in and <code>children</code> points to an array of
+<code>XML_Content</code> structures that will all have type
+XML_CTYPE_NAME with no quantification.  Only the root node can be type
+<code>XML_CTYPE_EMPTY</code>, <code>XML_CTYPE_ANY</code>, or
+<code>XML_CTYPE_MIXED</code>.</p>
+
+<p>For type <code>XML_CTYPE_NAME</code>, the <code>name</code> field
+points to the name and the <code>numchildren</code> and
+<code>children</code> fields will be zero and NULL. The
+<code>quant</code> field will indicate any quantifiers placed on the
+name.</p>
 
 <p>Types <code>XML_CTYPE_CHOICE</code> and <code>XML_CTYPE_SEQ</code>
-indicate a choice or sequence respectively. The <code>numchildren</code>
-field indicates how many nodes in the choice or sequence and
-<code>children</code> points to the nodes.</p>
+indicate a choice or sequence respectively. The
+<code>numchildren</code> field indicates how many nodes in the choice
+or sequence and <code>children</code> points to the nodes.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetAttlistDeclHandler"><pre>
+<pre class="setter" id="XML_SetAttlistDeclHandler">
+void XMLCALL
 XML_SetAttlistDeclHandler(XML_Parser p,
                           XML_AttlistDeclHandler attdecl);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_AttlistDeclHandler) (void           *userData,
-                           const XML_Char *elname,
-                           const XML_Char *attname,
-                           const XML_Char *att_type,
-                           const XML_Char *dflt,
-                           int            isrequired);
-</pre></div>
-<p>Set a handler for attlist declarations in the DTD. This handler is called
-for <em>each</em> attribute. So a single attlist declaration with multiple
-attributes declared will generate multiple calls to this handler. The
-<code>elname</code> parameter returns the name of the element for which the
-attribute is being declared. The attribute name is in the <code>attname</code>
-parameter. The attribute type is in the <code>att_type</code> parameter.
-It is the string representing the type in the declaration with whitespace
-removed.</p>
-
-<p>The <code>dflt</code> parameter holds the default value. It will
-be NULL in the case of "#IMPLIED" or "#REQUIRED" attributes. You can
+(XMLCALL *XML_AttlistDeclHandler)(void           *userData,
+                                  const XML_Char *elname,
+                                  const XML_Char *attname,
+                                  const XML_Char *att_type,
+                                  const XML_Char *dflt,
+                                  int            isrequired);
+</pre>
+<p>Set a handler for attlist declarations in the DTD. This handler is
+called for <em>each</em> attribute. So a single attlist declaration
+with multiple attributes declared will generate multiple calls to this
+handler. The <code>elname</code> parameter returns the name of the
+element for which the attribute is being declared. The attribute name
+is in the <code>attname</code> parameter. The attribute type is in the
+<code>att_type</code> parameter.  It is the string representing the
+type in the declaration with whitespace removed.</p>
+
+<p>The <code>dflt</code> parameter holds the default value. It will be
+NULL in the case of "#IMPLIED" or "#REQUIRED" attributes. You can
 distinguish these two cases by checking the <code>isrequired</code>
 parameter, which will be true in the case of "#REQUIRED" attributes.
 Attributes which are "#FIXED" will have also have a true
-<code>isrequired</code>, but they will have the non-NULL fixed value in the
-<code>dflt</code> parameter.
-</p>
+<code>isrequired</code>, but they will have the non-NULL fixed value
+in the <code>dflt</code> parameter.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetEntityDeclHandler"><pre>
+<pre class="setter" id="XML_SetEntityDeclHandler">
+void XMLCALL
 XML_SetEntityDeclHandler(XML_Parser p,
                         XML_EntityDeclHandler handler);
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_EntityDeclHandler) (void           *userData,
-                          const XML_Char *entityName,
-                          int            is_parameter_entity,
-                          const XML_Char *value,
-                          int            value_length,
-                          const XML_Char *base,
-                          const XML_Char *systemId,
-                          const XML_Char *publicId,
-                          const XML_Char *notationName);
-</pre></div>
+(XMLCALL *XML_EntityDeclHandler)(void           *userData,
+                                 const XML_Char *entityName,
+                                 int            is_parameter_entity,
+                                 const XML_Char *value,
+                                 int            value_length, 
+                                 const XML_Char *base,
+                                 const XML_Char *systemId,
+                                 const XML_Char *publicId,
+                                 const XML_Char *notationName);
+</pre>
 <p>Sets a handler that will be called for all entity declarations.
-The <code>is_parameter_entity</code> argument will be non-zero in the case
-of parameter entities and zero otherwise.
-</p>
+The <code>is_parameter_entity</code> argument will be non-zero in the
+case of parameter entities and zero otherwise.</p>
+
 <p>For internal entities (<code>&lt;!ENTITY foo "bar"&gt;</code>),
 <code>value</code> will be non-NULL and <code>systemId</code>,
 <code>publicId</code>, and <code>notationName</code> will all be NULL.
-The value string is <em>not</em> NULL terminated; the length is provided in
-the <code>value_length</code> parameter. Do not use <code>value_length</code>
-to test for internal entities, since it is legal to have zero-length
-values. Instead check for whether or not <code>value</code> is NULL.</p>
-<p>The <code>notationName</code> argument will have a non-NULL value only
-for unparsed entity declarations.</p>
+The value string is <em>not</em> NULL terminated; the length is
+provided in the <code>value_length</code> parameter. Do not use
+<code>value_length</code> to test for internal entities, since it is
+legal to have zero-length values. Instead check for whether or not
+<code>value</code> is NULL.</p> <p>The <code>notationName</code>
+argument will have a non-NULL value only for unparsed entity
+declarations.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetUnparsedEntityDeclHandler"><pre>
+<pre class="setter" id="XML_SetUnparsedEntityDeclHandler">
+void XMLCALL
 XML_SetUnparsedEntityDeclHandler(XML_Parser p,
                                  XML_UnparsedEntityDeclHandler h)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_UnparsedEntityDeclHandler)(void *userData,
-                                 const XML_Char *entityName,
-                                 const XML_Char *base,
-                                 const XML_Char *systemId,
-                                 const XML_Char *publicId,
-                                 const XML_Char *notationName);
-</pre></div>
+(XMLCALL *XML_UnparsedEntityDeclHandler)(void *userData,
+                                         const XML_Char *entityName, 
+                                         const XML_Char *base,
+                                         const XML_Char *systemId,
+                                         const XML_Char *publicId,
+                                         const XML_Char *notationName);
+</pre>
 <p>Set a handler that receives declarations of unparsed entities. These
 are entity declarations that have a notation (NDATA) field:</p>
 
 <div id="eg"><pre>
 &lt;!ENTITY logo SYSTEM "images/logo.gif" NDATA gif&gt;
 </pre></div>
-
-<p>This handler is obsolete and is provided for backwards compatibility.
-Use instead <a href="#XML_SetEntityDeclHandler">XML_SetEntityDeclHandler</a>.
-</p>
+<p>This handler is obsolete and is provided for backwards
+compatibility.  Use instead <a href= "#XML_SetEntityDeclHandler"
+>XML_SetEntityDeclHandler</a>.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetNotationDeclHandler"><pre>
+<pre class="setter" id="XML_SetNotationDeclHandler">
+void XMLCALL
 XML_SetNotationDeclHandler(XML_Parser p,
                            XML_NotationDeclHandler h)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef void
-(*XML_NotationDeclHandler)(void *userData,
-                           const XML_Char *notationName,
-                           const XML_Char *base,
-                           const XML_Char *systemId,
-                           const XML_Char *publicId);
-</pre></div>
+(XMLCALL *XML_NotationDeclHandler)(void *userData, 
+                                   const XML_Char *notationName,
+                                   const XML_Char *base,
+                                   const XML_Char *systemId,
+                                   const XML_Char *publicId);
+</pre>
 <p>Set a handler that receives notation declarations.</p>
 </div>
 
 <div class="handler">
-<div class="setter"><a name="XML_SetNotStandaloneHandler"><pre>
+<pre class="setter" id="XML_SetNotStandaloneHandler">
+void XMLCALL
 XML_SetNotStandaloneHandler(XML_Parser p,
                             XML_NotStandaloneHandler h)
-</pre></a></div>
-<div class="signature"><pre>
+</pre>
+<pre class="signature">
 typedef int 
-(*XML_NotStandaloneHandler)(void *userData);
-</pre></div>
+(XMLCALL *XML_NotStandaloneHandler)(void *userData);
+</pre>
 <p>Set a handler that is called if the document is not "standalone".
-This happens when there is an external subset or a reference to a parameter
-entity, but does not have standalone set to "yes" in an XML declaration.
-If this handler returns 0, then the parser will throw an
-XML_ERROR_NOT_STANDALONE error.</p>
+This happens when there is an external subset or a reference to a
+parameter entity, but does not have standalone set to "yes" in an XML
+declaration.  If this handler returns <code>XML_STATUS_ERROR</code>,
+then the parser will throw an <code>XML_ERROR_NOT_STANDALONE</code>
+error.</p>
 </div>
 
 <h3><a name="position">Parse position and error reporting functions</a></h3>
-<p>These are the functions you'll want to call when the parse functions
-return 0 (i.e. a parse error has ocurred), although the position reporting
-functions are useful outside of errors. The position reported is the byte
-position (in the original document or entity encoding) of the first of the
-sequence of characters that generated the current event (or the error that
-caused the parse functions to return 0.)</p>
-<p>The position reporting functions are accurate only outside of the DTD.
-In other words, they usually return bogus information when called from within
-a DTD declaration handler.</p>
-
-<div class="fcndec"><a name="XML_GetErrorCode"><pre>
-enum XML_Error
-XML_GetErrorCode(XML_Parser p)
-</pre></a></div>
+
+<p>These are the functions you'll want to call when the parse
+functions return <code>XML_STATUS_ERROR</code> (a parse error has
+occurred), although the position reporting functions are useful outside
+of errors. The position reported is the byte position (in the original
+document or entity encoding) of the first of the sequence of
+characters that generated the current event (or the error that caused
+the parse functions to return <code>XML_STATUS_ERROR</code>.)  The
+exceptions are callbacks trigged by declarations in the document
+prologue, in which case they exact position reported is somewhere in the
+relevant markup, but not necessarily as meaningful as for other
+events.</p>
+
+<p>The position reporting functions are accurate only outside of the
+DTD.  In other words, they usually return bogus information when
+called from within a DTD declaration handler.</p>
+
+<pre class="fcndec" id="XML_GetErrorCode">
+enum XML_Error XMLCALL
+XML_GetErrorCode(XML_Parser p);
+</pre>
 <div class="fcndef">
 Return what type of error has occurred.
 </div>
 
-<div class="fcndec"><a name="XML_ErrorString"><pre>
-const XML_LChar *
-XML_ErrorString(int code)
-</pre></a></div>
+<pre class="fcndec" id="XML_ErrorString">
+const XML_LChar * XMLCALL
+XML_ErrorString(enum XML_Error code);
+</pre>
 <div class="fcndef">
 Return a string describing the error corresponding to code.
 The code should be one of the enums that can be returned from
-XML_GetErrorCode.
+<code><a href= "#XML_GetErrorCode" >XML_GetErrorCode</a></code>.
 </div>
 
-<div class="fcndec"><a name="XML_GetCurrentByteIndex"><pre>
-long
-XML_GetCurrentByteIndex(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_GetCurrentByteIndex">
+long XMLCALL
+XML_GetCurrentByteIndex(XML_Parser p);
+</pre>
 <div class="fcndef">
-Return the byte offset of the position.
+Return the byte offset of the position.  This always corresponds to
+the values returned by <code><a href= "#XML_GetCurrentLineNumber"
+>XML_GetCurrentLineNumber</a></code> and <code><a href=
+"#XML_GetCurrentColumnNumber" >XML_GetCurrentColumnNumber</a></code>.
 </div>
 
-<div class="fcndec"><a name="XML_GetCurrentLineNumber"><pre>
-int
-XML_GetCurrentLineNumber(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_GetCurrentLineNumber">
+int XMLCALL
+XML_GetCurrentLineNumber(XML_Parser p);
+</pre>
 <div class="fcndef">
-Return the line number of the position.
+Return the line number of the position.  The first line is reported as
+<code>1</code>.
 </div>
 
-<div class="fcndec"><a name="XML_GetCurrentColumnNumber"><pre>
-int
-XML_GetCurrentColumnNumber(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_GetCurrentColumnNumber">
+int XMLCALL
+XML_GetCurrentColumnNumber(XML_Parser p);
+</pre>
 <div class="fcndef">
 Return the offset, from the beginning of the current line, of
 the position.
 </div>
 
-<div class="fcndec"><a name="XML_GetCurrentByteCount"><pre>
-int
+<pre class="fcndec" id="XML_GetCurrentByteCount">
+int XMLCALL
 XML_GetCurrentByteCount(XML_Parser p);
-</pre></a></div>
+</pre>
 <div class="fcndef">
-Return the number of bytes in the current event. Returns 0 if the event is
-inside a reference to an internal entity.
+Return the number of bytes in the current event. Returns
+<code>0</code> if the event is inside a reference to an internal
+entity and for the end-tag event for empty element tags (the later can
+be used to distinguish empty-element tags from empty elements using
+separate start and end tags).
 </div>
 
-<div class="fcndec"><a name="XML_GetInputContext"><pre>
-const char *
+<pre class="fcndec" id="XML_GetInputContext">
+const char * XMLCALL
 XML_GetInputContext(XML_Parser p,
                     int *offset,
                     int *size);
-</pre></a></div>
+</pre>
 <div class="fcndef">
+
 <p>Returns the parser's input buffer, sets the integer pointed at by
 <code>offset</code> to the offset within this buffer of the current
-parse position, and set the integer pointed at by <code>size</code>
-to the size of the returned buffer.</p>
+parse position, and set the integer pointed at by <code>size</code> to
+the size of the returned buffer.</p>
+
 <p>This should only be called from within a handler during an active
 parse and the returned buffer should only be referred to from within
-the handler that made the call. This input buffer contains the untranslated
-bytes of the input.</p>
-<p>Only a limited amount of context is kept, so if the event triggering
-a call spans over a very large amount of input, the actual parse position
-may be before the beginning of the buffer.</p>
+the handler that made the call. This input buffer contains the
+untranslated bytes of the input.</p>
+
+<p>Only a limited amount of context is kept, so if the event
+triggering a call spans over a very large amount of input, the actual
+parse position may be before the beginning of the buffer.</p>
 </div>
 
 <h3><a name="miscellaneous">Miscellaneous functions</a></h3>
-<p>The functions in this section either obtain state information from the
-parser or can be used to dynamicly set parser options.
 
-<div class="fcndec"><a name="XML_SetUserData"><pre>
-void
+<p>The functions in this section either obtain state information from
+the parser or can be used to dynamicly set parser options.</p>
+
+<pre class="fcndec" id="XML_SetUserData">
+void XMLCALL
 XML_SetUserData(XML_Parser p,
-                void *userData)
-</pre></a></div>
+                void *userData);
+</pre>
 <div class="fcndef">
-This sets the user data pointer that gets passed to handlers.
-It overwrites any previous value for this pointer. Note that the
+This sets the user data pointer that gets passed to handlers.  It
+overwrites any previous value for this pointer. Note that the
 application is responsible for freeing the memory associated with
-<code>userData</code> when it is finished with the parser. So if
-you call this when there's already a pointer there, and you haven't
-freed the memory associated with it, then you've probably just leaked
+<code>userData</code> when it is finished with the parser. So if you
+call this when there's already a pointer there, and you haven't freed
+the memory associated with it, then you've probably just leaked
 memory.
 </div>
 
-<div class="fcndec"><a name="XML_GetUserData"><pre>
-void *
-XML_GetUserData(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_GetUserData">
+void * XMLCALL
+XML_GetUserData(XML_Parser p);
+</pre>
 <div class="fcndef">
 This returns the user data pointer that gets passed to handlers.
 It is actually implemented as a macro.
 </div>
 
-<div class="fcndec"><a name="XML_UseParserAsHandlerArg"><pre>
-void
-XML_UseParserAsHandlerArg(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_UseParserAsHandlerArg">
+void XMLCALL
+XML_UseParserAsHandlerArg(XML_Parser p);
+</pre>
 <div class="fcndef">
-After this is called, handlers receive the parser in the
-userData argument. The userData information can still be obtained using
-the XML_GetUserData function.
+After this is called, handlers receive the parser in their
+<code>userData</code> arguments.  The user data can still be obtained
+using the <code><a href= "#XML_GetUserData"
+>XML_GetUserData</a></code> function.
 </div>
 
-<div class="fcndec"><a name="XML_SetBase"><pre>
-int
+<pre class="fcndec" id="XML_SetBase">
+enum XML_Status XMLCALL
 XML_SetBase(XML_Parser p,
-            const XML_Char *base)
-</pre></a></div>
+            const XML_Char *base);
+</pre>
 <div class="fcndef">
-Set the base to be used for resolving relative URIs in system identifiers.
-The return value is 0 if there's no memory to store base, otherwise it's
-non-zero.
+Set the base to be used for resolving relative URIs in system
+identifiers.  The return value is <code>XML_STATUS_ERROR</code> if
+there's no memory to store base, otherwise it's
+<code>XML_STATUS_OK</code>.
 </div>
 
-<div class="fcndec"><a name="XML_GetBase"><pre>
-const XML_Char *
-XML_GetBase(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_GetBase">
+const XML_Char * XMLCALL
+XML_GetBase(XML_Parser p);
+</pre>
 <div class="fcndef">
 Return the base for resolving relative URIs.
 </div>
 
-<div class="fcndec"><a name="XML_GetSpecifiedAttributeCount"><pre>
-int
-XML_GetSpecifiedAttributeCount(XML_Parser p)
-</pre></a></div>
+<pre class="fcndec" id="XML_GetSpecifiedAttributeCount">
+int XMLCALL
+XML_GetSpecifiedAttributeCount(XML_Parser p);
+</pre>
 <div class="fcndef">
 When attributes are reported to the start handler in the atts vector,
 attributes that were explicitly set in the element occur before any
 attributes that receive their value from default information in an
-ATTLIST declaration. This function returns the number of attributes that
-were explicitly set times two, thus giving the offset in the <code>atts</code>
-array passed to the start tag handler of the first attribute set
-due to defaults. It supplies information for the last call to a start
-handler. If called inside a start handler, then that means the current call.
+ATTLIST declaration. This function returns the number of attributes
+that were explicitly set times two, thus giving the offset in the
+<code>atts</code> array passed to the start tag handler of the first
+attribute set due to defaults. It supplies information for the last
+call to a start handler. If called inside a start handler, then that
+means the current call.
 </div>
 
-<div class="fcndec"><a name="XML_GetIdAttributeIndex"><pre>
-int
+<pre class="fcndec" id="XML_GetIdAttributeIndex">
+int XMLCALL
 XML_GetIdAttributeIndex(XML_Parser p);
-</pre></a></div>
+</pre>
 <div class="fcndef">
-Returns the index of the ID attribute passed in the atts array
-in the last call to XML_StartElementHandler, or -1 if there is no ID
-attribute. If called inside a start handler, then that means the current call.
+Returns the index of the ID attribute passed in the atts array in the
+last call to <code><a href= "#XML_StartElementHandler"
+>XML_StartElementHandler</a></code>, or -1 if there is no ID
+attribute. If called inside a start handler, then that means the
+current call.
 </div>
 
-<div class="fcndec"><a name="XML_SetEncoding"><pre>
-int
+<pre class="fcndec" id="XML_SetEncoding">
+enum XML_Status XMLCALL
 XML_SetEncoding(XML_Parser p,
-                const XML_Char *encoding)
-</pre></a></div>
+                const XML_Char *encoding);
+</pre>
 <div class="fcndef">
 Set the encoding to be used by the parser. It is equivalent to
 passing a non-null encoding argument to the parser creation functions.
-It must not be called after XML_Parser or XML_ParseBuffer have been
-called on the given parser.
+It must not be called after <code><a href= "#XML_Parse"
+>XML_Parse</a></code> or <code><a href= "#XML_ParseBuffer"
+>XML_ParseBuffer</a></code> have been called on the given parser.
+Returns <code>XML_STATUS_OK</code> on success or
+<code>XML_STATUS_ERROR</code> on error.
 </div>
 
-<div class="fcndec"><a name="XML_SetParamEntityParsing"><pre>
-int
+<pre class="fcndec" id="XML_SetParamEntityParsing">
+int XMLCALL
 XML_SetParamEntityParsing(XML_Parser p,
-                          enum XML_ParamEntityParsing code)
-</pre></a></div>
+                          enum XML_ParamEntityParsing code);
+</pre>
 <div class="fcndef">
 This enables parsing of parameter entities, including the external
 parameter entity that is the external DTD subset, according to
 <code>code</code>.
 The choices for <code>code</code> are:
 <ul>
-<li>XML_PARAM_ENTITY_PARSING_NEVER
-<li>XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE
-<li>XML_PARAM_ENTITY_PARSING_ALWAYS
+<li><code>XML_PARAM_ENTITY_PARSING_NEVER</code></li>
+<li><code>XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE</code></li>
+<li><code>XML_PARAM_ENTITY_PARSING_ALWAYS</code></li>
 </ul>
 </div>
 
-<div class="fcndec"><a name="XML_SetReturnNSTriplet"><pre>
-void
+<pre class="fcndec" id="XML_UseForeignDTD">
+enum XML_Error XMLCALL
+XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
+</pre>
+<div class="fcndef">
+<p>This function allows an application to provide an external subset
+for the document type declaration for documents which do not specify
+an external subset of their own.  For documents which specify an
+external subset in their DOCTYPE declaration, the application-provided
+subset will be ignored.  If the document does not contain a DOCTYPE
+declaration at all and <code>useDTD</code> is true, the
+application-provided subset will be parsed, but the
+<code>startDoctypeDeclHandler</code> and
+<code>endDoctypeDeclHandler</code> functions, if set, will not be
+called.  The setting of parameter entity parsing, controlled using
+<code><a href= "#XML_SetParamEntityParsing"
+>XML_SetParamEntityParsing</a></code>, will be honored.</p>
+
+<p>The application-provided external subset is read by calling the
+external entity reference handler set via <code><a href=
+"#XML_SetExternalEntityRefHandler"
+>XML_SetExternalEntityRefHandler</a></code> with both
+<code>publicId</code> and <code>systemId</code> set to NULL.</p>
+
+<p>If this function is called after parsing has begun, it returns
+<code>XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING</code> and ignores
+<code>useDTD</code>.  If called when Expat has been compiled without
+DTD support, it returns
+<code>XML_ERROR_FEATURE_REQUIRES_XML_DTD</code>.  Otherwise, it
+returns <code>XML_ERROR_NONE</code>.</p>
+</div>
+
+<pre class="fcndec" id="XML_SetReturnNSTriplet">
+void XMLCALL
 XML_SetReturnNSTriplet(XML_Parser parser,
                        int        do_nst);
-</pre></a></div>
+</pre>
 <div class="fcndef">
 <p>
 This function only has an effect when using a parser created with
-<a href="#XML_ParserCreateNS">XML_ParserCreateNS</a>, i.e. when namespace
-processing is in effect. The <code>do_nst</code> sets whether or not prefixes
-are returned with names qualified with a namespace prefix. If this function
-is called with <code>do_nst</code> non-zero, then afterwards namespace
-qualified names (that is qualified with a prefix as opposed to belonging
-to a default namespace) are returned as a triplet with the three parts
-separated by the namespace separator specified when the parser was created.
-The order of returned parts is URI, local name, and prefix.</p>
-<p>If <code>do_nst</code> is zero, then namespaces are reported in the
-default manner, URI then local_name separated by the namespace separator.</p>
+<code><a href= "#XML_ParserCreateNS" >XML_ParserCreateNS</a></code>,
+i.e. when namespace processing is in effect. The <code>do_nst</code>
+sets whether or not prefixes are returned with names qualified with a
+namespace prefix. If this function is called with <code>do_nst</code>
+non-zero, then afterwards namespace qualified names (that is qualified
+with a prefix as opposed to belonging to a default namespace) are
+returned as a triplet with the three parts separated by the namespace
+separator specified when the parser was created.  The order of
+returned parts is URI, local name, and prefix.</p> <p>If
+<code>do_nst</code> is zero, then namespaces are reported in the
+default manner, URI then local_name separated by the namespace
+separator.</p>
+</div>
+
+<pre class="fcndec" id="XML_DefaultCurrent">
+void XMLCALL
+XML_DefaultCurrent(XML_Parser parser);
+</pre>
+<div class="fcndef">
+This can be called within a handler for a start element, end element,
+processing instruction or character data.  It causes the corresponding
+markup to be passed to the default handler set by <code><a
+href="#XML_SetDefaultHandler" >XML_SetDefaultHandler</a></code> or
+<code><a href="#XML_SetDefaultHandlerExpand"
+>XML_SetDefaultHandlerExpand</a></code>.  It does nothing if there is
+not a default handler.
 </div>
 
-<div class="fcndec"><a name="XML_ExpatVersion"><pre>
-XML_LChar *
+<pre class="fcndec" id="XML_ExpatVersion">
+XML_LChar * XMLCALL
 XML_ExpatVersion();
-</pre></a>
+</pre>
 <div class="fcndef">
-Return the library version string.
+Return the library version as a string (e.g. <code>"expat_1.95.1"</code>).
 </div>
 
+<pre class="fcndec" id="XML_ExpatVersionInfo">
+struct XML_Expat_Version XMLCALL
+XML_ExpatVersionInfo();
+</pre>
+<pre class="signature">
+typedef struct {
+  int major;
+  int minor;
+  int micro;
+} XML_Expat_Version;
+</pre>
+<div class="fcndef">
+Return the library version information as a structure.
+Some macros are also defined that support compile-time tests of the
+library version:
+<ul>
+<li><code>XML_MAJOR_VERSION</code></li>
+<li><code>XML_MINOR_VERSION</code></li>
+<li><code>XML_MICRO_VERSION</code></li>
+</ul>
+Testing these constants is currently the best way to determine if
+particular parts of the Expat API are available.
+</div>
+
+<pre class="fcndec" id="XML_GetFeatureList">
+const XML_Feature * XMLCALL
+XML_GetFeatureList();
+</pre>
+<pre class="signature">
+enum XML_FeatureEnum {
+  XML_FEATURE_END = 0,
+  XML_FEATURE_UNICODE,
+  XML_FEATURE_UNICODE_WCHAR_T,
+  XML_FEATURE_DTD,
+  XML_FEATURE_CONTEXT_BYTES,
+  XML_FEATURE_MIN_SIZE,
+  XML_FEATURE_SIZEOF_XML_CHAR,
+  XML_FEATURE_SIZEOF_XML_LCHAR
+};
+
+typedef struct {
+  enum XML_FeatureEnum  feature;
+  XML_LChar            *name;
+  long int              value;
+} XML_Feature;
+</pre>
+<div class="fcndef">
+<p>Returns a list of "feature" records, providing details on how
+Expat was configured at compile time.  Most applications should not
+need to worry about this, but this information is otherwise not
+available from Expat.  This function allows code that does need to
+check these features to do so at runtime.</p>
+
+<p>The return value is an array of <code>XML_Feature</code>,
+terminated by a record with a <code>feature</code> of
+<code>XML_FEATURE_END</code> and <code>name</code> of NULL,
+identifying the feature-test macros Expat was compiled with.  Since an
+application that requires this kind of information needs to determine
+the type of character the <code>name</code> points to, records for the
+<code>XML_FEATURE_SIZEOF_XML_CHAR</code> and
+<code>XML_FEATURE_SIZEOF_XML_LCHAR</code> will be located at the
+beginning of the list, followed by <code>XML_FEATURE_UNICODE</code>
+and <code>XML_FEATURE_UNICODE_WCHAR_T</code>, if they are present at
+all.</p>
+
+<p>Some features have an associated value.  If there isn't an
+associated value, the <code>value</code> field is set to 0.  At this
+time, the following features have been defined to have values:</p>
+
+<dl>
+  <dt><code>XML_FEATURE_SIZEOF_XML_CHAR</code></dt>
+  <dd>The number of bytes occupied by one <code>XML_Char</code>
+  character.</dd>
+  <dt><code>XML_FEATURE_SIZEOF_XML_LCHAR</code></dt>
+  <dd>The number of bytes occupied by one <code>XML_LChar</code>
+  character.</dd>
+  <dt><code>XML_FEATURE_CONTEXT_BYTES</code></dt>
+  <dd>The maximum number of characters of context which can be
+  reported by <code><a href= "#XML_GetInputContext"
+  >XML_GetInputContext</a></code>.</dd>
+</dl>
+</div>
+
+<pre class="fcndec" id="XML_FreeContentModel">
+void XMLCALL
+XML_FreeContentModel(XML_Parser parser, XML_Content *model);
+</pre>
+<div class="fcndef">
+Function to deallocate the <code>model</code> argument passed to the
+<code>XML_ElementDeclHandler</code> callback set using <code><a
+href="#XML_SetElementDeclHandler" >XML_ElementDeclHandler</a></code>.
+This function should not be used for any other purpose.
+</div>
+
+<p>The following functions allow external code to share the memory
+allocator an <code>XML_Parser</code> has been configured to use.  This
+is especially useful for third-party libraries that interact with a
+parser object created by application code, or heavily layered
+applications.  This can be essential when using dynamically loaded
+libraries which use different C standard libraries (this can happen on
+Windows, at least).</p>
+
+<pre class="fcndec" id="XML_MemMalloc">
+void * XMLCALL
+XML_MemMalloc(XML_Parser parser, size_t size);
+</pre>
+<div class="fcndef">
+Allocate <code>size</code> bytes of memory using the allocator the
+<code>parser</code> object has been configured to use.  Returns a
+pointer to the memory or NULL on failure.  Memory allocated in this
+way must be freed using <code><a href="#XML_MemFree"
+>XML_MemFree</a></code>.
+</div>
+
+<pre class="fcndec" id="XML_MemRealloc">
+void * XMLCALL
+XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
+</pre>
+<div class="fcndef">
+Allocate <code>size</code> bytes of memory using the allocator the
+<code>parser</code> object has been configured to use.
+<code>ptr</code> must point to a block of memory allocated by <code><a
+href="#XML_MemMalloc" >XML_MemMalloc</a></code> or
+<code>XML_MemRealloc</code>, or be NULL.  This function tries to
+expand the block pointed to by <code>ptr</code> if possible.  Returns
+a pointer to the memory or NULL on failure.  On success, the original
+block has either been expanded or freed.  On failure, the original
+block has not been freed; the caller is responsible for freeing the
+original block.  Memory allocated in this way must be freed using
+<code><a href="#XML_MemFree"
+>XML_MemFree</a></code>.
+</div>
+
+<pre class="fcndec" id="XML_MemFree">
+void XMLCALL
+XML_MemFree(XML_Parser parser, void *ptr);
+</pre>
+<div class="fcndef">
+Free a block of memory pointed to by <code>ptr</code>.  The block must
+have been allocated by <code><a href="#XML_MemMalloc"
+>XML_MemMalloc</a></code> or <code>XML_MemRealloc</code>, or be NULL.
+</div>
+
+<hr />
+<p><a href="http://validator.w3.org/check/referer"><img
+        src="valid-xhtml10.png" alt="Valid XHTML 1.0!"
+        height="31" width="88" class="noborder" /></a></p>
+</div>
 </body>
 </html>
index 343e974..8f19fbd 100644 (file)
@@ -1,26 +1,62 @@
 body {
-background-color: white
+  background-color: white;
+  border: 0px;
+  margin: 0px;
+  padding: 0px;
+}
+
+.corner {
+  width: 200px;
+  height: 80px;
+  text-align: center;
+}
+
+.banner {
+  background-color: rgb(110,139,61);
+  color: rgb(255,236,176);
+  padding-left: 2em;
+}
+
+.banner h1 {
+  font-size: 200%;
+}
+
+.content {
+  padding: 0em 2em 1em 2em;
+}
+
+.releaseno {
+  background-color: rgb(110,139,61);
+  color: rgb(255,236,176);
+  padding-bottom: 0.3em;
+  padding-top: 0.5em;
+  text-align: center;
+  font-weight: bold;
+}
+
+.noborder {
+  border-width: 0px;
 }
 
 .eg {
   padding-left: 1em;
   padding-top: .5em;
+  padding-bottom: .5em;
   border: solid thin;
   margin: 1em 0;
   background-color: tan;
-  margin-left: 5%;
+  margin-left: 2em;
   margin-right: 10%;
 }
 
 .handler {
   width: 100%;
   border-top-width: thin;  
-  margin-left: 5%;
   margin-bottom: 1em;
 }
 
 .handler p {
-  margin-left: 3%;
+  margin-left: 2em;
 }
 
 .setter {
@@ -38,10 +74,17 @@ background-color: white
 }
 
 .fcndef {
-  margin-left: 5%;
+  margin-left: 2em;
   margin-bottom: 2em;
 }
 
 dd {
-margin-bottom: 2em;
-}
\ No newline at end of file
+  margin-bottom: 2em;
+}
+
+.cpp-symbols dt {
+  font-family: monospace;
+}
+.cpp-symbols dd {
+  margin-bottom: 1em;
+}
index 9a20c34..78d7d93 100644 (file)
@@ -1,12 +1,13 @@
 /* This is simple demonstration of how to use expat. This program
-reads an XML document from standard input and writes a line with the
-name of each element to standard output indenting child elements by
-one tab stop more than their parent element. */
+   reads an XML document from standard input and writes a line with
+   the name of each element to standard output indenting child
+   elements by one tab stop more than their parent element.
+*/
 
 #include <stdio.h>
 #include "expat.h"
 
-static void
+static void XMLCALL
 startElement(void *userData, const char *name, const char **atts)
 {
   int i;
@@ -17,7 +18,7 @@ startElement(void *userData, const char *name, const char **atts)
   *depthPtr += 1;
 }
 
-static void
+static void XMLCALL
 endElement(void *userData, const char *name)
 {
   int *depthPtr = userData;
@@ -36,11 +37,11 @@ main(int argc, char *argv[])
   do {
     size_t len = fread(buf, 1, sizeof(buf), stdin);
     done = len < sizeof(buf);
-    if (!XML_Parse(parser, buf, len, done)) {
+    if (XML_Parse(parser, buf, len, done) == XML_STATUS_ERROR) {
       fprintf(stderr,
-             "%s at line %d\n",
-             XML_ErrorString(XML_GetErrorCode(parser)),
-             XML_GetCurrentLineNumber(parser));
+              "%s at line %d\n",
+              XML_ErrorString(XML_GetErrorCode(parser)),
+              XML_GetCurrentLineNumber(parser));
       return 1;
     }
   } while (!done);
index 22ab278..43ee74b 100644 (file)
 #include <stdio.h>
 #include <expat.h>
 
-#define BUFFSIZE       8192
+#define BUFFSIZE        8192
 
 char Buff[BUFFSIZE];
 
 int Depth;
 
-void
-start(void *data, const char *el, const char **attr) {
+static void XMLCALL
+start(void *data, const char *el, const char **attr)
+{
   int i;
 
   for (i = 0; i < Depth; i++)
@@ -45,14 +46,17 @@ start(void *data, const char *el, const char **attr) {
 
   printf("\n");
   Depth++;
-}  /* End of start handler */
+}
 
-void
-end(void *data, const char *el) {
+static void XMLCALL
+end(void *data, const char *el)
+{
   Depth--;
-}  /* End of end handler */
+}
 
-main(int argc, char **argv) {
+int
+main(int argc, char *argv[])
+{
   XML_Parser p = XML_ParserCreate(NULL);
   if (! p) {
     fprintf(stderr, "Couldn't allocate memory for parser\n");
@@ -72,15 +76,15 @@ main(int argc, char **argv) {
     }
     done = feof(stdin);
 
-    if (! XML_Parse(p, Buff, len, done)) {
+    if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) {
       fprintf(stderr, "Parse error at line %d:\n%s\n",
-             XML_GetCurrentLineNumber(p),
-             XML_ErrorString(XML_GetErrorCode(p)));
+              XML_GetCurrentLineNumber(p),
+              XML_ErrorString(XML_GetErrorCode(p)));
       exit(-1);
     }
 
     if (done)
       break;
   }
-}  /* End of main */
-
+  return 0;
+}
index b2a4609..0f386ef 100644 (file)
 
 #include <stdlib.h>
 
-#ifndef XMLPARSEAPI
 #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
-#ifdef XML_STATIC
-#define XMLPARSEAPI(type) type __cdecl
-#else
-#define XMLPARSEAPI(type) __declspec(dllimport) type __cdecl
+#define XML_USE_MSC_EXTENSIONS 1
 #endif
+
+/* Expat tries very hard to make the API boundary very specifically
+   defined.  There are two macros defined to control this boundary;
+   each of these can be defined before including this header to
+   achieve some different behavior, but doing so it not recommended or
+   tested frequently.
+
+   XMLCALL    - The calling convention to use for all calls across the
+                "library boundary."  This will default to cdecl, and
+                try really hard to tell the compiler that's what we
+                want.
+
+   XMLIMPORT  - Whatever magic is needed to note that a function is
+                to be imported from a dynamically loaded library
+                (.dll, .so, or .sl, depending on your platform).
+
+   The XMLCALL macro was added in Expat 1.95.7.  The only one which is
+   expected to be directly useful in client code is XMLCALL.
+
+   Note that on at least some Unix versions, the Expat library must be
+   compiled with the cdecl calling convention as the default since
+   system headers may assume the cdecl convention.
+*/
+#ifndef XMLCALL
+#if defined(XML_USE_MSC_EXTENSIONS)
+#define XMLCALL __cdecl
+#elif 0
+#define XMLCALL __attribute__((cdecl))
 #else
-#define XMLPARSEAPI(type) type
+/* For any platform which uses this definition and supports more than
+   one calling convention, we need to extend this definition to
+   declare the convention used on that platform, if it's possible to
+   do so.
+
+   If this is the case for your platform, please file a bug report
+   with information on how to identify your platform via the C
+   pre-processor and how to specify the same calling convention as the
+   platform's malloc() implementation.
+*/
+#define XMLCALL
 #endif
-#endif  /* not defined XMLPARSEAPI */
+#endif  /* not defined XMLCALL */
+
+
+#if !defined(XML_STATIC) && !defined(XMLIMPORT)
+#ifndef XML_BUILDING_EXPAT
+/* using Expat from an application */
+
+#ifdef XML_USE_MSC_EXTENSIONS
+#define XMLIMPORT __declspec(dllimport)
+#endif
+
+#endif
+#endif  /* not defined XML_STATIC */
+
+/* If we didn't define it above, define it away: */
+#ifndef XMLIMPORT
+#define XMLIMPORT
+#endif
+
+
+#define XMLPARSEAPI(type) XMLIMPORT type XMLCALL
 
 #ifdef __cplusplus
 extern "C" {
@@ -57,6 +111,26 @@ typedef unsigned char XML_Bool;
 #define XML_TRUE   ((XML_Bool) 1)
 #define XML_FALSE  ((XML_Bool) 0)
 
+/* The XML_Status enum gives the possible return values for several
+   API functions.  The preprocessor #defines are included so this
+   stanza can be added to code that still needs to support older
+   versions of Expat 1.95.x:
+
+   #ifndef XML_STATUS_OK
+   #define XML_STATUS_OK    1
+   #define XML_STATUS_ERROR 0
+   #endif
+
+   Otherwise, the #define hackery is quite ugly and would have been
+   dropped.
+*/
+enum XML_Status {
+  XML_STATUS_ERROR = 0,
+#define XML_STATUS_ERROR XML_STATUS_ERROR
+  XML_STATUS_OK = 1
+#define XML_STATUS_OK XML_STATUS_OK
+};
+
 enum XML_Error {
   XML_ERROR_NONE,
   XML_ERROR_NO_MEMORY,
@@ -84,7 +158,8 @@ enum XML_Error {
   XML_ERROR_UNEXPECTED_STATE,
   XML_ERROR_ENTITY_DECLARED_IN_PE,
   XML_ERROR_FEATURE_REQUIRES_XML_DTD,
-  XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING
+  XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING,
+  XML_ERROR_UNBOUND_PREFIX
 };
 
 enum XML_Content_Type {
@@ -136,15 +211,13 @@ struct XML_cp {
    description of the model argument. It's the caller's responsibility
    to free model when finished with it.
 */
-typedef void (*XML_ElementDeclHandler) (void *userData,
-                                        const XML_Char *name,
-                                        XML_Content *model)
-       /*@*/;
+typedef void (XMLCALL *XML_ElementDeclHandler) (void *userData,
+                                                const XML_Char *name,
+                                                XML_Content *model);
 
 XMLPARSEAPI(void)
 XML_SetElementDeclHandler(XML_Parser parser,
-                          XML_ElementDeclHandler eldecl)
-       /*@modifies parser @*/;
+                          XML_ElementDeclHandler eldecl);
 
 /* The Attlist declaration handler is called for *each* attribute. So
    a single Attlist declaration with multiple attributes declared will
@@ -154,18 +227,17 @@ XML_SetElementDeclHandler(XML_Parser parser,
    value will be NULL in the case of "#REQUIRED". If "isrequired" is
    true and default is non-NULL, then this is a "#FIXED" default.
 */
-typedef void (*XML_AttlistDeclHandler) (void           *userData,
-                                        const XML_Char *elname,
-                                        const XML_Char *attname,
-                                        const XML_Char *att_type,
-                                        const XML_Char *dflt,
-                                        int             isrequired)
-       /*@*/;
+typedef void (XMLCALL *XML_AttlistDeclHandler) (
+                                    void            *userData,
+                                    const XML_Char  *elname,
+                                    const XML_Char  *attname,
+                                    const XML_Char  *att_type,
+                                    const XML_Char  *dflt,
+                                    int              isrequired);
 
 XMLPARSEAPI(void)
 XML_SetAttlistDeclHandler(XML_Parser parser,
-                          XML_AttlistDeclHandler attdecl)
-       /*@modifies parser @*/;
+                          XML_AttlistDeclHandler attdecl);
 
 /* The XML declaration handler is called for *both* XML declarations
    and text declarations. The way to distinguish is that the version
@@ -175,31 +247,27 @@ XML_SetAttlistDeclHandler(XML_Parser parser,
    was no standalone parameter in the declaration, that it was given
    as no, or that it was given as yes.
 */
-typedef void (*XML_XmlDeclHandler) (void                *userData,
-                                    const XML_Char      *version,
-                                    const XML_Char      *encoding,
-                                    int                  standalone)
-       /*@*/;
+typedef void (XMLCALL *XML_XmlDeclHandler) (void           *userData,
+                                            const XML_Char *version,
+                                            const XML_Char *encoding,
+                                            int             standalone);
 
 XMLPARSEAPI(void)
 XML_SetXmlDeclHandler(XML_Parser parser,
-                      XML_XmlDeclHandler xmldecl)
-       /*@modifies parser @*/;
+                      XML_XmlDeclHandler xmldecl);
 
 
 typedef struct {
-  void *(*malloc_fcn)(size_t size);
-  void *(*realloc_fcn)(void *ptr, size_t size);
-  void (*free_fcn)(void *ptr);
+  void *(XMLCALL *malloc_fcn)(size_t size);
+  void *(XMLCALL *realloc_fcn)(void *ptr, size_t size);
+  void (XMLCALL *free_fcn)(void *ptr);
 } XML_Memory_Handling_Suite;
 
 /* Constructs a new parser; encoding is the encoding specified by the
    external protocol or NULL if there is none specified.
 */
-/*@null@*/
 XMLPARSEAPI(XML_Parser)
-XML_ParserCreate(const XML_Char *encoding)
-       /*@*/;
+XML_ParserCreate(const XML_Char *encoding);
 
 /* Constructs a new parser and namespace processor.  Element type
    names and attribute names that belong to a namespace will be
@@ -212,10 +280,8 @@ XML_ParserCreate(const XML_Char *encoding)
    When a namespace is not declared, the name and prefix will be
    passed through without expansion.
 */
-/*@null@*/
 XMLPARSEAPI(XML_Parser)
-XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator)
-       /*@*/;
+XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
 
 
 /* Constructs a new parser using the memory management suite referred to
@@ -227,12 +293,10 @@ XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator)
    All further memory operations used for the created parser will come from
    the given suite.
 */
-/*@null@*/
 XMLPARSEAPI(XML_Parser)
 XML_ParserCreate_MM(const XML_Char *encoding,
-                    /*@null@*/ const XML_Memory_Handling_Suite *memsuite,
-                    /*@null@*/ const XML_Char *namespaceSeparator)
-       /*@*/;
+                    const XML_Memory_Handling_Suite *memsuite,
+                    const XML_Char *namespaceSeparator);
 
 /* Prepare a parser object to be re-used.  This is particularly
    valuable when memory allocation overhead is disproportionatly high,
@@ -244,42 +308,36 @@ XML_ParserCreate_MM(const XML_Char *encoding,
    Added in Expat 1.95.3.
 */
 XMLPARSEAPI(XML_Bool)
-XML_ParserReset(XML_Parser parser, const XML_Char *encoding)
-       /*@modifies parser @*/;
+XML_ParserReset(XML_Parser parser, const XML_Char *encoding);
 
 /* atts is array of name/value pairs, terminated by 0;
    names and values are 0 terminated.
 */
-typedef void (*XML_StartElementHandler)(void *userData,
-                                        const XML_Char *name,
-                                        const XML_Char **atts)
-       /*@*/;
+typedef void (XMLCALL *XML_StartElementHandler) (void *userData,
+                                                 const XML_Char *name,
+                                                 const XML_Char **atts);
 
-typedef void (*XML_EndElementHandler)(void *userData,
-                                      const XML_Char *name)
-       /*@*/;
+typedef void (XMLCALL *XML_EndElementHandler) (void *userData,
+                                               const XML_Char *name);
 
 
 /* s is not 0 terminated. */
-typedef void (*XML_CharacterDataHandler)(void *userData,
-                                         const XML_Char *s,
-                                         int len)
-       /*@*/;
+typedef void (XMLCALL *XML_CharacterDataHandler) (void *userData,
+                                                  const XML_Char *s,
+                                                  int len);
 
 /* target and data are 0 terminated */
-typedef void (*XML_ProcessingInstructionHandler)(void *userData,
-                                                 const XML_Char *target,
-                                                 const XML_Char *data)
-       /*@*/;
+typedef void (XMLCALL *XML_ProcessingInstructionHandler) (
+                                                void *userData,
+                                                const XML_Char *target,
+                                                const XML_Char *data);
 
 /* data is 0 terminated */
-typedef void (*XML_CommentHandler)(void *userData, const XML_Char *data)
-       /*@*/;
+typedef void (XMLCALL *XML_CommentHandler) (void *userData,
+                                            const XML_Char *data);
 
-typedef void (*XML_StartCdataSectionHandler)(void *userData)
-       /*@*/;
-typedef void (*XML_EndCdataSectionHandler)(void *userData)
-       /*@*/;
+typedef void (XMLCALL *XML_StartCdataSectionHandler) (void *userData);
+typedef void (XMLCALL *XML_EndCdataSectionHandler) (void *userData);
 
 /* This is called for any characters in the XML document for which
    there is no applicable handler.  This includes both characters that
@@ -294,27 +352,25 @@ typedef void (*XML_EndCdataSectionHandler)(void *userData)
    default handler: for example, a comment might be split between
    multiple calls.
 */
-typedef void (*XML_DefaultHandler)(void *userData,
-                                   const XML_Char *s,
-                                   int len)
-       /*@*/;
+typedef void (XMLCALL *XML_DefaultHandler) (void *userData,
+                                            const XML_Char *s,
+                                            int len);
 
 /* This is called for the start of the DOCTYPE declaration, before
    any DTD or internal subset is parsed.
 */
-typedef void (*XML_StartDoctypeDeclHandler)(void *userData,
+typedef void (XMLCALL *XML_StartDoctypeDeclHandler) (
+                                            void *userData,
                                             const XML_Char *doctypeName,
                                             const XML_Char *sysid,
                                             const XML_Char *pubid,
-                                            int has_internal_subset)
-       /*@*/;
+                                            int has_internal_subset);
 
 /* This is called for the start of the DOCTYPE declaration when the
    closing > is encountered, but after processing any external
    subset.
 */
-typedef void (*XML_EndDoctypeDeclHandler)(void *userData)
-       /*@*/;
+typedef void (XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
 
 /* This is called for entity declarations. The is_parameter_entity
    argument will be non-zero if the entity is a parameter entity, zero
@@ -334,21 +390,20 @@ typedef void (*XML_EndDoctypeDeclHandler)(void *userData)
    Note that is_parameter_entity can't be changed to XML_Bool, since
    that would break binary compatibility.
 */
-typedef void (*XML_EntityDeclHandler) (void *userData,
-                                       const XML_Char *entityName,
-                                       int is_parameter_entity,
-                                       const XML_Char *value,
-                                       int value_length,
-                                       const XML_Char *base,
-                                       const XML_Char *systemId,
-                                       const XML_Char *publicId,
-                                       const XML_Char *notationName)
-       /*@*/;
+typedef void (XMLCALL *XML_EntityDeclHandler) (
+                              void *userData,
+                              const XML_Char *entityName,
+                              int is_parameter_entity,
+                              const XML_Char *value,
+                              int value_length,
+                              const XML_Char *base,
+                              const XML_Char *systemId,
+                              const XML_Char *publicId,
+                              const XML_Char *notationName);
 
 XMLPARSEAPI(void)
 XML_SetEntityDeclHandler(XML_Parser parser,
-                         XML_EntityDeclHandler handler)
-       /*@modifies parser @*/;
+                         XML_EntityDeclHandler handler);
 
 /* OBSOLETE -- OBSOLETE -- OBSOLETE
    This handler has been superceded by the EntityDeclHandler above.
@@ -359,24 +414,24 @@ XML_SetEntityDeclHandler(XML_Parser parser,
    entityName, systemId and notationName arguments will never be
    NULL. The other arguments may be.
 */
-typedef void (*XML_UnparsedEntityDeclHandler)(void *userData,
-                                              const XML_Char *entityName,
-                                              const XML_Char *base,
-                                              const XML_Char *systemId,
-                                              const XML_Char *publicId,
-                                              const XML_Char *notationName)
-       /*@*/;
+typedef void (XMLCALL *XML_UnparsedEntityDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *entityName,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId,
+                                    const XML_Char *notationName);
 
 /* This is called for a declaration of notation.  The base argument is
    whatever was set by XML_SetBase. The notationName will never be
    NULL.  The other arguments can be.
 */
-typedef void (*XML_NotationDeclHandler)(void *userData,
-                                        const XML_Char *notationName,
-                                        const XML_Char *base,
-                                        const XML_Char *systemId,
-                                        const XML_Char *publicId)
-       /*@*/;
+typedef void (XMLCALL *XML_NotationDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *notationName,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId);
 
 /* When namespace processing is enabled, these are called once for
    each namespace declaration. The call to the start and end element
@@ -384,14 +439,14 @@ typedef void (*XML_NotationDeclHandler)(void *userData,
    declaration handlers. For an xmlns attribute, prefix will be
    NULL.  For an xmlns="" attribute, uri will be NULL.
 */
-typedef void (*XML_StartNamespaceDeclHandler)(void *userData,
-                                              const XML_Char *prefix,
-                                              const XML_Char *uri)
-       /*@*/;
+typedef void (XMLCALL *XML_StartNamespaceDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *prefix,
+                                    const XML_Char *uri);
 
-typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
-                                            const XML_Char *prefix)
-       /*@*/;
+typedef void (XMLCALL *XML_EndNamespaceDeclHandler) (
+                                    void *userData,
+                                    const XML_Char *prefix);
 
 /* This is called if the document is not standalone, that is, it has an
    external subset or a reference to a parameter entity, but does not
@@ -402,8 +457,7 @@ typedef void (*XML_EndNamespaceDeclHandler)(void *userData,
    conditions above this handler will only be called if the referenced
    entity was actually read.
 */
-typedef int (*XML_NotStandaloneHandler)(void *userData)
-       /*@*/;
+typedef int (XMLCALL *XML_NotStandaloneHandler) (void *userData);
 
 /* This is called for a reference to an external parsed general
    entity.  The referenced entity is not automatically parsed.  The
@@ -439,12 +493,12 @@ typedef int (*XML_NotStandaloneHandler)(void *userData)
    Note that unlike other handlers the first argument is the parser,
    not userData.
 */
-typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
-                                            const XML_Char *context,
-                                            const XML_Char *base,
-                                            const XML_Char *systemId,
-                                            const XML_Char *publicId)
-       /*@*/;
+typedef int (XMLCALL *XML_ExternalEntityRefHandler) (
+                                    XML_Parser parser,
+                                    const XML_Char *context,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId);
 
 /* This is called in two situations:
    1) An entity reference is encountered for which no declaration
@@ -456,10 +510,10 @@ typedef int (*XML_ExternalEntityRefHandler)(XML_Parser parser,
          the event would be out of sync with the reporting of the
          declarations or attribute values
 */
-typedef void (*XML_SkippedEntityHandler)(void *userData,
-                                         const XML_Char *entityName,
-                                         int is_parameter_entity)
-       /*@*/;
+typedef void (XMLCALL *XML_SkippedEntityHandler) (
+                                    void *userData,
+                                    const XML_Char *entityName,
+                                    int is_parameter_entity);
 
 /* This structure is filled in by the XML_UnknownEncodingHandler to
    provide information to the parser about encodings that are unknown
@@ -516,8 +570,8 @@ typedef void (*XML_SkippedEntityHandler)(void *userData,
 typedef struct {
   int map[256];
   void *data;
-  int (*convert)(void *data, const char *s);
-  void (*release)(void *data);
+  int (XMLCALL *convert)(void *data, const char *s);
+  void (XMLCALL *release)(void *data);
 } XML_Encoding;
 
 /* This is called for an encoding that is unknown to the parser.
@@ -535,54 +589,45 @@ typedef struct {
    If info does not describe a suitable encoding, then the parser will
    return an XML_UNKNOWN_ENCODING error.
 */
-typedef int (*XML_UnknownEncodingHandler)(void *encodingHandlerData,
-                                          const XML_Char *name,
-                                          XML_Encoding *info)
-       /*@*/;
+typedef int (XMLCALL *XML_UnknownEncodingHandler) (
+                                    void *encodingHandlerData,
+                                    const XML_Char *name,
+                                    XML_Encoding *info);
 
 XMLPARSEAPI(void)
 XML_SetElementHandler(XML_Parser parser,
                       XML_StartElementHandler start,
-                      XML_EndElementHandler end)
-       /*@modifies parser @*/;
+                      XML_EndElementHandler end);
 
 XMLPARSEAPI(void)
-XML_SetStartElementHandler(XML_Parser parser, XML_StartElementHandler)
-       /*@modifies parser @*/;
+XML_SetStartElementHandler(XML_Parser, XML_StartElementHandler);
 
 XMLPARSEAPI(void)
-XML_SetEndElementHandler(XML_Parser parser, XML_EndElementHandler)
-       /*@modifies parser @*/;
+XML_SetEndElementHandler(XML_Parser, XML_EndElementHandler);
 
 XMLPARSEAPI(void)
 XML_SetCharacterDataHandler(XML_Parser parser,
-                            XML_CharacterDataHandler handler)
-       /*@modifies parser @*/;
+                            XML_CharacterDataHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetProcessingInstructionHandler(XML_Parser parser,
-                                    XML_ProcessingInstructionHandler handler)
-       /*@modifies parser @*/;
+                                    XML_ProcessingInstructionHandler handler);
 XMLPARSEAPI(void)
 XML_SetCommentHandler(XML_Parser parser,
-                      XML_CommentHandler handler)
-       /*@modifies parser @*/;
+                      XML_CommentHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetCdataSectionHandler(XML_Parser parser,
                            XML_StartCdataSectionHandler start,
-                           XML_EndCdataSectionHandler end)
-       /*@modifies parser @*/;
+                           XML_EndCdataSectionHandler end);
 
 XMLPARSEAPI(void)
 XML_SetStartCdataSectionHandler(XML_Parser parser,
-                                XML_StartCdataSectionHandler start)
-       /*@modifies parser @*/;
+                                XML_StartCdataSectionHandler start);
 
 XMLPARSEAPI(void)
 XML_SetEndCdataSectionHandler(XML_Parser parser,
-                              XML_EndCdataSectionHandler end)
-       /*@modifies parser @*/;
+                              XML_EndCdataSectionHandler end);
 
 /* This sets the default handler and also inhibits expansion of
    internal entities. These entity references will be passed to the
@@ -590,8 +635,7 @@ XML_SetEndCdataSectionHandler(XML_Parser parser,
 */
 XMLPARSEAPI(void)
 XML_SetDefaultHandler(XML_Parser parser,
-                      XML_DefaultHandler handler)
-       /*@modifies parser @*/;
+                      XML_DefaultHandler handler);
 
 /* This sets the default handler but does not inhibit expansion of
    internal entities.  The entity reference will not be passed to the
@@ -599,87 +643,72 @@ XML_SetDefaultHandler(XML_Parser parser,
 */
 XMLPARSEAPI(void)
 XML_SetDefaultHandlerExpand(XML_Parser parser,
-                            XML_DefaultHandler handler)
-       /*@modifies parser @*/;
+                            XML_DefaultHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetDoctypeDeclHandler(XML_Parser parser,
                           XML_StartDoctypeDeclHandler start,
-                          XML_EndDoctypeDeclHandler end)
-       /*@modifies parser @*/;
+                          XML_EndDoctypeDeclHandler end);
 
 XMLPARSEAPI(void)
 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
-                               XML_StartDoctypeDeclHandler start)
-       /*@modifies parser @*/;
+                               XML_StartDoctypeDeclHandler start);
 
 XMLPARSEAPI(void)
 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
-                             XML_EndDoctypeDeclHandler end)
-       /*@modifies parser @*/;
+                             XML_EndDoctypeDeclHandler end);
 
 XMLPARSEAPI(void)
 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
-                                 XML_UnparsedEntityDeclHandler handler)
-       /*@modifies parser @*/;
+                                 XML_UnparsedEntityDeclHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetNotationDeclHandler(XML_Parser parser,
-                           XML_NotationDeclHandler handler)
-       /*@modifies parser @*/;
+                           XML_NotationDeclHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetNamespaceDeclHandler(XML_Parser parser,
                             XML_StartNamespaceDeclHandler start,
-                            XML_EndNamespaceDeclHandler end)
-       /*@modifies parser @*/;
+                            XML_EndNamespaceDeclHandler end);
 
 XMLPARSEAPI(void)
 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
-                                 XML_StartNamespaceDeclHandler start)
-       /*@modifies parser @*/;
+                                 XML_StartNamespaceDeclHandler start);
 
 XMLPARSEAPI(void)
 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
-                               XML_EndNamespaceDeclHandler end)
-       /*@modifies parser @*/;
+                               XML_EndNamespaceDeclHandler end);
 
 XMLPARSEAPI(void)
 XML_SetNotStandaloneHandler(XML_Parser parser,
-                            XML_NotStandaloneHandler handler)
-       /*@modifies parser @*/;
+                            XML_NotStandaloneHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetExternalEntityRefHandler(XML_Parser parser,
-                                XML_ExternalEntityRefHandler handler)
-       /*@modifies parser @*/;
+                                XML_ExternalEntityRefHandler handler);
 
 /* If a non-NULL value for arg is specified here, then it will be
    passed as the first argument to the external entity ref handler
    instead of the parser object.
 */
 XMLPARSEAPI(void)
-XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
-       /*@modifies parser @*/;
+XML_SetExternalEntityRefHandlerArg(XML_Parser, void *arg);
 
 XMLPARSEAPI(void)
 XML_SetSkippedEntityHandler(XML_Parser parser,
-                            XML_SkippedEntityHandler handler)
-       /*@modifies parser @*/;
+                            XML_SkippedEntityHandler handler);
 
 XMLPARSEAPI(void)
 XML_SetUnknownEncodingHandler(XML_Parser parser,
                               XML_UnknownEncodingHandler handler,
-                              void *encodingHandlerData)
-       /*@modifies parser @*/;
+                              void *encodingHandlerData);
 
 /* This can be called within a handler for a start element, end
    element, processing instruction or character data.  It causes the
    corresponding markup to be passed to the default handler.
 */
 XMLPARSEAPI(void)
-XML_DefaultCurrent(XML_Parser parser)
-       /*@modifies parser @*/;
+XML_DefaultCurrent(XML_Parser parser);
 
 /* If do_nst is non-zero, and namespace processing is in effect, and
    a name has a prefix (i.e. an explicit namespace qualifier) then
@@ -696,13 +725,11 @@ XML_DefaultCurrent(XML_Parser parser)
 */
 
 XMLPARSEAPI(void)
-XML_SetReturnNSTriplet(XML_Parser parser, int do_nst)
-       /*@modifies parser @*/;
+XML_SetReturnNSTriplet(XML_Parser parser, int do_nst);
 
 /* This value is passed as the userData argument to callbacks. */
 XMLPARSEAPI(void)
-XML_SetUserData(XML_Parser parser, void *userData)
-       /*@modifies parser @*/;
+XML_SetUserData(XML_Parser parser, void *userData);
 
 /* Returns the last value set by XML_SetUserData or NULL. */
 #define XML_GetUserData(parser) (*(void **)(parser))
@@ -714,16 +741,14 @@ XML_SetUserData(XML_Parser parser, void *userData)
      has no effect and returns XML_STATUS_ERROR.
 */
 XMLPARSEAPI(enum XML_Status)
-XML_SetEncoding(XML_Parser parser, const XML_Char *encoding)
-       /*@modifies parser @*/;
+XML_SetEncoding(XML_Parser parser, const XML_Char *encoding);
 
 /* If this function is called, then the parser will be passed as the
    first argument to callbacks instead of userData.  The userData will
    still be accessible using XML_GetUserData.
 */
 XMLPARSEAPI(void)
-XML_UseParserAsHandlerArg(XML_Parser parser)
-       /*@modifies parser @*/;
+XML_UseParserAsHandlerArg(XML_Parser parser);
 
 /* If useDTD == XML_TRUE is passed to this function, then the parser
    will assume that there is an external subset, even if none is
@@ -741,8 +766,7 @@ XML_UseParserAsHandlerArg(XML_Parser parser)
      XML_ERROR_FEATURE_REQUIRES_XML_DTD.
 */
 XMLPARSEAPI(enum XML_Error)
-XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
-       /*@modifies parser @*/;
+XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
 
 
 /* Sets the base to be used for resolving relative URIs in system
@@ -754,12 +778,10 @@ XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
    XML_STATUS_OK otherwise.
 */
 XMLPARSEAPI(enum XML_Status)
-XML_SetBase(XML_Parser parser, const XML_Char *base)
-       /*@modifies parser @*/;
+XML_SetBase(XML_Parser parser, const XML_Char *base);
 
 XMLPARSEAPI(const XML_Char *)
-XML_GetBase(XML_Parser parser)
-       /*@*/;
+XML_GetBase(XML_Parser parser);
 
 /* Returns the number of the attribute/value pairs passed in last call
    to the XML_StartElementHandler that were specified in the start-tag
@@ -768,8 +790,7 @@ XML_GetBase(XML_Parser parser)
    XML_StartElementHandler.
 */
 XMLPARSEAPI(int)
-XML_GetSpecifiedAttributeCount(XML_Parser parser)
-       /*@*/;
+XML_GetSpecifiedAttributeCount(XML_Parser parser);
 
 /* Returns the index of the ID attribute passed in the last call to
    XML_StartElementHandler, or -1 if there is no ID attribute.  Each
@@ -777,47 +798,25 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser)
    index into the atts array passed to the XML_StartElementHandler.
 */
 XMLPARSEAPI(int)
-XML_GetIdAttributeIndex(XML_Parser parser)
-       /*@*/;
+XML_GetIdAttributeIndex(XML_Parser parser);
 
 /* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
    detected.  The last call to XML_Parse must have isFinal true; len
    may be zero for this call (or any other).
 
-   The XML_Status enum gives the possible return values for the
-   XML_Parse and XML_ParseBuffer functions.  Though the return values
-   for these functions has always been described as a Boolean value,
-   the implementation, at least for the 1.95.x series, has always
-   returned exactly one of these values.  The preprocessor #defines
-   are included so this stanza can be added to code that still needs
-   to support older versions of Expat 1.95.x:
-
-   #ifndef XML_STATUS_OK
-   #define XML_STATUS_OK    1
-   #define XML_STATUS_ERROR 0
-   #endif
-
-   Otherwise, the #define hackery is quite ugly and would have been dropped.
+   Though the return values for these functions has always been
+   described as a Boolean value, the implementation, at least for the
+   1.95.x series, has always returned exactly one of the XML_Status
+   values.
 */
-enum XML_Status {
-  XML_STATUS_ERROR = 0,
-#define XML_STATUS_ERROR XML_STATUS_ERROR
-  XML_STATUS_OK = 1
-#define XML_STATUS_OK XML_STATUS_OK
-};
-
 XMLPARSEAPI(enum XML_Status)
-XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
-       /*@modifies parser @*/;
+XML_Parse(XML_Parser parser, const char *s, int len, int isFinal);
 
-/*@null@*/
 XMLPARSEAPI(void *)
-XML_GetBuffer(XML_Parser parser, int len)
-       /*@modifies parser @*/;
+XML_GetBuffer(XML_Parser parser, int len);
 
 XMLPARSEAPI(enum XML_Status)
-XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
-       /*@modifies parser @*/;
+XML_ParseBuffer(XML_Parser parser, int len, int isFinal);
 
 /* Creates an XML_Parser object that can parse an external general
    entity; context is a '\0'-terminated string specifying the parse
@@ -835,12 +834,10 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
    initialized from the parser argument.  Returns NULL if out of memory.
    Otherwise returns a new XML_Parser object.
 */
-/*@null@*/
 XMLPARSEAPI(XML_Parser)
 XML_ExternalEntityParserCreate(XML_Parser parser,
                                const XML_Char *context,
-                               const XML_Char *encoding)
-       /*@*/;
+                               const XML_Char *encoding);
 
 enum XML_ParamEntityParsing {
   XML_PARAM_ENTITY_PARSING_NEVER,
@@ -873,20 +870,23 @@ enum XML_ParamEntityParsing {
 */
 XMLPARSEAPI(int)
 XML_SetParamEntityParsing(XML_Parser parser,
-                          enum XML_ParamEntityParsing parsing)
-       /*@modifies parser @*/;
+                          enum XML_ParamEntityParsing parsing);
 
 /* If XML_Parse or XML_ParseBuffer have returned XML_STATUS_ERROR, then
    XML_GetErrorCode returns information about the error.
 */
 XMLPARSEAPI(enum XML_Error)
-XML_GetErrorCode(XML_Parser parser)
-       /*@*/;
+XML_GetErrorCode(XML_Parser parser);
 
 /* These functions return information about the current parse
    location.  They may be called from any callback called to report
-   some parse event; in this case the location is the location of
-   the first of the sequence of characters that generated the event. 
+   some parse event; in this case the location is the location of the
+   first of the sequence of characters that generated the event.  When
+   called from callbacks generated by declarations in the document
+   prologue, the location identified isn't as neatly defined, but will
+   be within the relevant markup.  When called outside of the callback
+   functions, the position indicated will be just past the last parse
+   event (regardless of whether there was an associated callback).
    
    They may also be called after returning from a call to XML_Parse
    or XML_ParseBuffer.  If the return value is XML_STATUS_ERROR then
@@ -894,19 +894,15 @@ XML_GetErrorCode(XML_Parser parser)
    was detected; otherwise the location is the location of the last
    parse event, as described above.
 */
-XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser)
-       /*@modifies parser @*/;
-XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser)
-       /*@modifies parser @*/;
-XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser)
-       /*@*/;
+XMLPARSEAPI(int) XML_GetCurrentLineNumber(XML_Parser parser);
+XMLPARSEAPI(int) XML_GetCurrentColumnNumber(XML_Parser parser);
+XMLPARSEAPI(long) XML_GetCurrentByteIndex(XML_Parser parser);
 
 /* Return the number of bytes in the current event.
    Returns 0 if the event is in an internal entity.
 */
 XMLPARSEAPI(int)
-XML_GetCurrentByteCount(XML_Parser parser)
-       /*@*/;
+XML_GetCurrentByteCount(XML_Parser parser);
 
 /* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
    the integer pointed to by offset to the offset within this buffer
@@ -918,12 +914,10 @@ XML_GetCurrentByteCount(XML_Parser parser)
    NOTE: The character pointer returned should not be used outside
    the handler that makes the call.
 */
-/*@null@*/
 XMLPARSEAPI(const char *)
 XML_GetInputContext(XML_Parser parser,
-                    /*@out@*/ int *offset,
-                    /*@out@*/ int *size)
-       /*@modifies *offset, *size @*/;
+                    int *offset,
+                    int *size);
 
 /* For backwards compatibility with previous versions. */
 #define XML_GetErrorLineNumber   XML_GetCurrentLineNumber
@@ -932,38 +926,29 @@ XML_GetInputContext(XML_Parser parser,
 
 /* Frees the content model passed to the element declaration handler */
 XMLPARSEAPI(void)
-XML_FreeContentModel(XML_Parser parser, XML_Content *model)
-       /*@*/;
+XML_FreeContentModel(XML_Parser parser, XML_Content *model);
 
 /* Exposing the memory handling functions used in Expat */
 XMLPARSEAPI(void *)
-XML_MemMalloc(XML_Parser parser, size_t size)
-       /*@*/;
+XML_MemMalloc(XML_Parser parser, size_t size);
 
 XMLPARSEAPI(void *)
-XML_MemRealloc(XML_Parser parser, void *ptr, size_t size)
-       /*@*/;
+XML_MemRealloc(XML_Parser parser, void *ptr, size_t size);
 
 XMLPARSEAPI(void)
-XML_MemFree(XML_Parser parser, void *ptr)
-       /*@*/;
+XML_MemFree(XML_Parser parser, void *ptr);
 
 /* Frees memory used by the parser. */
 XMLPARSEAPI(void)
-XML_ParserFree(/*@only@*/ XML_Parser parser)
-       /*@modifies parser @*/;
+XML_ParserFree(XML_Parser parser);
 
 /* Returns a string describing the error. */
-/*@observer@*/ /*@null@*/
 XMLPARSEAPI(const XML_LChar *)
-XML_ErrorString(enum XML_Error code)
-       /*@*/;
+XML_ErrorString(enum XML_Error code);
 
 /* Return a string containing the version number of this expat */
-/*@observer@*/
 XMLPARSEAPI(const XML_LChar *)
-XML_ExpatVersion(void)
-       /*@*/;
+XML_ExpatVersion(void);
 
 typedef struct {
   int major;
@@ -975,8 +960,7 @@ typedef struct {
    number information for this version of expat.
 */
 XMLPARSEAPI(XML_Expat_Version)
-XML_ExpatVersionInfo(void)
-       /*@*/;
+XML_ExpatVersionInfo(void);
 
 /* Added in Expat 1.95.5. */
 enum XML_FeatureEnum {
@@ -993,15 +977,12 @@ enum XML_FeatureEnum {
 
 typedef struct {
   enum XML_FeatureEnum  feature;
-/*@observer@*/
   const XML_LChar       *name;
   long int              value;
 } XML_Feature;
 
-/*@observer@*/
 XMLPARSEAPI(const XML_Feature *)
-XML_GetFeatureList(void)
-       /*@*/;
+XML_GetFeatureList(void);
 
 
 /* Expat follows the GNU/Linux convention of odd number minor version for
@@ -1011,7 +992,7 @@ XML_GetFeatureList(void)
 */
 #define XML_MAJOR_VERSION 1
 #define XML_MINOR_VERSION 95
-#define XML_MICRO_VERSION 6
+#define XML_MICRO_VERSION 7
 
 #ifdef __cplusplus
 }
index 6e2c5ed..ff056c6 100644 (file)
@@ -3,32 +3,59 @@
    Internal definitions used by Expat.  This is not needed to compile
    client code.
 
-   The following definitions are made:
+   The following calling convention macros are defined for frequently
+   called functions:
 
-   FASTCALL -- Used for most internal functions to specify that the
-               fastest possible calling convention be used.
+   FASTCALL    - Used for those internal functions that have a simple
+                 body and a low number of arguments and local variables.
 
-   inline   -- Used for selected internal functions for which inlining
-               may improve performance on some platforms.
-*/
+   PTRCALL     - Used for functions called though function pointers.
+
+   PTRFASTCALL - Like PTRCALL, but for low number of arguments.
 
-#if defined(__GNUC__)
-/* Last minute instability reported with egcs on a RedHat Linux 7.3
-   box; argh!
+   inline      - Used for selected internal functions for which inlining
+                 may improve performance on some platforms.
+
+   Note: Use of these macros is based on judgement, not hard rules,
+         and therefore subject to change.
 */
-/* #define FASTCALL __attribute__((stdcall, regparm(3))) */
-#elif defined(WIN32)
-/* XXX This seems to have an unexpected negative effect on Windows so
-   we'll disable it for now on that platform.  It may be reconsidered
-   for a future release if it can be made more effective.
+
+#if defined(__GNUC__) && defined(__i386__)
+/* We'll use this version by default only where we know it helps.
+
+   regparm() generates warnings on Solaris boxes.   See SF bug #692878.
+
+   Instability reported with egcs on a RedHat Linux 7.3.
+   Let's comment out:
+   #define FASTCALL __attribute__((stdcall, regparm(3)))
+   and let's try this:
 */
-/* #define FASTCALL __fastcall */
+#define FASTCALL __attribute__((regparm(3)))
+#define PTRFASTCALL __attribute__((regparm(3)))
 #endif
 
+/* Using __fastcall seems to have an unexpected negative effect under
+   MS VC++, especially for function pointers, so we won't use it for
+   now on that platform. It may be reconsidered for a future release
+   if it can be made more effective.
+   Likely reason: __fastcall on Windows is like stdcall, therefore
+   the compiler cannot perform stack optimizations for call clusters.
+*/
+
+/* Make sure all of these are defined if they aren't already. */
+
 #ifndef FASTCALL
 #define FASTCALL
 #endif
 
+#ifndef PTRCALL
+#define PTRCALL
+#endif
+
+#ifndef PTRFASTCALL
+#define PTRFASTCALL
+#endif
+
 #ifndef XML_MIN_SIZE
 #if !defined(__cplusplus) && !defined(inline)
 #ifdef __GNUC__
index 7a57666..82f67c6 100644 (file)
@@ -5,33 +5,20 @@
 #include <stddef.h>
 #include <string.h>                     /* memset(), memcpy() */
 
-#ifdef COMPILED_FROM_DSP
+#define XML_BUILDING_EXPAT 1
 
+#ifdef COMPILED_FROM_DSP
 #include "winconfig.h"
-#define XMLPARSEAPI(type) type __cdecl
-#include "expat.h"
-#undef XMLPARSEAPI
-
 #elif defined(MACOS_CLASSIC)
-
 #include "macconfig.h"
-#include "expat.h"
-
 #else
-
-#include <expat_config.h>
-
-#ifdef __declspec
-#define XMLPARSEAPI(type) type __cdecl
+#ifdef HAVE_CONFIG_H
+#include <config.h>
 #endif
+#endif /* ndef COMPILED_FROM_DSP */
 
 #include "expat.h"
 
-#ifdef __declspec
-#undef XMLPARSEAPI
-#endif
-#endif /* ndef COMPILED_FROM_DSP */
-
 #ifdef XML_UNICODE
 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX
 #define XmlConvert XmlUtf16Convert
@@ -102,12 +89,37 @@ typedef struct {
 
 typedef struct {
   NAMED **v;
+  unsigned char power;
   size_t size;
   size_t used;
-  size_t usedLim;
   const XML_Memory_Handling_Suite *mem;
 } HASH_TABLE;
 
+/* Basic character hash algorithm, taken from Python's string hash:
+   h = h * 1000003 ^ character, the constant being a prime number.
+
+*/
+#ifdef XML_UNICODE
+#define CHAR_HASH(h, c) \
+  (((h) * 0xF4243) ^ (unsigned short)(c))
+#else
+#define CHAR_HASH(h, c) \
+  (((h) * 0xF4243) ^ (unsigned char)(c))
+#endif
+
+/* For probing (after a collision) we need a step size relative prime
+   to the hash table size, which is a power of 2. We use double-hashing,
+   since we can calculate a second hash value cheaply by taking those bits
+   of the first hash value that were discarded (masked out) when the table
+   index was calculated: index = hash & mask, where mask = table->size - 1.
+   We limit the maximum step size to table->size / 4 (mask >> 2) and make
+   it odd, since odd numbers are always relative prime to a power of 2.
+*/
+#define SECOND_HASH(hash, mask, power) \
+  ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2))
+#define PROBE_STEP(hash, mask, power) \
+  ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1))
+
 typedef struct {
   NAMED **p;
 /*@dependent@*/
@@ -117,6 +129,7 @@ typedef struct {
 #define INIT_TAG_BUF_SIZE 32  /* must be a multiple of sizeof(XML_Char) */
 #define INIT_DATA_BUF_SIZE 1024
 #define INIT_ATTS_SIZE 16
+#define INIT_ATTS_VERSION 0xFFFFFFFF
 #define INIT_BLOCK_SIZE 1024
 #define INIT_BUFFER_SIZE 1024
 
@@ -167,7 +180,6 @@ typedef struct tag {
   TAG_NAME name;                /* tagName in the API encoding */
 /*@owned@*/
   char *buf;                    /* buffer for name components */
-/*@dependent@*/
   char *bufEnd;                 /* end of the buffer */
   BINDING *bindings;
 } TAG;
@@ -206,10 +218,8 @@ typedef struct block {
 typedef struct {
   BLOCK *blocks;
   BLOCK *freeBlocks;
-/*@dependent@*/
   const XML_Char *end;
   XML_Char *ptr;
-/*@owned@*/
   XML_Char *start;
   const XML_Memory_Handling_Suite *mem;
 } STRING_POOL;
@@ -231,6 +241,12 @@ typedef struct {
 } DEFAULT_ATTRIBUTE;
 
 typedef struct {
+  unsigned long version;
+  unsigned long hash;
+  const XML_Char *uriName;
+} NS_ATT;
+
+typedef struct {
   const XML_Char *name;
   PREFIX *prefix;
   const ATTRIBUTE_ID *idAtt;
@@ -285,10 +301,8 @@ typedef enum XML_Error PTRCALL Processor(XML_Parser parser,
 static Processor prologProcessor;
 /*@unchecked@*/
 static Processor prologInitProcessor;
-#if !defined(__LCLINT__)
 /*@unchecked@*/
 static Processor contentProcessor;
-#endif
 /*@unchecked@*/
 static Processor cdataSectionProcessor;
 #ifdef XML_DTD
@@ -321,14 +335,14 @@ handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName)
        /*@modifies parser @*/;
 static enum XML_Error
 processXmlDecl(XML_Parser parser, int isGeneralTextEntity,
-               const char *, const char *)
+               const char *, const char *)
        /*@modifies parser @*/;
 static enum XML_Error
 initializeEncoding(XML_Parser parser)
        /*@modifies parser @*/;
 static enum XML_Error
 doProlog(XML_Parser parser, const ENCODING *enc, const char *s,
-         const char *end, int tok, const char *next,
+               const char *end, int tok, const char *next,
        /*@null@*/ const char **nextPtr)
        /*@modifies parser, s, next, *nextPtr @*/;
 static enum XML_Error
@@ -336,65 +350,64 @@ processInternalParamEntity(XML_Parser parser, ENTITY *entity)
        /*@modifies parser, entity @*/;
 static enum XML_Error
 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc,
-          const char *start, const char *end, const char **endPtr)
+               const char *start, const char *end, const char **endPtr)
        /*@modifies parser, start, *endPtr @*/;
 static enum XML_Error
 doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr,
-               const char *end, const char **nextPtr)
+               const char *end, const char **nextPtr)
        /*@modifies parser, *startPtr, *nextPtr @*/;
 #ifdef XML_DTD
 static enum XML_Error
 doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr,
-                const char *end, const char **nextPtr)
+               const char *end, const char **nextPtr)
        /*@modifies parser, *startPtr, *nextPtr @*/;
 #endif /* XML_DTD */
 
 static enum XML_Error
 storeAtts(XML_Parser parser, const ENCODING *, const char *s,
-          TAG_NAME *tagNamePtr, BINDING **bindingsPtr)
+               TAG_NAME *tagNamePtr, BINDING **bindingsPtr)
        /*@modifies parser, tagNamePtr, *bindingsPtr @*/;
 static enum XML_Error
 addBinding(XML_Parser parser, PREFIX *prefix,
-          /*@null@*/ const ATTRIBUTE_ID *attId,
-           const XML_Char *uri, BINDING **bindingsPtr)
+               /*@null@*/ const ATTRIBUTE_ID *attId,
+               const XML_Char *uri, BINDING **bindingsPtr)
        /*@modifies parser, *bindingsPtr @*/;
 static int
-defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId,
-                XML_Bool isCdata, XML_Bool isId,
-               /*@null@*/ const XML_Char *dfltValue,
-                XML_Parser parser)
+defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *,
+               XML_Bool isCdata, XML_Bool isId, const XML_Char *dfltValue,
+               XML_Parser parser)
        /*@modifies type, attId @*/;
 static enum XML_Error
 storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata,
-                    const char *, const char *, STRING_POOL *pool)
+               const char *, const char *, STRING_POOL *)
        /*@modifies parser, pool @*/;
 static enum XML_Error
 appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata,
-                     const char *, const char *, STRING_POOL *pool)
+               const char *, const char *, STRING_POOL *)
        /*@modifies parser, pool @*/;
 /*@null@*/
 static ATTRIBUTE_ID *
 getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start,
-               const char *end)
+               const char *end)
        /*@modifies parser @*/;
 static int
-setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType)
+setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *)
        /*@modifies parser, elementType @*/;
 static enum XML_Error
 storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start,
-                 const char *end)
+               const char *end)
        /*@modifies parser @*/;
 static int
 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc,
-                            const char *start, const char *end)
+               const char *start, const char *end)
        /*@modifies parser @*/;
 static int
 reportComment(XML_Parser parser, const ENCODING *enc, const char *start,
-              const char *end)
+               const char *end)
        /*@modifies parser @*/;
 static void
 reportDefault(XML_Parser parser, const ENCODING *enc, const char *start,
-              const char *end)
+               const char *end)
        /*@modifies parser @*/;
 
 /*@null@*/
@@ -404,7 +417,7 @@ static XML_Bool
 setContext(XML_Parser parser, const XML_Char *context)
        /*@modifies parser @*/;
 
-static void FASTCALL normalizePublicId(XML_Char *publicId)
+static void FASTCALL normalizePublicId(XML_Char *s)
        /*@modifies publicId @*/;
 
 static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms)
@@ -420,8 +433,7 @@ static int
 dtdCopy(DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms)
        /*@modifies newDtd @*/;
 static int
-copyEntityTable(HASH_TABLE *newTable, STRING_POOL *newPool,
-               const HASH_TABLE *oldTable)
+copyEntityTable(HASH_TABLE *, STRING_POOL *, const HASH_TABLE *)
        /*@modifies newTable, newPool @*/;
 
 /*@null@*/
@@ -429,35 +441,34 @@ static NAMED *
 lookup(HASH_TABLE *table, KEY name, size_t createSize)
        /*@modifies table @*/;
 static void FASTCALL
-hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms)
+hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms)
        /*@modifies p @*/;
-static void FASTCALL hashTableClear(HASH_TABLE *table)
+static void FASTCALL hashTableClear(HASH_TABLE *)
        /*@modifies table @*/;
-static void FASTCALL hashTableDestroy(/*@only@*/ HASH_TABLE *table)
+static void FASTCALL hashTableDestroy(HASH_TABLE *)
        /*@modifies *table @*/;
 static void FASTCALL
-hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table)
+hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *)
        /*@modifies iter @*/;
 /*@null@*/
-static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *iter)
+static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *)
        /*@modifies iter @*/;
 
 static void FASTCALL
-poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms)
+poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms)
        /*@modifies pool @*/;
-static void FASTCALL poolClear(STRING_POOL *pool)
+static void FASTCALL poolClear(STRING_POOL *)
        /*@modifies pool @*/;
-static void FASTCALL poolDestroy(/*@only@*/ STRING_POOL *pool)
+static void FASTCALL poolDestroy(STRING_POOL *)
        /*@modifies *pool @*/;
 /*@null@*/
 static XML_Char *
 poolAppend(STRING_POOL *pool, const ENCODING *enc,
-           const char *ptr, const char *end)
+               const char *ptr, const char *end)
        /*@modifies pool @*/;
-/*@null@*/
 static XML_Char *
 poolStoreString(STRING_POOL *pool, const ENCODING *enc,
-                const char *ptr, const char *end)
+               const char *ptr, const char *end)
        /*@modifies pool @*/;
 static XML_Bool FASTCALL poolGrow(STRING_POOL *pool)
        /*@modifies pool @*/;
@@ -482,15 +493,14 @@ static XML_Content * build_model(XML_Parser parser)
 /*@null@*/
 static ELEMENT_TYPE *
 getElementType(XML_Parser parser, const ENCODING *enc,
-               const char *ptr, const char *end)
+               const char *ptr, const char *end)
        /*@modifies parser @*/;
 
-/*@null@*/
 static XML_Parser
 parserCreate(const XML_Char *encodingName,
-             /*@null@*/ const XML_Memory_Handling_Suite *memsuite,
-             /*@null@*/ const XML_Char *nameSep,
-             /*@null@*/ DTD *dtd)
+               /*@null@*/ const XML_Memory_Handling_Suite *memsuite,
+               /*@null@*/ const XML_Char *nameSep,
+               /*@null@*/ DTD *dtd)
        /*@*/;
 static void
 parserInit(XML_Parser parser, const XML_Char *encodingName)
@@ -560,7 +570,6 @@ struct XML_ParserStruct {
   XML_Bool m_ns_triplets;
   void *m_unknownEncodingMem;
   void *m_unknownEncodingData;
-/*@null@*/
   void *m_unknownEncodingHandlerData;
   void (*m_unknownEncodingRelease)(void *);
   PROLOG_STATE m_prologState;
@@ -597,12 +606,15 @@ struct XML_ParserStruct {
   int m_nSpecifiedAtts;
   int m_idAttIndex;
   ATTRIBUTE *m_atts;
+  NS_ATT *m_nsAtts;
+  unsigned long m_nsAttsVersion;
+  unsigned char m_nsAttsPower;
   POSITION m_position;
   STRING_POOL m_tempPool;
   STRING_POOL m_temp2Pool;
 /*@null@*/
   char *m_groupConnector;
-  unsigned m_groupSize;
+  unsigned int m_groupSize;
   XML_Char m_namespaceSeparator;
   XML_Parser m_parentParser;
 #ifdef XML_DTD
@@ -700,6 +712,9 @@ struct XML_ParserStruct {
 #define attsSize (parser->m_attsSize)
 #define nSpecifiedAtts (parser->m_nSpecifiedAtts)
 #define idAttIndex (parser->m_idAttIndex)
+#define nsAtts (parser->m_nsAtts)
+#define nsAttsVersion (parser->m_nsAttsVersion)
+#define nsAttsPower (parser->m_nsAttsPower)
 #define tempPool (parser->m_tempPool)
 #define temp2Pool (parser->m_temp2Pool)
 #define groupConnector (parser->m_groupConnector)
@@ -712,6 +727,7 @@ struct XML_ParserStruct {
 #define paramEntityParsing (parser->m_paramEntityParsing)
 #endif /* XML_DTD */
 
+#ifdef XML_DTD
 #define parsing \
   (parentParser \
     ? \
@@ -722,14 +738,22 @@ struct XML_ParserStruct {
       (processor != externalEntityInitProcessor)) \
     : \
     (processor != prologInitProcessor))
+#else
+#define parsing \
+  (parentParser \
+    ? \
+    (processor != externalEntityInitProcessor) \
+    : \
+    (processor != prologInitProcessor))
+#endif /* XML_DTD */
 
-XML_Parser
+XML_Parser XMLCALL
 XML_ParserCreate(const XML_Char *encodingName)
 {
   return XML_ParserCreate_MM(encodingName, NULL, NULL);
 }
 
-XML_Parser
+XML_Parser XMLCALL
 XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep)
 {
   XML_Char tmp[2];
@@ -745,7 +769,7 @@ static const XML_Char implicitContext[] = {
   'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0'
 };
 
-XML_Parser
+XML_Parser XMLCALL
 XML_ParserCreate_MM(const XML_Char *encodingName,
                     const XML_Memory_Handling_Suite *memsuite,
                     const XML_Char *nameSep)
@@ -838,6 +862,10 @@ parserCreate(const XML_Char *encodingName,
   ns = XML_FALSE;
   ns_triplets = XML_FALSE;
 
+  nsAtts = NULL;
+  nsAttsVersion = 0;
+  nsAttsPower = 0;
+
   poolInit(&tempPool, &(parser->m_mem));
   poolInit(&temp2Pool, &(parser->m_mem));
   parserInit(parser, encodingName);
@@ -868,7 +896,7 @@ parserInit(XML_Parser parser, const XML_Char *encodingName)
                           ? poolCopyString(&tempPool, encodingName)
                           : NULL);
   curBase = NULL;
-  (void) XmlInitEncoding(&initEncoding, &encoding, 0);
+  XmlInitEncoding(&initEncoding, &encoding, 0);
   userData = NULL;
   handlerArg = NULL;
   startElementHandler = NULL;
@@ -943,7 +971,7 @@ moveToFreeBindingList(XML_Parser parser, BINDING *bindings)
   }
 }
 
-XML_Bool
+XML_Bool XMLCALL
 XML_ParserReset(XML_Parser parser, const XML_Char *encodingName)
 {
   TAG *tStk;
@@ -971,7 +999,7 @@ XML_ParserReset(XML_Parser parser, const XML_Char *encodingName)
   return setContext(parser, implicitContext);
 }
 
-enum XML_Status
+enum XML_Status XMLCALL
 XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName)
 {
   /* Block after XML_Parse()/XML_ParseBuffer() has been called.
@@ -990,7 +1018,7 @@ XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName)
   return XML_STATUS_OK;
 }
 
-XML_Parser
+XML_Parser XMLCALL
 XML_ExternalEntityParserCreate(XML_Parser oldParser,
                                const XML_Char *context,
                                const XML_Char *encodingName)
@@ -1122,8 +1150,7 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser,
 
 /*@-mustmod@*/
 static void FASTCALL
-destroyBindings(/*@only@*/ BINDING *bindings, XML_Parser parser)
-       /*@modifies *bindings @*/
+destroyBindings(BINDING *bindings, XML_Parser parser)
 {
   for (;;) {
     BINDING *b = bindings;
@@ -1136,7 +1163,7 @@ destroyBindings(/*@only@*/ BINDING *bindings, XML_Parser parser)
 }
 /*@=mustmod@*/
 
-void
+void XMLCALL
 XML_ParserFree(XML_Parser parser)
 {
   for (;;) {
@@ -1172,6 +1199,7 @@ XML_ParserFree(XML_Parser parser)
   if (buffer)
     FREE(buffer);
   FREE(dataBuf);
+  FREE(nsAtts);
   if (unknownEncodingMem)
     FREE(unknownEncodingMem);
   if (unknownEncodingRelease)
@@ -1179,13 +1207,13 @@ XML_ParserFree(XML_Parser parser)
   FREE(parser);
 }
 
-void
+void XMLCALL
 XML_UseParserAsHandlerArg(XML_Parser parser)
 {
   handlerArg = parser;
 }
 
-enum XML_Error
+enum XML_Error XMLCALL
 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
 {
 #ifdef XML_DTD
@@ -1199,7 +1227,7 @@ XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD)
 #endif
 }
 
-void
+void XMLCALL
 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst)
 {
   /* block after XML_Parse()/XML_ParseBuffer() has been called */
@@ -1208,7 +1236,7 @@ XML_SetReturnNSTriplet(XML_Parser parser, int do_nst)
   ns_triplets = do_nst ? XML_TRUE : XML_FALSE;
 }
 
-void
+void XMLCALL
 XML_SetUserData(XML_Parser parser, void *p)
 {
   if (handlerArg == userData)
@@ -1217,7 +1245,7 @@ XML_SetUserData(XML_Parser parser, void *p)
     userData = p;
 }
 
-enum XML_Status
+enum XML_Status XMLCALL
 XML_SetBase(XML_Parser parser, const XML_Char *p)
 {
   if (p) {
@@ -1231,25 +1259,25 @@ XML_SetBase(XML_Parser parser, const XML_Char *p)
   return XML_STATUS_OK;
 }
 
-const XML_Char *
+const XML_Char * XMLCALL
 XML_GetBase(XML_Parser parser)
 {
   return curBase;
 }
 
-int
+int XMLCALL
 XML_GetSpecifiedAttributeCount(XML_Parser parser)
 {
   return nSpecifiedAtts;
 }
 
-int
+int XMLCALL
 XML_GetIdAttributeIndex(XML_Parser parser)
 {
   return idAttIndex;
 }
 
-void
+void XMLCALL
 XML_SetElementHandler(XML_Parser parser,
                       XML_StartElementHandler start,
                       XML_EndElementHandler end)
@@ -1258,40 +1286,40 @@ XML_SetElementHandler(XML_Parser parser,
   endElementHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetStartElementHandler(XML_Parser parser,
                            XML_StartElementHandler start) {
   startElementHandler = start;
 }
 
-void
+void XMLCALL
 XML_SetEndElementHandler(XML_Parser parser,
                          XML_EndElementHandler end) {
   endElementHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetCharacterDataHandler(XML_Parser parser,
                             XML_CharacterDataHandler handler)
 {
   characterDataHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetProcessingInstructionHandler(XML_Parser parser,
                                     XML_ProcessingInstructionHandler handler)
 {
   processingInstructionHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetCommentHandler(XML_Parser parser,
                       XML_CommentHandler handler)
 {
   commentHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetCdataSectionHandler(XML_Parser parser,
                            XML_StartCdataSectionHandler start,
                            XML_EndCdataSectionHandler end)
@@ -1300,19 +1328,19 @@ XML_SetCdataSectionHandler(XML_Parser parser,
   endCdataSectionHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetStartCdataSectionHandler(XML_Parser parser,
                                 XML_StartCdataSectionHandler start) {
   startCdataSectionHandler = start;
 }
 
-void
+void XMLCALL
 XML_SetEndCdataSectionHandler(XML_Parser parser,
                               XML_EndCdataSectionHandler end) {
   endCdataSectionHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetDefaultHandler(XML_Parser parser,
                       XML_DefaultHandler handler)
 {
@@ -1320,7 +1348,7 @@ XML_SetDefaultHandler(XML_Parser parser,
   defaultExpandInternalEntities = XML_FALSE;
 }
 
-void
+void XMLCALL
 XML_SetDefaultHandlerExpand(XML_Parser parser,
                             XML_DefaultHandler handler)
 {
@@ -1328,7 +1356,7 @@ XML_SetDefaultHandlerExpand(XML_Parser parser,
   defaultExpandInternalEntities = XML_TRUE;
 }
 
-void
+void XMLCALL
 XML_SetDoctypeDeclHandler(XML_Parser parser,
                           XML_StartDoctypeDeclHandler start,
                           XML_EndDoctypeDeclHandler end)
@@ -1337,33 +1365,33 @@ XML_SetDoctypeDeclHandler(XML_Parser parser,
   endDoctypeDeclHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetStartDoctypeDeclHandler(XML_Parser parser,
                                XML_StartDoctypeDeclHandler start) {
   startDoctypeDeclHandler = start;
 }
 
-void
+void XMLCALL
 XML_SetEndDoctypeDeclHandler(XML_Parser parser,
                              XML_EndDoctypeDeclHandler end) {
   endDoctypeDeclHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetUnparsedEntityDeclHandler(XML_Parser parser,
                                  XML_UnparsedEntityDeclHandler handler)
 {
   unparsedEntityDeclHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetNotationDeclHandler(XML_Parser parser,
                            XML_NotationDeclHandler handler)
 {
   notationDeclHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetNamespaceDeclHandler(XML_Parser parser,
                             XML_StartNamespaceDeclHandler start,
                             XML_EndNamespaceDeclHandler end)
@@ -1372,33 +1400,33 @@ XML_SetNamespaceDeclHandler(XML_Parser parser,
   endNamespaceDeclHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetStartNamespaceDeclHandler(XML_Parser parser,
                                  XML_StartNamespaceDeclHandler start) {
   startNamespaceDeclHandler = start;
 }
 
-void
+void XMLCALL
 XML_SetEndNamespaceDeclHandler(XML_Parser parser,
                                XML_EndNamespaceDeclHandler end) {
   endNamespaceDeclHandler = end;
 }
 
-void
+void XMLCALL
 XML_SetNotStandaloneHandler(XML_Parser parser,
                             XML_NotStandaloneHandler handler)
 {
   notStandaloneHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetExternalEntityRefHandler(XML_Parser parser,
                                 XML_ExternalEntityRefHandler handler)
 {
   externalEntityRefHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
 {
   if (arg)
@@ -1407,14 +1435,14 @@ XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg)
     externalEntityRefHandlerArg = parser;
 }
 
-void
+void XMLCALL
 XML_SetSkippedEntityHandler(XML_Parser parser,
                             XML_SkippedEntityHandler handler)
 {
   skippedEntityHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetUnknownEncodingHandler(XML_Parser parser,
                               XML_UnknownEncodingHandler handler,
                               void *data)
@@ -1423,34 +1451,34 @@ XML_SetUnknownEncodingHandler(XML_Parser parser,
   unknownEncodingHandlerData = data;
 }
 
-void
+void XMLCALL
 XML_SetElementDeclHandler(XML_Parser parser,
                           XML_ElementDeclHandler eldecl)
 {
   elementDeclHandler = eldecl;
 }
 
-void
+void XMLCALL
 XML_SetAttlistDeclHandler(XML_Parser parser,
                           XML_AttlistDeclHandler attdecl)
 {
   attlistDeclHandler = attdecl;
 }
 
-void
+void XMLCALL
 XML_SetEntityDeclHandler(XML_Parser parser,
                          XML_EntityDeclHandler handler)
 {
   entityDeclHandler = handler;
 }
 
-void
+void XMLCALL
 XML_SetXmlDeclHandler(XML_Parser parser,
                       XML_XmlDeclHandler handler) {
   xmlDeclHandler = handler;
 }
 
-int
+int XMLCALL
 XML_SetParamEntityParsing(XML_Parser parser,
                           enum XML_ParamEntityParsing peParsing)
 {
@@ -1465,7 +1493,7 @@ XML_SetParamEntityParsing(XML_Parser parser,
 #endif
 }
 
-enum XML_Status
+enum XML_Status XMLCALL
 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
 {
   if (len == 0) {
@@ -1540,7 +1568,7 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
   }
 }
 
-enum XML_Status
+enum XML_Status XMLCALL
 XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
 {
   const char *start = bufferPtr;
@@ -1563,7 +1591,7 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal)
   }
 }
 
-void *
+void * XMLCALL
 XML_GetBuffer(XML_Parser parser, int len)
 {
   if (len > bufferLim - bufferEnd) {
@@ -1632,13 +1660,13 @@ XML_GetBuffer(XML_Parser parser, int len)
   return bufferEnd;
 }
 
-enum XML_Error
+enum XML_Error XMLCALL
 XML_GetErrorCode(XML_Parser parser)
 {
   return errorCode;
 }
 
-long
+long XMLCALL
 XML_GetCurrentByteIndex(XML_Parser parser)
 {
   if (eventPtr)
@@ -1646,7 +1674,7 @@ XML_GetCurrentByteIndex(XML_Parser parser)
   return -1;
 }
 
-int
+int XMLCALL
 XML_GetCurrentByteCount(XML_Parser parser)
 {
   if (eventEndPtr && eventPtr)
@@ -1654,7 +1682,7 @@ XML_GetCurrentByteCount(XML_Parser parser)
   return 0;
 }
 
-const char *
+const char * XMLCALL
 XML_GetInputContext(XML_Parser parser, int *offset, int *size)
 {
 #ifdef XML_CONTEXT_BYTES
@@ -1667,7 +1695,7 @@ XML_GetInputContext(XML_Parser parser, int *offset, int *size)
   return (char *) 0;
 }
 
-int
+int XMLCALL
 XML_GetCurrentLineNumber(XML_Parser parser)
 {
   if (eventPtr) {
@@ -1677,7 +1705,7 @@ XML_GetCurrentLineNumber(XML_Parser parser)
   return position.lineNumber + 1;
 }
 
-int
+int XMLCALL
 XML_GetCurrentColumnNumber(XML_Parser parser)
 {
   if (eventPtr) {
@@ -1687,31 +1715,31 @@ XML_GetCurrentColumnNumber(XML_Parser parser)
   return position.columnNumber;
 }
 
-void
+void XMLCALL
 XML_FreeContentModel(XML_Parser parser, XML_Content *model)
 {
   FREE(model);
 }
 
-void *
+void * XMLCALL
 XML_MemMalloc(XML_Parser parser, size_t size)
 {
   return MALLOC(size);
 }
 
-void *
+void * XMLCALL
 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size)
 {
   return REALLOC(ptr, size);
 }
 
-void
+void XMLCALL
 XML_MemFree(XML_Parser parser, void *ptr)
 {
   FREE(ptr);
 }
 
-void
+void XMLCALL
 XML_DefaultCurrent(XML_Parser parser)
 {
   if (defaultHandler) {
@@ -1725,7 +1753,7 @@ XML_DefaultCurrent(XML_Parser parser)
   }
 }
 
-const XML_LChar *
+const XML_LChar * XMLCALL
 XML_ErrorString(enum XML_Error code)
 {
 /*@-readonlytrans@*/
@@ -1759,7 +1787,8 @@ XML_ErrorString(enum XML_Error code)
     XML_L("unexpected parser state - please send a bug report"),
     XML_L("entity declared in parameter entity"),
     XML_L("requested feature requires XML_DTD support in Expat"),
-    XML_L("cannot change setting once parsing has begun")
+    XML_L("cannot change setting once parsing has begun"),
+    XML_L("unbound prefix")
   };
 /*@=readonlytrans@*/
   if (code > 0 && code < sizeof(message)/sizeof(message[0]))
@@ -1767,7 +1796,7 @@ XML_ErrorString(enum XML_Error code)
   return NULL;
 }
 
-const XML_LChar *
+const XML_LChar * XMLCALL
 XML_ExpatVersion(void) {
 
   /* V1 is used to string-ize the version number. However, it would
@@ -1787,7 +1816,7 @@ XML_ExpatVersion(void) {
 #undef V2
 }
 
-XML_Expat_Version
+XML_Expat_Version XMLCALL
 XML_ExpatVersionInfo(void)
 {
   XML_Expat_Version version;
@@ -1799,29 +1828,29 @@ XML_ExpatVersionInfo(void)
   return version;
 }
 
-const XML_Feature *
+const XML_Feature * XMLCALL
 XML_GetFeatureList(void)
 {
   static XML_Feature features[] = {
-    {XML_FEATURE_SIZEOF_XML_CHAR,  XML_L("sizeof(XML_Char)")},
-    {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)")},
+    {XML_FEATURE_SIZEOF_XML_CHAR,  XML_L("sizeof(XML_Char)"), 0},
+    {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), 0},
 #ifdef XML_UNICODE
-    {XML_FEATURE_UNICODE,          XML_L("XML_UNICODE")},
+    {XML_FEATURE_UNICODE,          XML_L("XML_UNICODE"), 0},
 #endif
 #ifdef XML_UNICODE_WCHAR_T
-    {XML_FEATURE_UNICODE_WCHAR_T,  XML_L("XML_UNICODE_WCHAR_T")},
+    {XML_FEATURE_UNICODE_WCHAR_T,  XML_L("XML_UNICODE_WCHAR_T"), 0},
 #endif
 #ifdef XML_DTD
-    {XML_FEATURE_DTD,              XML_L("XML_DTD")},
+    {XML_FEATURE_DTD,              XML_L("XML_DTD"), 0},
 #endif
 #ifdef XML_CONTEXT_BYTES
     {XML_FEATURE_CONTEXT_BYTES,    XML_L("XML_CONTEXT_BYTES"),
      XML_CONTEXT_BYTES},
 #endif
 #ifdef XML_MIN_SIZE
-    {XML_FEATURE_MIN_SIZE,         XML_L("XML_MIN_SIZE")},
+    {XML_FEATURE_MIN_SIZE,         XML_L("XML_MIN_SIZE"), 0},
 #endif
-    {XML_FEATURE_END,              NULL}
+    {XML_FEATURE_END,              NULL, 0}
   };
 
   features[0].value = sizeof(XML_Char);
@@ -2463,7 +2492,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
 {
   DTD * const dtd = _dtd;  /* save one level of indirection */
   ELEMENT_TYPE *elementType = NULL;
-  int nDefaultAtts = 0;
+  int nDefaultAtts;
   const XML_Char **appAtts;   /* the attribute list for the application */
   int attIndex = 0;
   int prefixLen;
@@ -2511,7 +2540,10 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
                                          + XmlNameLength(enc, atts[i].name));
     if (!attId)
       return XML_ERROR_NO_MEMORY;
-    /* detect duplicate attributes */
+    /* Detect duplicate attributes by their QNames. This does not work when
+       namespace processing is turned on and different prefixes for the same
+       namespace are used. For this case we have a check further down.
+    */
     if ((attId->name)[-1]) {
       if (enc == encoding)
         eventPtr = atts[i].name;
@@ -2611,58 +2643,126 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
   }
   appAtts[attIndex] = 0;
 
+  /* expand prefixed attribute names, check for duplicates,
+     and clear flags that say whether attributes were specified */
   i = 0;
   if (nPrefixes) {
-    /* expand prefixed attribute names */
+    int j;  /* hash table index */
+    unsigned long version = nsAttsVersion;
+    int nsAttsSize = (int)1 << nsAttsPower;
+    /* size of hash table must be at least 2 * (# of prefixed attributes) */
+    if ((nPrefixes << 1) >> nsAttsPower) {  /* true for nsAttsPower = 0 */
+      NS_ATT *temp;
+      /* hash table size must also be a power of 2 and >= 8 */
+      while (nPrefixes >> nsAttsPower++);
+      if (nsAttsPower < 3)
+        nsAttsPower = 3;
+      nsAttsSize = (int)1 << nsAttsPower;
+      temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT));
+      if (!temp)
+        return XML_ERROR_NO_MEMORY;
+      nsAtts = temp;
+      version = 0;  /* force re-initialization of nsAtts hash table */
+    }
+    /* using a version flag saves us from initializing nsAtts every time */
+    if (!version) {  /* initialize version flags when version wraps around */
+      version = INIT_ATTS_VERSION;
+      for (j = nsAttsSize; j != 0; )
+        nsAtts[--j].version = version;
+    }
+    nsAttsVersion = --version;
+
+    /* expand prefixed names and check for duplicates */
     for (; i < attIndex; i += 2) {
-      if (appAtts[i][-1] == 2) {
+      const XML_Char *s = appAtts[i];
+      if (s[-1] == 2) {  /* prefixed */
         ATTRIBUTE_ID *id;
-        ((XML_Char *)(appAtts[i]))[-1] = 0;
-        id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, appAtts[i], 0);
-        if (id->prefix->binding) {
-          int j;
-          const BINDING *b = id->prefix->binding;
-          const XML_Char *s = appAtts[i];
-          for (j = 0; j < b->uriLen; j++) {
-            if (!poolAppendChar(&tempPool, b->uri[j]))
-              return XML_ERROR_NO_MEMORY;
+        const BINDING *b;
+        unsigned long uriHash = 0;
+        ((XML_Char *)s)[-1] = 0;  /* clear flag */
+        id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, s, 0);
+        b = id->prefix->binding;
+        if (!b)
+          return XML_ERROR_UNBOUND_PREFIX;
+
+        /* as we expand the name we also calculate its hash value */
+        for (j = 0; j < b->uriLen; j++) {
+          const XML_Char c = b->uri[j];
+          if (!poolAppendChar(&tempPool, c))
+            return XML_ERROR_NO_MEMORY;
+          uriHash = CHAR_HASH(uriHash, c);
+        }
+        while (*s++ != XML_T(':'))
+          ;
+        do {  /* copies null terminator */
+          const XML_Char c = *s;
+          if (!poolAppendChar(&tempPool, *s))
+            return XML_ERROR_NO_MEMORY;
+          uriHash = CHAR_HASH(uriHash, c);
+        } while (*s++);
+
+        { /* Check hash table for duplicate of expanded name (uriName).
+             Derived from code in lookup(HASH_TABLE *table, ...).
+          */
+          unsigned char step = 0;
+          unsigned long mask = nsAttsSize - 1;
+          j = uriHash & mask;  /* index into hash table */
+          while (nsAtts[j].version == version) {
+            /* for speed we compare stored hash values first */
+            if (uriHash == nsAtts[j].hash) {
+              const XML_Char *s1 = poolStart(&tempPool);
+              const XML_Char *s2 = nsAtts[j].uriName;
+              /* s1 is null terminated, but not s2 */
+              for (; *s1 == *s2 && *s1 != 0; s1++, s2++);
+              if (*s1 == 0)
+                return XML_ERROR_DUPLICATE_ATTRIBUTE;
+            }
+            if (!step)
+              step = PROBE_STEP(uriHash, mask, nsAttsPower);
+            j < step ? ( j += nsAttsSize - step) : (j -= step);
           }
-          while (*s++ != XML_T(':'))
-            ;
+        }
+
+        if (ns_triplets) {  /* append namespace separator and prefix */
+          tempPool.ptr[-1] = namespaceSeparator;
+          s = b->prefix->name;
           do {
             if (!poolAppendChar(&tempPool, *s))
               return XML_ERROR_NO_MEMORY;
           } while (*s++);
-          if (ns_triplets) {
-            tempPool.ptr[-1] = namespaceSeparator;
-            s = b->prefix->name;
-            do {
-              if (!poolAppendChar(&tempPool, *s))
-                return XML_ERROR_NO_MEMORY;
-            } while (*s++);
-          }
-
-          appAtts[i] = poolStart(&tempPool);
-          poolFinish(&tempPool);
         }
+
+        /* store expanded name in attribute list */
+        s = poolStart(&tempPool);
+        poolFinish(&tempPool);
+        appAtts[i] = s;
+
+        /* fill empty slot with new version, uriName and hash value */
+        nsAtts[j].version = version;
+        nsAtts[j].hash = uriHash;
+        nsAtts[j].uriName = s;
+
         if (!--nPrefixes)
           break;
       }
-      else
-        ((XML_Char *)(appAtts[i]))[-1] = 0;
+      else  /* not prefixed */
+        ((XML_Char *)s)[-1] = 0;  /* clear flag */
     }
   }
-  /* clear the flags that say whether attributes were specified */
+  /* clear flags for the remaining attributes */
   for (; i < attIndex; i += 2)
     ((XML_Char *)(appAtts[i]))[-1] = 0;
   for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding)
     binding->attId->name[-1] = 0;
 
+  if (!ns)
+    return XML_ERROR_NONE;
+
   /* expand the element type name */
   if (elementType->prefix) {
     binding = elementType->prefix->binding;
     if (!binding)
-      return XML_ERROR_NONE;
+      return XML_ERROR_UNBOUND_PREFIX;
     localPart = tagNamePtr->str;
     while (*localPart++ != XML_T(':'))
       ;
@@ -2674,7 +2774,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
   else
     return XML_ERROR_NONE;
   prefixLen = 0;
-  if (ns && ns_triplets && binding->prefix->name) {
+  if (ns_triplets && binding->prefix->name) {
     for (; binding->prefix->name[prefixLen++];)
       ;
   }
@@ -2701,8 +2801,9 @@ storeAtts(XML_Parser parser, const ENCODING *enc,
   uri = binding->uri + binding->uriLen;
   memcpy(uri, localPart, i * sizeof(XML_Char));
   if (prefixLen) {
-        uri = uri + (i - 1);
-    if (namespaceSeparator) { *(uri) = namespaceSeparator; }
+    uri = uri + (i - 1);
+    if (namespaceSeparator)
+      *uri = namespaceSeparator;
     memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char));
   }
   tagNamePtr->str = binding->uri;
@@ -2757,6 +2858,7 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId,
   b->prefix = prefix;
   b->attId = attId;
   b->prevPrefixBinding = prefix->binding;
+  /* NULL binding when default namespace undeclared */
   if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix)
     prefix->binding = NULL;
   else
@@ -3616,8 +3718,8 @@ doProlog(XML_Parser parser,
     case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE:
       if (dtd->keepProcessing) {
         if (!defineAttribute(declElementType, declAttributeId,
-                              declAttributeIsCdata, declAttributeIsId, 0,
-                              parser))
+                             declAttributeIsCdata, declAttributeIsId,
+                             0, parser))
           return XML_ERROR_NO_MEMORY;
         if (attlistDeclHandler && declAttributeType) {
           if (*declAttributeType == XML_T('(')
@@ -3643,11 +3745,11 @@ doProlog(XML_Parser parser,
     case XML_ROLE_FIXED_ATTRIBUTE_VALUE:
       if (dtd->keepProcessing) {
         const XML_Char *attVal;
-        enum XML_Error result
-          storeAttributeValue(parser, enc, declAttributeIsCdata,
-                                s + enc->minBytesPerChar,
-                                next - enc->minBytesPerChar,
-                                &dtd->pool);
+        enum XML_Error result =
+          storeAttributeValue(parser, enc, declAttributeIsCdata,
+                              s + enc->minBytesPerChar,
+                              next - enc->minBytesPerChar,
+                              &dtd->pool);
         if (result)
           return result;
         attVal = poolStart(&dtd->pool);
@@ -4796,7 +4898,7 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata,
   if (type->nDefaultAtts == type->allocDefaultAtts) {
     if (type->allocDefaultAtts == 0) {
       type->allocDefaultAtts = 8;
-      type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts 
+      type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts
                             * sizeof(DEFAULT_ATTRIBUTE));
       if (!type->defaultAtts)
         return 0;
@@ -4864,6 +4966,7 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
   name = poolStoreString(&dtd->pool, enc, start, end);
   if (!name)
     return NULL;
+  /* skip quotation mark - its storage will be re-used (like in name[-1]) */
   ++name;
   id = (ATTRIBUTE_ID *)lookup(&dtd->attributeIds, name, sizeof(ATTRIBUTE_ID));
   if (!id)
@@ -4889,6 +4992,7 @@ getAttributeId(XML_Parser parser, const ENCODING *enc,
     else {
       int i;
       for (i = 0; name[i]; i++) {
+        /* attributes without prefix are *not* in the default namespace */
         if (name[i] == XML_T(':')) {
           int j;
           for (j = 0; j < i; j++) {
@@ -5128,6 +5232,7 @@ dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms)
   p->defaultPrefix.binding = NULL;
 
   p->in_eldecl = XML_FALSE;
+
   if (p->scaffIndex) {
     ms->free_fcn(p->scaffIndex);
     p->scaffIndex = NULL;
@@ -5136,6 +5241,7 @@ dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms)
     ms->free_fcn(p->scaffold);
     p->scaffold = NULL;
   }
+
   p->scaffLevel = 0;
   p->scaffSize = 0;
   p->scaffCount = 0;
@@ -5377,16 +5483,16 @@ copyEntityTable(HASH_TABLE *newTable,
   return 1;
 }
 
-#define INIT_SIZE 64
+#define INIT_POWER 6
 
-static int FASTCALL
+static XML_Bool FASTCALL
 keyeq(KEY s1, KEY s2)
        /*@*/
 {
   for (; *s1 == *s2; s1++, s2++)
     if (*s1 == 0)
-      return 1;
-  return 0;
+      return XML_TRUE;
+  return XML_FALSE;
 }
 
 static unsigned long FASTCALL
@@ -5395,7 +5501,7 @@ hash(KEY s)
 {
   unsigned long h = 0;
   while (*s)
-    h = (h << 5) + h + (unsigned char)*s++;
+    h = CHAR_HASH(h, *s++);
   return h;
 }
 
@@ -5405,31 +5511,38 @@ lookup(HASH_TABLE *table, KEY name, size_t createSize)
   size_t i;
   if (table->size == 0) {
     size_t tsize;
-
     if (!createSize)
       return NULL;
-    tsize = INIT_SIZE * sizeof(NAMED *);
+    table->power = INIT_POWER;
+    /* table->size is a power of 2 */
+    table->size = (size_t)1 << INIT_POWER;
+    tsize = table->size * sizeof(NAMED *);
     table->v = (NAMED **)table->mem->malloc_fcn(tsize);
     if (!table->v)
       return NULL;
     memset(table->v, 0, tsize);
-    table->size = INIT_SIZE;
-    table->usedLim = INIT_SIZE / 2;
-    i = hash(name) & (table->size - 1);
+    i = hash(name) & ((unsigned long)table->size - 1);
   }
   else {
     unsigned long h = hash(name);
-    for (i = h & (table->size - 1);
-         table->v[i];
-         i == 0 ? i = table->size - 1 : --i) {
+    unsigned long mask = (unsigned long)table->size - 1;
+    unsigned char step = 0;
+    i = h & mask;
+    while (table->v[i]) {
       if (keyeq(name, table->v[i]->name))
         return table->v[i];
+      if (!step)
+        step = PROBE_STEP(h, mask, table->power);
+      i < step ? (i += table->size - step) : (i -= step);
     }
     if (!createSize)
       return NULL;
-    if (table->used == table->usedLim) {
-      /* check for overflow */
-      size_t newSize = table->size * 2;
+
+    /* check for overflow (table is half full) */
+    if (table->used >> (table->power - 1)) {
+      unsigned char newPower = table->power + 1;
+      size_t newSize = (size_t)1 << newPower;
+      unsigned long newMask = (unsigned long)newSize - 1;
       size_t tsize = newSize * sizeof(NAMED *);
       NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize);
       if (!newV)
@@ -5437,21 +5550,27 @@ lookup(HASH_TABLE *table, KEY name, size_t createSize)
       memset(newV, 0, tsize);
       for (i = 0; i < table->size; i++)
         if (table->v[i]) {
-          size_t j;
-          for (j = hash(table->v[i]->name) & (newSize - 1);
-               newV[j];
-               j == 0 ? j = newSize - 1 : --j)
-            ;
+          unsigned long newHash = hash(table->v[i]->name);
+          size_t j = newHash & newMask;
+          step = 0;
+          while (newV[j]) {
+            if (!step)
+              step = PROBE_STEP(newHash, newMask, newPower);
+            j < step ? (j += newSize - step) : (j -= step);
+          }
           newV[j] = table->v[i];
         }
       table->mem->free_fcn(table->v);
       table->v = newV;
+      table->power = newPower;
       table->size = newSize;
-      table->usedLim = newSize/2;
-      for (i = h & (table->size - 1);
-           table->v[i];
-           i == 0 ? i = table->size - 1 : --i)
-        ;
+      i = h & newMask;
+      step = 0;
+      while (table->v[i]) {
+        if (!step)
+          step = PROBE_STEP(h, newMask, newPower);
+        i < step ? (i += newSize - step) : (i -= step);
+      }
     }
   }
   table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize);
@@ -5468,13 +5587,9 @@ hashTableClear(HASH_TABLE *table)
 {
   size_t i;
   for (i = 0; i < table->size; i++) {
-    NAMED *p = table->v[i];
-    if (p) {
-      table->mem->free_fcn(p);
-      table->v[i] = NULL;
-    }
+    table->mem->free_fcn(table->v[i]);
+    table->v[i] = NULL;
   }
-  table->usedLim = table->size / 2;
   table->used = 0;
 }
 
@@ -5483,21 +5598,17 @@ static void FASTCALL
 hashTableDestroy(HASH_TABLE *table)
 {
   size_t i;
-  for (i = 0; i < table->size; i++) {
-    NAMED *p = table->v[i];
-    if (p)
-      table->mem->free_fcn(p);
-  }
-  if (table->v)
-    table->mem->free_fcn(table->v);
+  for (i = 0; i < table->size; i++)
+    table->mem->free_fcn(table->v[i]);
+  table->mem->free_fcn(table->v);
 }
 /*@=mustmod@*/
 
 static void FASTCALL
 hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms)
 {
+  p->power = 0;
   p->size = 0;
-  p->usedLim = 0;
   p->used = 0;
   p->v = NULL;
   p->mem = ms;
@@ -5666,8 +5777,8 @@ poolGrow(STRING_POOL *pool)
     int blockSize = (pool->end - pool->start)*2;
     pool->blocks = (BLOCK *)
       pool->mem->realloc_fcn(pool->blocks,
-                            (offsetof(BLOCK, s)
-                             + blockSize * sizeof(XML_Char)));
+                             (offsetof(BLOCK, s)
+                              + blockSize * sizeof(XML_Char)));
     if (pool->blocks == NULL)
       return XML_FALSE;
     pool->blocks->size = blockSize;
@@ -5683,7 +5794,7 @@ poolGrow(STRING_POOL *pool)
     else
       blockSize *= 2;
     tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s)
-                                       + blockSize * sizeof(XML_Char));
+                                        + blockSize * sizeof(XML_Char));
     if (!tem)
       return XML_FALSE;
     tem->size = blockSize;
@@ -5753,7 +5864,6 @@ build_node(XML_Parser parser,
            XML_Content *dest,
            XML_Content **contpos,
            XML_Char **strpos)
-       /*@modifies dest, *contpos, *strpos @*/
 {
   DTD * const dtd = _dtd;  /* save one level of indirection */
   dest->type = dtd->scaffold[src_node].type;
index be5a03c..a21c251 100644 (file)
@@ -7,7 +7,9 @@
 #elif defined(MACOS_CLASSIC)
 #include "macconfig.h"
 #else
-#include <expat_config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #endif /* ndef COMPILED_FROM_DSP */
 
 #include "internal.h"
index 778c299..720b475 100644 (file)
@@ -100,10 +100,10 @@ typedef struct prolog_state {
 #endif /* XML_DTD */
 } PROLOG_STATE;
 
-void XmlPrologStateInit(PROLOG_STATE *state)
+void XmlPrologStateInit(PROLOG_STATE *)
        /*@modifies state @*/;
 #ifdef XML_DTD
-void XmlPrologStateInitExternalEntity(PROLOG_STATE *state)
+void XmlPrologStateInitExternalEntity(PROLOG_STATE *)
        /*@modifies state @*/;
 #endif /* XML_DTD */
 
index 4039811..5916191 100644 (file)
@@ -7,7 +7,9 @@
 #elif defined(MACOS_CLASSIC)
 #include "macconfig.h"
 #else
-#include <expat_config.h>
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 #endif /* ndef COMPILED_FROM_DSP */
 
 #include "internal.h"
@@ -290,6 +292,7 @@ sb_byteToAscii(const ENCODING *enc, const char *p)
  (AS_NORMAL_ENCODING(enc)->charMatches(enc, p, c))
 static int PTRCALL
 sb_charMatches(const ENCODING *enc, const char *p, int c)
+       /*@*/
 {
   return *p == c;
 }
@@ -322,7 +325,6 @@ static void PTRCALL
 utf8_toUtf8(const ENCODING *enc,
             const char **fromP, const char *fromLim,
             char **toP, const char *toLim)
-       /*@modifies *fromP, *toP @*/
 {
   char *to;
   const char *from;
@@ -342,7 +344,6 @@ static void PTRCALL
 utf8_toUtf16(const ENCODING *enc,
              const char **fromP, const char *fromLim,
              unsigned short **toP, const unsigned short *toLim)
-       /*@modifies *fromP, *toP @*/
 {
   unsigned short *to = *toP;
   const char *from = *fromP;
@@ -733,6 +734,7 @@ little2_isNmstrtMin(const ENCODING *enc, const char *p)
 
 #ifdef XML_NS
 
+/*@unchecked@*/ /*@observer@*/
 static const struct normal_encoding little2_encoding_ns = {
   { VTABLE, 2, 0,
 #if BYTEORDER == 1234
@@ -821,7 +823,6 @@ big2_byteType(const ENCODING *enc, const char *p)
 
 static int PTRFASTCALL
 big2_byteToAscii(const ENCODING *enc, const char *p)
-       /*@*/
 {
   return BIG2_BYTE_TO_ASCII(enc, p);
 }
@@ -1133,6 +1134,7 @@ doParseXmlDecl(const ENCODING *(*encodingFinder)(const ENCODING *,
                /*@null@*/ int *standalone)
        /*@modifies ptr, *badPtr, *versionPtr, *versionEndPtr,
                *encodingName, *encoding, *standalone @*/
+
 {
   const char *val = NULL;
   const char *name = NULL;
@@ -1517,7 +1519,6 @@ static int FASTCALL
 getEncodingIndex(/*@null@*/ const char *name)
        /*@*/
 {
-  /*@unchecked@*/ /*@observer@*/
   static const char *encodingNames[] = {
     KW_ISO_8859_1,
     KW_US_ASCII,
@@ -1552,12 +1553,11 @@ getEncodingIndex(/*@null@*/ const char *name)
 
 static int
 initScan(const ENCODING **encodingTable,
-               const INIT_ENCODING *enc,
-               int state,
-               const char *ptr,
-               const char *end,
-               const char **nextTokPtr)
-       /*@modifies enc, *nextTokPtr @*/
+         const INIT_ENCODING *enc,
+         int state,
+         const char *ptr,
+         const char *end,
+         const char **nextTokPtr)
 {
   const ENCODING **encPtr;
 
index 245d8e9..dac77b5 100644 (file)
@@ -152,7 +152,8 @@ struct encoding {
                          int attsMax,
                          ATTRIBUTE *atts)
        /*@*/;
-  int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr);
+  int (PTRFASTCALL *charRefNumber)(const ENCODING *enc, const char *ptr)
+       /*@*/;
   int (PTRCALL *predefinedEntityName)(const ENCODING *,
                                       const char *,
                                       const char *)
@@ -283,26 +284,25 @@ int XmlParseXmlDecl(int isGeneralTextEntity,
                     const char **versionEndPtr,
                     const char **encodingNamePtr,
                     const ENCODING **namedEncodingPtr,
-                    int *standalonePtr);
+                    int *standalonePtr)
+       /*@*/;
 
-int XmlInitEncoding(INIT_ENCODING *p, const ENCODING **encPtr,
-               /*@null@*/ const char *name)
+int XmlInitEncoding(INIT_ENCODING *, const ENCODING **, const char *name)
        /*@modifies p, *encPtr @*/;
 const ENCODING *XmlGetUtf8InternalEncoding(void)
        /*@*/;
 const ENCODING *XmlGetUtf16InternalEncoding(void)
        /*@*/;
 int FASTCALL XmlUtf8Encode(int charNumber, char *buf)
-       /*@modifies buf @*/;
+       /*@*/;
 int FASTCALL XmlUtf16Encode(int charNumber, unsigned short *buf)
-       /*@modifies buf @*/;
+       /*@*/;
 int XmlSizeOfUnknownEncoding(void)
        /*@*/;
 
 typedef int (*CONVERTER)(void *userData, const char *p)
        /*@*/;
 
-/*@null@*/
 ENCODING *
 XmlInitUnknownEncoding(void *mem,
                        int *table,
@@ -333,8 +333,7 @@ ENCODING *
 XmlInitUnknownEncodingNS(void *mem,
                          int *table,
                          CONVERTER convert,
-                         void *userData)
-       /*@modifies mem @*/;
+                         void *userData);
 #ifdef __cplusplus
 }
 #endif
index 0fe5f19..9aaaadd 100644 (file)
@@ -580,7 +580,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
           return XML_TOK_INVALID;
         }
       }
-      /*@fallthrough@*/
+    /*@fallthrough@*/
     case BT_EQUALS:
       {
         int open;
@@ -898,7 +898,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
        /*@modifies *nextTokPtr @*/
 {
   if (ptr == end)
-    return XML_TOK_PARTIAL;
+    return -XML_TOK_PERCENT;
   switch (BYTE_TYPE(enc, ptr)) {
   CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
   case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
@@ -1427,7 +1427,6 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
     case BT_NMSTRT:
       if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f))
         break;
-      /*@fallthrough@*/
     default:
       switch (BYTE_TO_ASCII(enc, ptr)) {
       case 0x24: /* $ */
@@ -1448,7 +1447,6 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
    first attsMax attributes are stored in atts.
 */
 
-/*@-mods@*/
 static int PTRCALL
 PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
                 int attsMax, ATTRIBUTE *atts)
@@ -1542,7 +1540,6 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
   }
   /*@notreached@*/
 }
-/*@=mods@*/
 
 static int PTRFASTCALL
 PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
@@ -1656,7 +1653,7 @@ PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
         return 0;
     LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2)
 #undef LEAD_CASE
-      /* fall through */
+      /*@fallthrough@*/
       if (*ptr1++ != *ptr2++)
         return 0;
       break;
index c561d91..ebc5a7b 100644 (file)
@@ -11,3 +11,7 @@ LDADD = $(top_builddir)/lib/libexpat.la
 noinst_HEADERS = chardata.h
 
 runtests_SOURCES = chardata.c runtests.c
+runtests_LDFLAGGS = -all-static
+runtests_LDADD = $(LDADD) -lcheck
+
+all: runtests
index 4a228a7..4b7edd6 100644 (file)
@@ -1,7 +1,17 @@
-/*  chardata.c
- *
- *
- */
+/* Copyright (c) 1998-2003 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+
+   chardata.c
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#ifdef HAVE_CHECK_H
+#include <check.h>
+#else
+#error This test suite requires the 'check' unit test framework (http://check.sf.net/)
+#endif
 
 #include <assert.h>
 #include <check.h>
index 54ce61f..5ab1034 100644 (file)
@@ -1,5 +1,20 @@
-#include <assert.h>
+/* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
+   See the file COPYING for copying permission.
+
+   runtest.c : run the Expat test suite
+*/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_CHECK_H
 #include <check.h>
+#else
+#error This test suite requires the 'check' unit test framework (http://check.sf.net/)
+#endif
+
+#include <assert.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -40,11 +55,91 @@ _xml_failure(XML_Parser parser, const char *file, int line)
             XML_GetCurrentLineNumber(parser),
             XML_GetCurrentColumnNumber(parser),
             file, line);
-    fail(buffer);
+    _fail_unless(0, file, line, buffer);
 }
 
 #define xml_failure(parser) _xml_failure((parser), __FILE__, __LINE__)
 
+static void
+_expect_failure(char *text, enum XML_Error errorCode, char *errorMessage,
+                char *file, int lineno)
+{
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_OK)
+        /* Hackish use of _fail_unless() macro, but let's us report
+           the right filename and line number. */
+        _fail_unless(0, file, lineno, errorMessage);
+    if (XML_GetErrorCode(parser) != errorCode)
+        _xml_failure(parser, file, lineno);
+}
+
+#define expect_failure(text, errorCode, errorMessage) \
+        _expect_failure((text), (errorCode), (errorMessage), \
+                        __FILE__, __LINE__)
+
+/* Dummy handlers for when we need to set a handler to tickle a bug,
+   but it doesn't need to do anything.
+*/
+
+static void XMLCALL
+dummy_start_doctype_handler(void           *userData,
+                            const XML_Char *doctypeName,
+                            const XML_Char *sysid,
+                            const XML_Char *pubid,
+                            int            has_internal_subset)
+{}
+
+static void XMLCALL
+dummy_end_doctype_handler(void *userData)
+{}
+
+static void XMLCALL
+dummy_entity_decl_handler(void           *userData,
+                          const XML_Char *entityName,
+                          int            is_parameter_entity,
+                          const XML_Char *value,
+                          int            value_length,
+                          const XML_Char *base,
+                          const XML_Char *systemId,
+                          const XML_Char *publicId,
+                          const XML_Char *notationName)
+{}
+
+static void XMLCALL
+dummy_notation_decl_handler(void *userData,
+                            const XML_Char *notationName,
+                            const XML_Char *base,
+                            const XML_Char *systemId,
+                            const XML_Char *publicId)
+{}
+
+static void XMLCALL
+dummy_element_decl_handler(void *userData,
+                           const XML_Char *name,
+                           XML_Content *model)
+{}
+
+static void XMLCALL
+dummy_attlist_decl_handler(void           *userData,
+                           const XML_Char *elname,
+                           const XML_Char *attname,
+                           const XML_Char *att_type,
+                           const XML_Char *dflt,
+                           int            isrequired)
+{}
+
+static void XMLCALL
+dummy_comment_handler(void *userData, const XML_Char *data)
+{}
+
+static void XMLCALL
+dummy_pi_handler(void *userData, const XML_Char *target, const XML_Char *data)
+{}
+
+static void XMLCALL
+dummy_start_element(void *userData,
+                    const XML_Char *name, const XML_Char **atts)
+{}
+
 
 /*
  * Character & encoding tests.
@@ -55,7 +150,7 @@ START_TEST(test_nul_byte)
     char text[] = "<doc>\0</doc>";
 
     /* test that a NUL byte (in US-ASCII data) is an error */
-    if (XML_Parse(parser, text, sizeof(text) - 1, 1))
+    if (XML_Parse(parser, text, sizeof(text) - 1, XML_TRUE) == XML_STATUS_OK)
         fail("Parser did not report error on NUL-byte.");
     if (XML_GetErrorCode(parser) != XML_ERROR_INVALID_TOKEN)
         xml_failure(parser);
@@ -65,13 +160,10 @@ END_TEST
 
 START_TEST(test_u0000_char)
 {
-    char *text = "<doc>&#0;</doc>";
-
     /* test that a NUL byte (in US-ASCII data) is an error */
-    if (XML_Parse(parser, text, strlen(text), 1))
-        fail("Parser did not report error on NUL-byte.");
-    if (XML_GetErrorCode(parser) != XML_ERROR_BAD_CHAR_REF)
-        xml_failure(parser);
+    expect_failure("<doc>&#0;</doc>",
+                   XML_ERROR_BAD_CHAR_REF,
+                   "Parser did not report error on NUL-byte.");
 }
 END_TEST
 
@@ -80,7 +172,7 @@ START_TEST(test_bom_utf8)
     /* This test is really just making sure we don't core on a UTF-8 BOM. */
     char *text = "\357\273\277<e/>";
 
-    if (!XML_Parse(parser, text, strlen(text), 1))
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
 }
 END_TEST
@@ -89,7 +181,7 @@ START_TEST(test_bom_utf16_be)
 {
     char text[] = "\376\377\0<\0e\0/\0>";
 
-    if (!XML_Parse(parser, text, sizeof(text) - 1, 1))
+    if (XML_Parse(parser, text, sizeof(text)-1, XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
 }
 END_TEST
@@ -98,18 +190,18 @@ START_TEST(test_bom_utf16_le)
 {
     char text[] = "\377\376<\0e\0/\0>\0";
 
-    if (!XML_Parse(parser, text, sizeof(text) - 1, 1))
+    if (XML_Parse(parser, text, sizeof(text)-1, XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
 }
 END_TEST
 
-static void
+static void XMLCALL
 accumulate_characters(void *userData, const XML_Char *s, int len)
 {
     CharData_AppendXMLChars((CharData *)userData, s, len);
 }
 
-static void
+static void XMLCALL
 accumulate_attribute(void *userData, const XML_Char *name,
                      const XML_Char **atts)
 {
@@ -122,31 +214,39 @@ accumulate_attribute(void *userData, const XML_Char *name,
 
 
 static void
-run_character_check(XML_Char *text, XML_Char *expected)
+_run_character_check(XML_Char *text, XML_Char *expected,
+                     const char *file, int line)
 {
     CharData storage;
 
     CharData_Init(&storage);
     XML_SetUserData(parser, &storage);
     XML_SetCharacterDataHandler(parser, accumulate_characters);
-    if (!XML_Parse(parser, text, strlen(text), 1))
-        xml_failure(parser);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        _xml_failure(parser, file, line);
     CharData_CheckXMLChars(&storage, expected);
 }
 
+#define run_character_check(text, expected) \
+        _run_character_check(text, expected, __FILE__, __LINE__)
+
 static void
-run_attribute_check(XML_Char *text, XML_Char *expected)
+_run_attribute_check(XML_Char *text, XML_Char *expected,
+                     const char *file, int line)
 {
     CharData storage;
 
     CharData_Init(&storage);
     XML_SetUserData(parser, &storage);
     XML_SetStartElementHandler(parser, accumulate_attribute);
-    if (!XML_Parse(parser, text, strlen(text), 1))
-        xml_failure(parser);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        _xml_failure(parser, file, line);
     CharData_CheckXMLChars(&storage, expected);
 }
 
+#define run_attribute_check(text, expected) \
+        _run_attribute_check(text, expected, __FILE__, __LINE__)
+
 /* Regression test for SF bug #491986. */
 START_TEST(test_danish_latin1)
 {
@@ -157,7 +257,6 @@ START_TEST(test_danish_latin1)
              "J\xC3\xB8rgen \xC3\xA6\xC3\xB8\xC3\xA5\xC3\x86\xC3\x98\xC3\x85");
 }
 END_TEST
-/* End regression test for SF bug #491986. */
 
 
 /* Regression test for SF bug #514281. */
@@ -199,7 +298,18 @@ START_TEST(test_french_utf8)
     run_character_check(text, "\xC3\xA9");
 }
 END_TEST
-/* End regression test for SF bug #514281. */
+
+/* Regression test for SF bug #600479.
+   XXX There should be a test that exercises all legal XML Unicode
+   characters as PCDATA and attribute value content, and XML Name
+   characters as part of element and attribute names.
+*/
+START_TEST(test_utf8_false_rejection)
+{
+    char *text = "<doc>\xEF\xBA\xBF</doc>";
+    run_character_check(text, "\xEF\xBA\xBF");
+}
+END_TEST
 
 /* Regression test for SF bug #477667.
    This test assures that any 8-bit character followed by a 7-bit
@@ -213,7 +323,7 @@ START_TEST(test_illegal_utf8)
 
     for (i = 128; i <= 255; ++i) {
         sprintf(text, "<e>%ccd</e>", i);
-        if (XML_Parse(parser, text, strlen(text), 1)) {
+        if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_OK) {
             sprintf(text,
                     "expected token error for '%c' (ordinal %d) in UTF-8 text",
                     i, i);
@@ -240,42 +350,161 @@ START_TEST(test_utf16)
         "\000<\000d\000o\000c\000 \000a\000=\000'\0001\0002\0003\000'"
         "\000>\000s\000o\000m\000e\000 \000t\000e\000x\000t\000<\000/"
         "\000d\000o\000c\000>";
-    if (!XML_Parse(parser, text, sizeof(text) - 1, 1))
+    if (XML_Parse(parser, text, sizeof(text)-1, XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+START_TEST(test_utf16_le_epilog_newline)
+{
+    int first_chunk_bytes = 17;
+    char text[] = 
+        "\xFF\xFE"                      /* BOM */
+        "<\000e\000/\000>\000"          /* document element */
+        "\r\000\n\000\r\000\n\000";     /* epilog */
+
+    if (first_chunk_bytes >= sizeof(text) - 1)
+        fail("bad value of first_chunk_bytes");
+    if (  XML_Parse(parser, text, first_chunk_bytes, XML_FALSE)
+          == XML_STATUS_ERROR)
         xml_failure(parser);
+    else {
+        enum XML_Status rc;
+        rc = XML_Parse(parser, text + first_chunk_bytes,
+                       sizeof(text) - first_chunk_bytes - 1, XML_TRUE);
+        if (rc == XML_STATUS_ERROR)
+            xml_failure(parser);
+    }
 }
 END_TEST
 
-/* Regression test for SF bug #481609. */
+/* Regression test for SF bug #481609, #774028. */
 START_TEST(test_latin1_umlauts)
 {
     char *text =
         "<?xml version='1.0' encoding='iso-8859-1'?>\n"
-        "<e a='ä ö ü &#228; &#246; &#252; &#x00E4; &#x0F6; &#xFC;'\n"
-        "  >ä ö ü &#228; &#246; &#252; &#x00E4; &#x0F6; &#xFC;</e>";
+        "<e a='ä ö ü &#228; &#246; &#252; &#x00E4; &#x0F6; &#xFC; >'\n"
+        "  >ä ö ü &#228; &#246; &#252; &#x00E4; &#x0F6; &#xFC; ></e>";
     char *utf8 =
         "\xC3\xA4 \xC3\xB6 \xC3\xBC "
         "\xC3\xA4 \xC3\xB6 \xC3\xBC "
-        "\xC3\xA4 \xC3\xB6 \xC3\xBC";
+        "\xC3\xA4 \xC3\xB6 \xC3\xBC >";
     run_character_check(text, utf8);
     XML_ParserReset(parser, NULL);
     run_attribute_check(text, utf8);
 }
 END_TEST
 
-/* Regression test for SF bug #422239 (maybe).
-   It's not clear that this reproduces enough of the context
-   of the reported bug.
-*/
-START_TEST(test_line_count)
-{
+/* Regression test #1 for SF bug #653180. */
+START_TEST(test_line_number_after_parse)
+{  
     char *text =
-        "<e>\n"
-        "  <e/>\n"
-        "</e>";
+        "<tag>\n"
+        "\n"
+        "\n</tag>";
     int lineno;
-    if (!XML_Parse(parser, text, strlen(text), 1))
+
+    if (XML_Parse(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR)
         xml_failure(parser);
     lineno = XML_GetCurrentLineNumber(parser);
+    if (lineno != 4) {
+        char buffer[100];
+        sprintf(buffer, "expected 4 lines, saw %d", lineno);
+        fail(buffer);
+    }
+}
+END_TEST
+
+/* Regression test #2 for SF bug #653180. */
+START_TEST(test_column_number_after_parse)
+{
+    char *text = "<tag></tag>";
+    int colno;
+
+    if (XML_Parse(parser, text, strlen(text), XML_FALSE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+    colno = XML_GetCurrentColumnNumber(parser);
+    if (colno != 11) {
+        char buffer[100];
+        sprintf(buffer, "expected 11 columns, saw %d", colno);
+        fail(buffer);
+    }
+}
+END_TEST
+
+static void XMLCALL
+start_element_event_handler2(void *userData, const XML_Char *name,
+                            const XML_Char **attr)
+{
+    CharData *storage = (CharData *) userData;
+    char buffer[100];
+
+    sprintf(buffer, "<%s> at col:%d line:%d\n", name,
+           XML_GetCurrentColumnNumber(parser),
+           XML_GetCurrentLineNumber(parser));
+    CharData_AppendString(storage, buffer);
+}
+
+static void XMLCALL
+end_element_event_handler2(void *userData, const XML_Char *name)
+{
+    CharData *storage = (CharData *) userData;
+    char buffer[100];
+
+    sprintf(buffer, "</%s> at col:%d line:%d\n", name,
+           XML_GetCurrentColumnNumber(parser),
+           XML_GetCurrentLineNumber(parser));
+    CharData_AppendString(storage, buffer);
+}
+
+/* Regression test #3 for SF bug #653180. */
+START_TEST(test_line_and_column_numbers_inside_handlers)
+{
+    char *text =
+        "<a>\n"        /* Unix end-of-line */
+        "  <b>\r\n"    /* Windows end-of-line */
+        "    <c/>\r"   /* Mac OS end-of-line */
+        "  </b>\n"
+        "  <d>\n"
+        "    <f/>\n"
+        "  </d>\n"
+        "</a>";
+    char *expected =
+        "<a> at col:0 line:1\n"
+        "<b> at col:2 line:2\n"
+        "<c> at col:4 line:3\n"
+        "</c> at col:8 line:3\n"
+        "</b> at col:2 line:4\n"
+        "<d> at col:2 line:5\n"
+        "<f> at col:4 line:6\n"
+        "</f> at col:8 line:6\n"
+        "</d> at col:2 line:7\n"
+        "</a> at col:0 line:8\n";
+    CharData storage;
+
+    CharData_Init(&storage);
+    XML_SetUserData(parser, &storage);
+    XML_SetStartElementHandler(parser, start_element_event_handler2);
+    XML_SetEndElementHandler(parser, end_element_event_handler2);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+
+    CharData_CheckString(&storage, expected); 
+}
+END_TEST
+
+/* Regression test #4 for SF bug #653180. */
+START_TEST(test_line_number_after_error)
+{
+    char *text =
+        "<a>\n"
+        "  <b>\n"
+        "  </a>";  /* missing </b> */
+    int lineno;
+    if (XML_Parse(parser, text, strlen(text), XML_FALSE) != XML_STATUS_ERROR)
+        fail("Expected a parse error");
+
+    lineno = XML_GetCurrentLineNumber(parser);
     if (lineno != 3) {
         char buffer[100];
         sprintf(buffer, "expected 3 lines, saw %d", lineno);
@@ -283,6 +512,26 @@ START_TEST(test_line_count)
     }
 }
 END_TEST
+    
+/* Regression test #5 for SF bug #653180. */
+START_TEST(test_column_number_after_error)
+{
+    char *text =
+        "<a>\n"
+        "  <b>\n"
+        "  </a>";  /* missing </b> */
+    int colno;
+    if (XML_Parse(parser, text, strlen(text), XML_FALSE) != XML_STATUS_ERROR)
+        fail("Expected a parse error");
+
+    colno = XML_GetCurrentColumnNumber(parser);
+    if (colno != 4) { 
+        char buffer[100];
+        sprintf(buffer, "expected 4 columns, saw %d", colno);
+        fail(buffer);
+    }
+}
+END_TEST
 
 /* Regression test for SF bug #478332. */
 START_TEST(test_really_long_lines)
@@ -314,7 +563,7 @@ START_TEST(test_really_long_lines)
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
         "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-+"
         "</e>";
-    if (!XML_Parse(parser, text, strlen(text), 1))
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
 }
 END_TEST
@@ -324,7 +573,7 @@ END_TEST
  * Element event tests.
  */
 
-static void
+static void XMLCALL
 end_element_event_handler(void *userData, const XML_Char *name)
 {
     CharData *storage = (CharData *) userData;
@@ -341,7 +590,7 @@ START_TEST(test_end_element_events)
     CharData_Init(&storage);
     XML_SetUserData(parser, &storage);
     XML_SetEndElementHandler(parser, end_element_event_handler);
-    if (!XML_Parse(parser, text, strlen(text), 1))
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
     CharData_CheckString(&storage, expected);
 }
@@ -414,8 +663,8 @@ testhelper_is_whitespace_normalized(void)
     assert(!is_whitespace_normalized("abc\t def", 1));
 }
 
-static void
-check_attr_contains_normalized_whitespace(void *userdata,
+static void XMLCALL
+check_attr_contains_normalized_whitespace(void *userData,
                                           const XML_Char *name,
                                           const XML_Char **atts)
 {
@@ -454,7 +703,7 @@ START_TEST(test_attr_whitespace_normalization)
 
     XML_SetStartElementHandler(parser,
                                check_attr_contains_normalized_whitespace);
-    if (!XML_Parse(parser, text, strlen(text), 1))
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
 }
 END_TEST
@@ -466,18 +715,240 @@ END_TEST
 
 START_TEST(test_xmldecl_misplaced)
 {
+    expect_failure("\n"
+                   "<?xml version='1.0'?>\n"
+                   "<a/>",
+                   XML_ERROR_MISPLACED_XML_PI,
+                   "failed to report misplaced XML declaration");
+}
+END_TEST
+
+/* Regression test for SF bug #584832. */
+static int XMLCALL
+UnknownEncodingHandler(void *data,const XML_Char *encoding,XML_Encoding *info)
+{
+    if (strcmp(encoding,"unsupported-encoding") == 0) {
+        int i;
+        for (i = 0; i < 256; ++i)
+            info->map[i] = i;
+        info->data = NULL;
+        info->convert = NULL;
+        info->release = NULL;
+        return XML_STATUS_OK;
+    }
+    return XML_STATUS_ERROR;
+}
+
+START_TEST(test_unknown_encoding_internal_entity)
+{
     char *text =
-        "\n"
-        "<?xml version='1.0'?>\n"
-        "<a>&eee;</a>";
+        "<?xml version='1.0' encoding='unsupported-encoding'?>\n"
+        "<!DOCTYPE test [<!ENTITY foo 'bar'>]>\n"
+        "<test a='&foo;'/>";
 
-    if (!XML_Parse(parser, text, strlen(text), 1)) {
-        if (XML_GetErrorCode(parser) != XML_ERROR_MISPLACED_XML_PI)
-            xml_failure(parser);
+    XML_SetUnknownEncodingHandler(parser, UnknownEncodingHandler, NULL);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+/* Regression test for SF bug #620106. */
+static int XMLCALL
+external_entity_loader_set_encoding(XML_Parser parser,
+                                    const XML_Char *context,
+                                    const XML_Char *base,
+                                    const XML_Char *systemId,
+                                    const XML_Char *publicId)
+{
+    /* This text says it's an unsupported encoding, but it's really
+       UTF-8, which we tell Expat using XML_SetEncoding().
+    */
+    char *text =
+        "<?xml encoding='iso-8859-3'?>"
+        "\xC3\xA9";
+    XML_Parser extparser;
+
+    extparser = XML_ExternalEntityParserCreate(parser, context, NULL);
+    if (extparser == NULL)
+        fail("Could not create external entity parser.");
+    if (!XML_SetEncoding(extparser, "utf-8"))
+        fail("XML_SetEncoding() ignored for external entity");
+    if (  XML_Parse(extparser, text, strlen(text), XML_TRUE)
+          == XML_STATUS_ERROR) {
+        xml_failure(parser);
+        return 0;
     }
-    else {
-        fail("expected XML_ERROR_MISPLACED_XML_PI with misplaced XML decl");
+    return 1;
+}
+
+START_TEST(test_ext_entity_set_encoding)
+{
+    char *text =
+        "<!DOCTYPE doc [\n"
+        "  <!ENTITY en SYSTEM 'http://xml.libexpat.org/dummy.ent'>\n"
+        "]>\n"
+        "<doc>&en;</doc>";
+
+    XML_SetExternalEntityRefHandler(parser,
+                                    external_entity_loader_set_encoding);
+    run_character_check(text, "\xC3\xA9");
+}
+END_TEST
+
+/* Test that no error is reported for unknown entities if we don't
+   read an external subset.  This was fixed in Expat 1.95.5.
+*/
+START_TEST(test_wfc_undeclared_entity_unread_external_subset) {
+    char *text =
+        "<!DOCTYPE doc SYSTEM 'foo'>\n"
+        "<doc>&entity;</doc>";
+
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+/* Test that an error is reported for unknown entities if we don't
+   have an external subset.
+*/
+START_TEST(test_wfc_undeclared_entity_no_external_subset) {
+    expect_failure("<doc>&entity;</doc>",
+                   XML_ERROR_UNDEFINED_ENTITY,
+                   "Parser did not report undefined entity w/out a DTD.");
+}
+END_TEST
+
+/* Test that an error is reported for unknown entities if we don't
+   read an external subset, but have been declared standalone.
+*/
+START_TEST(test_wfc_undeclared_entity_standalone) {
+    char *text =
+        "<?xml version='1.0' encoding='us-ascii' standalone='yes'?>\n"
+        "<!DOCTYPE doc SYSTEM 'foo'>\n"
+        "<doc>&entity;</doc>";
+
+    expect_failure(text,
+                   XML_ERROR_UNDEFINED_ENTITY,
+                   "Parser did not report undefined entity (standalone).");
+}
+END_TEST
+
+static int XMLCALL
+external_entity_loader(XML_Parser parser,
+                       const XML_Char *context,
+                       const XML_Char *base,
+                       const XML_Char *systemId,
+                       const XML_Char *publicId)
+{
+    char *text = (char *)XML_GetUserData(parser);
+    XML_Parser extparser;
+
+    extparser = XML_ExternalEntityParserCreate(parser, context, NULL);
+    if (extparser == NULL)
+        fail("Could not create external entity parser.");
+    if (  XML_Parse(extparser, text, strlen(text), XML_TRUE)
+          == XML_STATUS_ERROR) {
+        xml_failure(parser);
+        return XML_STATUS_ERROR;
     }
+    return XML_STATUS_OK;
+}
+
+/* Test that an error is reported for unknown entities if we have read
+   an external subset, and standalone is true.
+*/
+START_TEST(test_wfc_undeclared_entity_with_external_subset_standalone) {
+    char *text =
+        "<?xml version='1.0' encoding='us-ascii' standalone='yes'?>\n"
+        "<!DOCTYPE doc SYSTEM 'foo'>\n"
+        "<doc>&entity;</doc>";
+    char *foo_text =
+        "<!ELEMENT doc (#PCDATA)*>";
+
+    XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+    XML_SetUserData(parser, foo_text);
+    XML_SetExternalEntityRefHandler(parser, external_entity_loader);
+    expect_failure(text,
+                   XML_ERROR_UNDEFINED_ENTITY,
+                   "Parser did not report undefined entity (external DTD).");
+}
+END_TEST
+
+/* Test that no error is reported for unknown entities if we have read
+   an external subset, and standalone is false.
+*/
+START_TEST(test_wfc_undeclared_entity_with_external_subset) {
+    char *text =
+        "<?xml version='1.0' encoding='us-ascii'?>\n"
+        "<!DOCTYPE doc SYSTEM 'foo'>\n"
+        "<doc>&entity;</doc>";
+    char *foo_text =
+        "<!ELEMENT doc (#PCDATA)*>";
+
+    XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+    XML_SetUserData(parser, foo_text);
+    XML_SetExternalEntityRefHandler(parser, external_entity_loader);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+START_TEST(test_wfc_no_recursive_entity_refs)
+{
+    char *text =
+        "<!DOCTYPE doc [\n"
+        "  <!ENTITY entity '&#38;entity;'>\n"
+        "]>\n"
+        "<doc>&entity;</doc>";
+
+    expect_failure(text,
+                   XML_ERROR_RECURSIVE_ENTITY_REF,
+                   "Parser did not report recursive entity reference.");
+}
+END_TEST
+
+/* Regression test for SF bug #483514. */
+START_TEST(test_dtd_default_handling)
+{
+    char *text =
+        "<!DOCTYPE doc [\n"
+        "<!ENTITY e SYSTEM 'http://xml.libexpat.org/e'>\n"
+        "<!NOTATION n SYSTEM 'http://xml.libexpat.org/n'>\n"
+        "<!ELEMENT doc EMPTY>\n"
+        "<!ATTLIST doc a CDATA #IMPLIED>\n"
+        "<?pi in dtd?>\n"
+        "<!--comment in dtd-->\n"
+        "]><doc/>";
+
+    XML_SetDefaultHandler(parser, accumulate_characters);
+    XML_SetDoctypeDeclHandler(parser,
+                              dummy_start_doctype_handler,
+                              dummy_end_doctype_handler);
+    XML_SetEntityDeclHandler(parser, dummy_entity_decl_handler);
+    XML_SetNotationDeclHandler(parser, dummy_notation_decl_handler);
+    XML_SetElementDeclHandler(parser, dummy_element_decl_handler);
+    XML_SetAttlistDeclHandler(parser, dummy_attlist_decl_handler);
+    XML_SetProcessingInstructionHandler(parser, dummy_pi_handler);
+    XML_SetCommentHandler(parser, dummy_comment_handler);
+    run_character_check(text, "\n\n\n\n\n\n\n<doc/>");
+}
+END_TEST
+
+/* See related SF bug #673791.
+   When namespace processing is enabled, setting the namespace URI for
+   a prefix is not allowed; this test ensures that it *is* allowed
+   when namespace processing is not enabled.
+   (See Namespaces in XML, section 2.)
+*/
+START_TEST(test_empty_ns_without_namespaces)
+{
+    char *text =
+        "<doc xmlns:prefix='http://www.example.com/'>\n"
+        "  <e xmlns:prefix=''/>\n"
+        "</doc>";
+
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
 }
 END_TEST
 
@@ -505,7 +976,7 @@ namespace_teardown(void)
    provided as the userData argument; the first is the expected
    element name, and the second is the expected attribute name.
 */
-static void
+static void XMLCALL
 triplet_start_checker(void *userData, const XML_Char *name,
                       const XML_Char **atts)
 {
@@ -525,7 +996,7 @@ triplet_start_checker(void *userData, const XML_Char *name,
    the expected value.  The expected value is passed as the first element
    in an array of strings passed as the userData argument.
 */
-static void
+static void XMLCALL
 triplet_end_checker(void *userData, const XML_Char *name)
 {
     char **elemstr = (char **)userData;
@@ -545,15 +1016,15 @@ START_TEST(test_return_ns_triplet)
         "http://expat.sf.net/ e foo",
         "http://expat.sf.net/ a bar"
     };
-    XML_SetReturnNSTriplet(parser, 1);
+    XML_SetReturnNSTriplet(parser, XML_TRUE);
     XML_SetUserData(parser, elemstr);
     XML_SetElementHandler(parser, triplet_start_checker, triplet_end_checker);
-    if (!XML_Parse(parser, text, strlen(text), 1))
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
 }
 END_TEST
 
-static void
+static void XMLCALL
 overwrite_start_checker(void *userData, const XML_Char *name,
                         const XML_Char **atts)
 {
@@ -568,7 +1039,7 @@ overwrite_start_checker(void *userData, const XML_Char *name,
     CharData_AppendString(storage, "\n");
 }
 
-static void
+static void XMLCALL
 overwrite_end_checker(void *userData, const XML_Char *name)
 {
     CharData *storage = (CharData *) userData;
@@ -585,7 +1056,7 @@ run_ns_tagname_overwrite_test(char *text, char *result)
     XML_SetUserData(parser, &storage);
     XML_SetElementHandler(parser,
                           overwrite_start_checker, overwrite_end_checker);
-    if (!XML_Parse(parser, text, strlen(text), 1))
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
         xml_failure(parser);
     CharData_CheckString(&storage, result);
 }
@@ -628,52 +1099,256 @@ START_TEST(test_ns_tagname_overwrite_triplet)
         "attribute http://xml.libexpat.org/ attr2 n\n"
         "end http://xml.libexpat.org/ g n\n"
         "end http://xml.libexpat.org/ e n\n";
-    XML_SetReturnNSTriplet(parser, 1);
+    XML_SetReturnNSTriplet(parser, XML_TRUE);
     run_ns_tagname_overwrite_test(text, result);
 }
 END_TEST
 
+
+/* Regression test for SF bug #620343. */
+static void XMLCALL
+start_element_fail(void *userData,
+                   const XML_Char *name, const XML_Char **atts)
+{
+    /* We should never get here. */
+    fail("should never reach start_element_fail()");
+}
+
+static void XMLCALL
+start_ns_clearing_start_element(void *userData,
+                                const XML_Char *prefix,
+                                const XML_Char *uri)
+{
+    XML_SetStartElementHandler((XML_Parser) userData, NULL);
+}
+
+START_TEST(test_start_ns_clears_start_element)
+{
+    /* This needs to use separate start/end tags; using the empty tag
+       syntax doesn't cause the problematic path through Expat to be
+       taken.
+    */
+    char *text = "<e xmlns='http://xml.libexpat.org/'></e>";
+
+    XML_SetStartElementHandler(parser, start_element_fail);
+    XML_SetStartNamespaceDeclHandler(parser, start_ns_clearing_start_element);
+    XML_UseParserAsHandlerArg(parser);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+/* Regression test for SF bug #616863. */
+static int XMLCALL
+external_entity_handler(XML_Parser parser,
+                        const XML_Char *context,
+                        const XML_Char *base,
+                        const XML_Char *systemId,
+                        const XML_Char *publicId) 
+{
+    int callno = 1 + (int)XML_GetUserData(parser);
+    char *text;
+    XML_Parser p2;
+
+    if (callno == 1)
+        text = ("<!ELEMENT doc (e+)>\n"
+                "<!ATTLIST doc xmlns CDATA #IMPLIED>\n"
+                "<!ELEMENT e EMPTY>\n");
+    else
+        text = ("<?xml version='1.0' encoding='us-ascii'?>"
+                "<e/>");
+
+    XML_SetUserData(parser, (void *) callno);
+    p2 = XML_ExternalEntityParserCreate(parser, context, NULL);
+    if (XML_Parse(p2, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR) {
+        xml_failure(p2);
+        return 0;
+    }
+    XML_ParserFree(p2);
+    return 1;
+}
+
+START_TEST(test_default_ns_from_ext_subset_and_ext_ge)
+{
+    char *text =
+        "<?xml version='1.0'?>\n"
+        "<!DOCTYPE doc SYSTEM 'http://xml.libexpat.org/doc.dtd' [\n"
+        "  <!ENTITY en SYSTEM 'http://xml.libexpat.org/entity.ent'>\n"
+        "]>\n"
+        "<doc xmlns='http://xml.libexpat.org/ns1'>\n"
+        "&en;\n"
+        "</doc>";
+
+    XML_SetParamEntityParsing(parser, XML_PARAM_ENTITY_PARSING_ALWAYS);
+    XML_SetExternalEntityRefHandler(parser, external_entity_handler);
+    /* We actually need to set this handler to tickle this bug. */
+    XML_SetStartElementHandler(parser, dummy_start_element);
+    XML_SetUserData(parser, NULL);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+/* Regression test #1 for SF bug #673791. */
+START_TEST(test_ns_prefix_with_empty_uri_1)
+{
+    char *text =
+        "<doc xmlns:prefix='http://xml.libexpat.org/'>\n"
+        "  <e xmlns:prefix=''/>\n"
+        "</doc>";
+
+    expect_failure(text,
+                   XML_ERROR_SYNTAX,
+                   "Did not report re-setting namespace"
+                   " URI with prefix to ''.");
+}
+END_TEST
+
+/* Regression test #2 for SF bug #673791. */
+START_TEST(test_ns_prefix_with_empty_uri_2)
+{
+    char *text =
+        "<?xml version='1.0'?>\n"
+        "<docelem xmlns:pre=''/>";
+
+    expect_failure(text,
+                   XML_ERROR_SYNTAX,
+                   "Did not report setting namespace URI with prefix to ''.");
+}
+END_TEST
+
+/* Regression test #3 for SF bug #673791. */
+START_TEST(test_ns_prefix_with_empty_uri_3)
+{
+    char *text =
+        "<!DOCTYPE doc [\n"
+        "  <!ELEMENT doc EMPTY>\n"
+        "  <!ATTLIST doc\n"
+        "    xmlns:prefix CDATA ''>\n"
+        "]>\n"
+        "<doc/>";
+
+    expect_failure(text,
+                   XML_ERROR_SYNTAX,
+                   "Didn't report attr default setting NS w/ prefix to ''.");
+}
+END_TEST
+
+/* Regression test #4 for SF bug #673791. */
+START_TEST(test_ns_prefix_with_empty_uri_4)
+{
+    char *text =
+        "<!DOCTYPE doc [\n"
+        "  <!ELEMENT prefix:doc EMPTY>\n"
+        "  <!ATTLIST prefix:doc\n"
+        "    xmlns:prefix CDATA 'http://xml.libexpat.org/'>\n"
+        "]>\n"
+        "<prefix:doc/>";
+    /* Packaged info expected by the end element handler;
+       the weird structuring lets us re-use the triplet_end_checker()
+       function also used for another test. */
+    char *elemstr[] = {
+        "http://xml.libexpat.org/ doc prefix"
+    };
+    XML_SetReturnNSTriplet(parser, XML_TRUE);
+    XML_SetUserData(parser, elemstr);
+    XML_SetEndElementHandler(parser, triplet_end_checker);
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+START_TEST(test_ns_default_with_empty_uri)
+{
+    char *text =
+        "<doc xmlns='http://xml.libexpat.org/'>\n"
+        "  <e xmlns=''/>\n"
+        "</doc>";
+    if (XML_Parse(parser, text, strlen(text), XML_TRUE) == XML_STATUS_ERROR)
+        xml_failure(parser);
+}
+END_TEST
+
+/* Regression test for SF bug #692964: two prefixes for one namespace. */
+START_TEST(test_ns_duplicate_attrs_diff_prefixes)
+{
+    char *text =
+        "<doc xmlns:a='http://xml.libexpat.org/a'\n"
+        "     xmlns:b='http://xml.libexpat.org/a'\n"
+        "     a:a='v' b:a='v' />";
+    expect_failure(text,
+                   XML_ERROR_DUPLICATE_ATTRIBUTE,
+                   "did not report multiple attributes with same URI+name");
+}
+END_TEST
+
+/* Regression test for SF bug #695401: unbound prefix. */
+START_TEST(test_ns_unbound_prefix_on_attribute)
+{
+    char *text = "<doc a:attr=''/>";
+    expect_failure(text,
+                   XML_ERROR_UNBOUND_PREFIX,
+                   "did not report unbound prefix on attribute");
+}
+END_TEST
+
+/* Regression test for SF bug #695401: unbound prefix. */
+START_TEST(test_ns_unbound_prefix_on_element)
+{
+    char *text = "<a:doc/>";
+    expect_failure(text,
+                   XML_ERROR_UNBOUND_PREFIX,
+                   "did not report unbound prefix on element");
+}
+END_TEST
+
 static Suite *
-make_basic_suite(void)
+make_suite(void)
 {
     Suite *s = suite_create("basic");
-    TCase *tc_chars = tcase_create("character tests");
-    TCase *tc_attrs = tcase_create("attributes");
-    TCase *tc_xmldecl = tcase_create("XML declaration");
+    TCase *tc_basic = tcase_create("basic tests");
     TCase *tc_namespace = tcase_create("XML namespaces");
-    TCase *tc_elements = tcase_create("element events");
-
-    suite_add_tcase(s, tc_chars);
-    tcase_add_checked_fixture(tc_chars, basic_setup, basic_teardown);
-    tcase_add_test(tc_chars, test_nul_byte);
-    tcase_add_test(tc_chars, test_u0000_char);
-    tcase_add_test(tc_chars, test_bom_utf8);
-    tcase_add_test(tc_chars, test_bom_utf16_be);
-    tcase_add_test(tc_chars, test_bom_utf16_le);
-    tcase_add_test(tc_chars, test_illegal_utf8);
-    tcase_add_test(tc_chars, test_utf16);
-    tcase_add_test(tc_chars, test_latin1_umlauts);
+
+    suite_add_tcase(s, tc_basic);
+    tcase_add_checked_fixture(tc_basic, basic_setup, basic_teardown);
+    tcase_add_test(tc_basic, test_nul_byte);
+    tcase_add_test(tc_basic, test_u0000_char);
+    tcase_add_test(tc_basic, test_bom_utf8);
+    tcase_add_test(tc_basic, test_bom_utf16_be);
+    tcase_add_test(tc_basic, test_bom_utf16_le);
+    tcase_add_test(tc_basic, test_illegal_utf8);
+    tcase_add_test(tc_basic, test_utf16);
+    tcase_add_test(tc_basic, test_utf16_le_epilog_newline);
+    tcase_add_test(tc_basic, test_latin1_umlauts);
     /* Regression test for SF bug #491986. */
-    tcase_add_test(tc_chars, test_danish_latin1);
+    tcase_add_test(tc_basic, test_danish_latin1);
     /* Regression test for SF bug #514281. */
-    tcase_add_test(tc_chars, test_french_charref_hexidecimal);
-    tcase_add_test(tc_chars, test_french_charref_decimal);
-    tcase_add_test(tc_chars, test_french_latin1);
-    tcase_add_test(tc_chars, test_french_utf8);
-    tcase_add_test(tc_chars, test_line_count);
-    tcase_add_test(tc_chars, test_really_long_lines);
-
-    suite_add_tcase(s, tc_elements);
-    tcase_add_checked_fixture(tc_elements, basic_setup, basic_teardown);
-    tcase_add_test(tc_elements, test_end_element_events);
-
-    suite_add_tcase(s, tc_attrs);
-    tcase_add_checked_fixture(tc_attrs, basic_setup, basic_teardown);
-    tcase_add_test(tc_attrs, test_attr_whitespace_normalization);
-
-    suite_add_tcase(s, tc_xmldecl);
-    tcase_add_checked_fixture(tc_xmldecl, basic_setup, basic_teardown);
-    tcase_add_test(tc_xmldecl, test_xmldecl_misplaced);
+    tcase_add_test(tc_basic, test_french_charref_hexidecimal);
+    tcase_add_test(tc_basic, test_french_charref_decimal);
+    tcase_add_test(tc_basic, test_french_latin1);
+    tcase_add_test(tc_basic, test_french_utf8);
+    tcase_add_test(tc_basic, test_utf8_false_rejection);
+    tcase_add_test(tc_basic, test_line_number_after_parse);
+    tcase_add_test(tc_basic, test_column_number_after_parse);
+    tcase_add_test(tc_basic, test_line_and_column_numbers_inside_handlers);
+    tcase_add_test(tc_basic, test_line_number_after_error);
+    tcase_add_test(tc_basic, test_column_number_after_error);
+    tcase_add_test(tc_basic, test_really_long_lines);
+    tcase_add_test(tc_basic, test_end_element_events);
+    tcase_add_test(tc_basic, test_attr_whitespace_normalization);
+    tcase_add_test(tc_basic, test_xmldecl_misplaced);
+    tcase_add_test(tc_basic, test_unknown_encoding_internal_entity);
+    tcase_add_test(tc_basic,
+                   test_wfc_undeclared_entity_unread_external_subset);
+    tcase_add_test(tc_basic, test_wfc_undeclared_entity_no_external_subset);
+    tcase_add_test(tc_basic, test_wfc_undeclared_entity_standalone);
+    tcase_add_test(tc_basic, test_wfc_undeclared_entity_with_external_subset);
+    tcase_add_test(tc_basic,
+                   test_wfc_undeclared_entity_with_external_subset_standalone);
+    tcase_add_test(tc_basic, test_wfc_no_recursive_entity_refs);
+    tcase_add_test(tc_basic, test_ext_entity_set_encoding);
+    tcase_add_test(tc_basic, test_dtd_default_handling);
+    tcase_add_test(tc_basic, test_empty_ns_without_namespaces);
 
     suite_add_tcase(s, tc_namespace);
     tcase_add_checked_fixture(tc_namespace,
@@ -681,6 +1356,16 @@ make_basic_suite(void)
     tcase_add_test(tc_namespace, test_return_ns_triplet);
     tcase_add_test(tc_namespace, test_ns_tagname_overwrite);
     tcase_add_test(tc_namespace, test_ns_tagname_overwrite_triplet);
+    tcase_add_test(tc_namespace, test_start_ns_clears_start_element);
+    tcase_add_test(tc_namespace, test_default_ns_from_ext_subset_and_ext_ge);
+    tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_1);
+    tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_2);
+    tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_3);
+    tcase_add_test(tc_namespace, test_ns_prefix_with_empty_uri_4);
+    tcase_add_test(tc_namespace, test_ns_default_with_empty_uri);
+    tcase_add_test(tc_namespace, test_ns_duplicate_attrs_diff_prefixes);
+    tcase_add_test(tc_namespace, test_ns_unbound_prefix_on_attribute);
+    tcase_add_test(tc_namespace, test_ns_unbound_prefix_on_element);
 
     return s;
 }
@@ -692,7 +1377,7 @@ main(int argc, char *argv[])
     int i, nf;
     int forking = 0, forking_set = 0;
     int verbosity = CK_NORMAL;
-    Suite *s = make_basic_suite();
+    Suite *s = make_suite();
     SRunner *sr = srunner_create(s);
 
     /* run the tests for internal helper functions */
@@ -719,10 +1404,14 @@ main(int argc, char *argv[])
     }
     if (forking_set)
         srunner_set_fork_status(sr, forking ? CK_FORK : CK_NOFORK);
+    if (verbosity != CK_SILENT)
+        printf("Expat version: %s\n", XML_ExpatVersion());
     srunner_run_all(sr, verbosity);
     nf = srunner_ntests_failed(sr);
     srunner_free(sr);
+#if 0
     suite_free(s);
+#endif
 
     return (nf == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
 }
index 9e5d2ad..49f3c9a 100644 (file)
@@ -38,6 +38,7 @@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
        IF F$SEARCH("$(LIBRARY)") .EQS. "" THEN $(LIBR) /CREATE /OBJECT $(LIBRARY)
 
 all : $(LIBRARY)
+        @ write sys$output "All made."
  
 .SUFFIXES : 
 .SUFFIXES : $(OLB) $(O) .C .H  
index 80239eb..5bb9639 100644 (file)
@@ -7,15 +7,15 @@
 [Setup]
 AppName=expat
 AppId=expat
-AppVersion=1.95.5
-AppVerName=expat 1.95.5
-AppCopyright=Copyright © 1998-2002 Thai Open Source Software Center, Clark Cooper, and the Expat maintainers
-DefaultDirName={sd}\Expat-1.95.5
+AppVersion=1.95.7
+AppVerName=expat 1.95.7
+AppCopyright=Copyright © 1998-2003 Thai Open Source Software Center, Clark Cooper, and the Expat maintainers
+DefaultDirName={sd}\Expat-1.95.7
 AppPublisher=The Expat Developers
 AppPublisherURL=http://www.libexpat.org/
 AppSupportURL=http://www.libexpat.org/
 AppUpdatesURL=http://www.libexpat.org/
-UninstallDisplayName=Expat XML Parser (version 1.95.5)
+UninstallDisplayName=Expat XML Parser (version 1.95.7)
 UninstallFilesDir={app}\Uninstall
 
 Compression=bzip/9
@@ -42,9 +42,11 @@ CopyMode: alwaysoverwrite; Source: lib\Release-w\*.lib;        DestDir: "{app}\L
 CopyMode: alwaysoverwrite; Source: lib\Release_static\*.lib;   DestDir: "{app}\StaticLibs"
 CopyMode: alwaysoverwrite; Source: lib\Release-w_static\*.lib; DestDir: "{app}\StaticLibs"
 CopyMode: alwaysoverwrite; Source: expat.dsw;                  DestDir: "{app}\Source"
+CopyMode: alwaysoverwrite; Source: win32\README.txt;           DestDir: "{app}\Source"
 CopyMode: alwaysoverwrite; Source: bcb5\*.*;                   DestDir: "{app}\Source\bcb5"
 CopyMode: alwaysoverwrite; Source: lib\*.c;                    DestDir: "{app}\Source\lib"
 CopyMode: alwaysoverwrite; Source: lib\*.h;                    DestDir: "{app}\Source\lib"
+CopyMode: alwaysoverwrite; Source: lib\*.def;                  DestDir: "{app}\Source\lib"
 CopyMode: alwaysoverwrite; Source: lib\*.dsp;                  DestDir: "{app}\Source\lib"
 CopyMode: alwaysoverwrite; Source: examples\*.c;               DestDir: "{app}\Source\examples"
 CopyMode: alwaysoverwrite; Source: examples\*.dsp;             DestDir: "{app}\Source\examples"
index f400d59..33480c2 100644 (file)
@@ -10,7 +10,9 @@
 #ifdef COMPILED_FROM_DSP
 #include "winconfig.h"
 #else
-#include "expat_config.h"
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
 #endif
 #include "expat.h"
 #include "xmlfile.h"
index d03ebaa..0fd2494 100644 (file)
@@ -20,7 +20,7 @@
 
 #define NSSEP T('\001')
 
-static void
+static void XMLCALL
 characterData(void *userData, const XML_Char *s, int len)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -58,7 +58,7 @@ characterData(void *userData, const XML_Char *s, int len)
   }
 }
 
-static void
+static void XMLCALL
 attributeValue(FILE *fp, const XML_Char *s)
        /*@globals fileSystem @*/
        /*@modifies fp, fileSystem @*/
@@ -118,7 +118,7 @@ attcmp(const void *att1, const void *att2)
   return tcscmp(*(const XML_Char **)att1, *(const XML_Char **)att2);
 }
 
-static void
+static void XMLCALL
 startElement(void *userData, const XML_Char *name, const XML_Char **atts)
        /*@globals fileSystem @*/
        /*@modifies userData, *atts, fileSystem @*/
@@ -144,7 +144,7 @@ startElement(void *userData, const XML_Char *name, const XML_Char **atts)
   (void) puttc(T('>'), fp);
 }
 
-static void
+static void XMLCALL
 endElement(void *userData, const XML_Char *name)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -169,7 +169,7 @@ nsattcmp(const void *p1, const void *p2)
   return tcscmp(att1, att2);
 }
 
-static void
+static void XMLCALL
 startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
        /*@globals fileSystem @*/
        /*@modifies userData, *atts, fileSystem @*/
@@ -220,7 +220,7 @@ startElementNS(void *userData, const XML_Char *name, const XML_Char **atts)
   (void) puttc(T('>'), fp);
 }
 
-static void
+static void XMLCALL
 endElementNS(void *userData, const XML_Char *name)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -241,7 +241,7 @@ endElementNS(void *userData, const XML_Char *name)
 
 #ifndef W3C14N
 
-static void
+static void XMLCALL
 processingInstruction(void *userData, const XML_Char *target,
                       const XML_Char *data)
        /*@globals fileSystem @*/
@@ -259,7 +259,7 @@ processingInstruction(void *userData, const XML_Char *target,
 
 #endif /* not W3C14N */
 
-static void
+static void XMLCALL
 defaultCharacterData(void *userData, /*@unused@*/ const XML_Char *s,
                /*@unused@*/ int len)
        /*@modifies userData @*/
@@ -267,7 +267,7 @@ defaultCharacterData(void *userData, /*@unused@*/ const XML_Char *s,
   XML_DefaultCurrent((XML_Parser) userData);
 }
 
-static void
+static void XMLCALL
 defaultStartElement(void *userData, /*@unused@*/ const XML_Char *name,
                     /*@unused@*/ const XML_Char **atts)
        /*@modifies userData @*/
@@ -275,14 +275,14 @@ defaultStartElement(void *userData, /*@unused@*/ const XML_Char *name,
   XML_DefaultCurrent((XML_Parser) userData);
 }
 
-static void
+static void XMLCALL
 defaultEndElement(void *userData, /*@unused@*/ const XML_Char *name)
        /*@modifies userData @*/
 {
   XML_DefaultCurrent((XML_Parser) userData);
 }
 
-static void
+static void XMLCALL
 defaultProcessingInstruction(void *userData,
                /*@unused@*/ const XML_Char *target,
                /*@unused@*/ const XML_Char *data)
@@ -292,25 +292,25 @@ defaultProcessingInstruction(void *userData,
 }
 
 /*@-paramuse@*/
-static void
+static void XMLCALL
 nopCharacterData(void *userData, const XML_Char *s, int len)
        /*@*/
 {
 }
 
-static void
+static void XMLCALL
 nopStartElement(void *userData, const XML_Char *name, const XML_Char **atts)
        /*@*/
 {
 }
 
-static void
+static void XMLCALL
 nopEndElement(void *userData, const XML_Char *name)
        /*@*/
 {
 }
 
-static void
+static void XMLCALL
 nopProcessingInstruction(void *userData, const XML_Char *target,
                          const XML_Char *data)
        /*@*/
@@ -318,7 +318,7 @@ nopProcessingInstruction(void *userData, const XML_Char *target,
 }
 /*@=paramuse@*/
 
-static void
+static void XMLCALL
 markup(void *userData, const XML_Char *s, int len)
        /*@globals fileSystem @*/
        /*@modifies fileSystem @*/
@@ -360,7 +360,7 @@ metaEndDocument(void *userData)
   (void) fputts(T("</document>\n"), XML_GetUserData((XML_Parser) userData));
 }
 
-static void
+static void XMLCALL
 metaStartElement(void *userData, const XML_Char *name,
                  const XML_Char **atts)
        /*@globals fileSystem @*/
@@ -397,7 +397,7 @@ metaStartElement(void *userData, const XML_Char *name,
     (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaEndElement(void *userData, const XML_Char *name)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -409,7 +409,7 @@ metaEndElement(void *userData, const XML_Char *name)
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaProcessingInstruction(void *userData, const XML_Char *target,
                           const XML_Char *data)
        /*@globals fileSystem @*/
@@ -424,7 +424,7 @@ metaProcessingInstruction(void *userData, const XML_Char *target,
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaComment(void *userData, const XML_Char *data)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -438,7 +438,7 @@ metaComment(void *userData, const XML_Char *data)
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaStartCdataSection(void *userData)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -450,7 +450,7 @@ metaStartCdataSection(void *userData)
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaEndCdataSection(void *userData)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -462,7 +462,7 @@ metaEndCdataSection(void *userData)
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaCharacterData(void *userData, const XML_Char *s, int len)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -476,7 +476,7 @@ metaCharacterData(void *userData, const XML_Char *s, int len)
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaStartDoctypeDecl(void *userData,
                      const XML_Char *doctypeName,
                      /*@unused@*/ const XML_Char *sysid,
@@ -492,7 +492,7 @@ metaStartDoctypeDecl(void *userData,
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaEndDoctypeDecl(void *userData)
        /*@globals fileSystem @*/
        /*@modifies userData, fileSystem @*/
@@ -504,7 +504,7 @@ metaEndDoctypeDecl(void *userData)
   (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaNotationDecl(void *userData,
                  const XML_Char *notationName,
                  /*@unused@*/ const XML_Char *base,
@@ -528,7 +528,7 @@ metaNotationDecl(void *userData,
 }
 
 
-static void
+static void XMLCALL
 metaEntityDecl(void *userData,
                const XML_Char *entityName,
                /*@unused@*/ int  is_param,
@@ -574,7 +574,7 @@ metaEntityDecl(void *userData,
   }
 }
 
-static void
+static void XMLCALL
 metaStartNamespaceDecl(void *userData,
                        const XML_Char *prefix,
                        const XML_Char *uri)
@@ -595,7 +595,7 @@ metaStartNamespaceDecl(void *userData,
     (void) fputts(T("/>\n"), fp);
 }
 
-static void
+static void XMLCALL
 metaEndNamespaceDecl(void *userData, const XML_Char *prefix)
        /*@globals fileSystem @*/
        /*@modifies fileSystem @*/
@@ -608,14 +608,14 @@ metaEndNamespaceDecl(void *userData, const XML_Char *prefix)
     ftprintf(fp, T("<endns prefix=\"%s\"/>\n"), prefix);
 }
 
-static int
+static int XMLCALL
 unknownEncodingConvert(void *data, const char *p)
        /*@*/
 {
   return codepageConvert(*(int *)data, p);
 }
 
-static int
+static int XMLCALL
 unknownEncoding(/*@unused@*/ void *userData, const XML_Char *name,
                XML_Encoding *info)
        /*@modifies info @*/
@@ -657,7 +657,7 @@ unknownEncoding(/*@unused@*/ void *userData, const XML_Char *name,
 /*@=compdef@*/
 }
 
-static int
+static int XMLCALL
 notStandalone(/*@unused@*/ void *userData)
        /*@*/
 {