Treat UTF-8 sequences that are longer than needed as an error (STR #4)

This commit is contained in:
Michael R Sweet 2004-10-28 01:07:00 +00:00
parent 3625039424
commit c0878b3f9a
5 changed files with 246 additions and 67 deletions

View File

@ -1,8 +1,10 @@
CHANGES - 10/26/2004
CHANGES - 10/27/2004
--------------------
CHANGES IN Mini-XML 2.1
- Now treat UTF-8 sequences which are longer than
necessary as an error (STR #4)
- Fixed entity number support (STR #8)
- Fixed mxmlLoadString() bug with UTF-8 (STR #7)
- Fixed entity lookup bug (STR #5)

View File

@ -19,7 +19,7 @@ PRE { font-family: monospace }
--></STYLE>
</HEAD>
<BODY>
<CENTER><A HREF="#CONTENTS"><IMG SRC="logo.png" BORDER="0" WIDTH="222" HEIGHT="181"><BR>
<CENTER><A HREF="#CONTENTS"><IMG SRC="logo.png" BORDER="0" WIDTH="222" HEIGHT="181" ALT="Mini-XML Programmers Manual, Version 2.0"><BR>
<H1>Mini-XML Programmers Manual, Version 2.0</H1></A><BR>
Michael Sweet<BR>
Copyright 2003-2004<BR>
@ -48,10 +48,11 @@ Copyright 2003-2004<BR>
<LI><A HREF="#3_1">The Basics</A></LI>
<LI><A HREF="#3_2">Nodes</A></LI>
<LI><A HREF="#3_3">Loading XML</A></LI>
<LI><A HREF="#3_4">Saving XML</A></LI>
<LI><A HREF="#3_4">Saving XML</A>
<UL>
<LI><A HREF="#3_4_1">Finding and Iterating Nodes</A></LI>
</UL>
</LI>
</UL>
<B><A HREF="#ADVANCED">3 - More Mini-XML Programming Techniques</A></B>
<UL>
@ -64,7 +65,7 @@ Copyright 2003-2004<BR>
<B><A HREF="#MXMLDOC">4 - Using the mxmldoc Utility</A></B>
<UL>
<LI><A HREF="#5_1">The Basics</A></LI>
<LI><A HREF="#5_2">Code Documentation Conventions</A></LI>
<LI><A HREF="#5_2">Code Documentation Conventions</A>
<UL>
<LI><A HREF="#5_2_1">Functions and Methods</A></LI>
<LI><A HREF="#5_2_2">Variables and Class/Structure/Union Members</A></LI>
@ -72,32 +73,35 @@ Copyright 2003-2004<BR>
<LI><A HREF="#5_2_4">Classes, Structures, and Unions</A></LI>
<LI><A HREF="#5_2_5">Enumerations</A></LI>
</UL>
</LI>
<LI><A HREF="#5_3">XML Schema</A></LI>
</UL>
<B><A HREF="#LICENSE">A - GNU Library General Public License</A></B>
<BR>
<BR><B><A HREF="#RELNOTES">B - Release Notes</A></B>
<UL>
<LI><A HREF="#7_1">Changes in Mini-XML 2.0</A></LI>
<LI><A HREF="#7_2">Changes in Mini-XML 1.3</A></LI>
<LI><A HREF="#7_3">Changes in Mini-XML 1.2</A></LI>
<LI><A HREF="#7_4">Changes in Mini-XML 1.1.2</A></LI>
<LI><A HREF="#7_5">Changes in Mini-XML 1.1.1</A></LI>
<LI><A HREF="#7_6">Changes in Mini-XML 1.1</A></LI>
<LI><A HREF="#7_7">Changes in Mini-XML 1.0</A></LI>
<LI><A HREF="#7_8">Changes in Mini-XML 0.93</A></LI>
<LI><A HREF="#7_9">Changes in Mini-XML 0.92</A></LI>
<LI><A HREF="#7_10">Changes in Mini-XML 0.91</A></LI>
<LI><A HREF="#7_11">Changes in Mini-XML 0.9</A></LI>
<LI><A HREF="#7_1">Changes in Mini-XML 2.1</A></LI>
<LI><A HREF="#7_2">Changes in Mini-XML 2.0</A></LI>
<LI><A HREF="#7_3">Changes in Mini-XML 1.3</A></LI>
<LI><A HREF="#7_4">Changes in Mini-XML 1.2</A></LI>
<LI><A HREF="#7_5">Changes in Mini-XML 1.1.2</A></LI>
<LI><A HREF="#7_6">Changes in Mini-XML 1.1.1</A></LI>
<LI><A HREF="#7_7">Changes in Mini-XML 1.1</A></LI>
<LI><A HREF="#7_8">Changes in Mini-XML 1.0</A></LI>
<LI><A HREF="#7_9">Changes in Mini-XML 0.93</A></LI>
<LI><A HREF="#7_10">Changes in Mini-XML 0.92</A></LI>
<LI><A HREF="#7_11">Changes in Mini-XML 0.91</A></LI>
<LI><A HREF="#7_12">Changes in Mini-XML 0.9</A></LI>
</UL>
<B><A HREF="#REFERENCE">C - Library Reference</A></B>
<UL>
<LI><A HREF="#8_1">Contents</A></LI>
<LI><A HREF="#_enumerations">Enumerations</A></LI>
<LI><A HREF="#_enumerations">Enumerations</A>
<UL>
<LI><A HREF="#mxml_type_e">mxml_type_e</A></LI>
</UL>
<LI><A HREF="#_functions">Functions</A></LI>
</LI>
<LI><A HREF="#_functions">Functions</A>
<UL>
<LI><A HREF="#mxmlAdd">mxmlAdd()</A></LI>
<LI><A HREF="#mxmlDelete">mxmlDelete()</A></LI>
@ -113,6 +117,7 @@ Copyright 2003-2004<BR>
<LI><A HREF="#mxmlIndexFind">mxmlIndexFind()</A></LI>
<LI><A HREF="#mxmlIndexNew">mxmlIndexNew()</A></LI>
<LI><A HREF="#mxmlIndexReset">mxmlIndexReset()</A></LI>
<LI><A HREF="#mxmlLoadFd">mxmlLoadFd()</A></LI>
<LI><A HREF="#mxmlLoadFile">mxmlLoadFile()</A></LI>
<LI><A HREF="#mxmlLoadString">mxmlLoadString()</A></LI>
<LI><A HREF="#mxmlNewElement">mxmlNewElement()</A></LI>
@ -123,6 +128,7 @@ Copyright 2003-2004<BR>
<LI><A HREF="#mxmlNewTextf">mxmlNewTextf()</A></LI>
<LI><A HREF="#mxmlRemove">mxmlRemove()</A></LI>
<LI><A HREF="#mxmlSaveAllocString">mxmlSaveAllocString()</A></LI>
<LI><A HREF="#mxmlSaveFd">mxmlSaveFd()</A></LI>
<LI><A HREF="#mxmlSaveFile">mxmlSaveFile()</A></LI>
<LI><A HREF="#mxmlSaveString">mxmlSaveString()</A></LI>
<LI><A HREF="#mxmlSetElement">mxmlSetElement()</A></LI>
@ -135,32 +141,39 @@ Copyright 2003-2004<BR>
<LI><A HREF="#mxmlWalkNext">mxmlWalkNext()</A></LI>
<LI><A HREF="#mxmlWalkPrev">mxmlWalkPrev()</A></LI>
</UL>
<LI><A HREF="#_structures">Structures</A></LI>
</LI>
<LI><A HREF="#_structures">Structures</A>
<UL>
<LI><A HREF="#mxml_attr_s">mxml_attr_s</A></LI>
<LI><A HREF="#mxml_fdbuf_s">mxml_fdbuf_s</A></LI>
<LI><A HREF="#mxml_index_s">mxml_index_s</A></LI>
<LI><A HREF="#mxml_node_s">mxml_node_s</A></LI>
<LI><A HREF="#mxml_text_s">mxml_text_s</A></LI>
<LI><A HREF="#mxml_value_s">mxml_value_s</A></LI>
</UL>
<LI><A HREF="#_types">Types</A></LI>
</LI>
<LI><A HREF="#_types">Types</A>
<UL>
<LI><A HREF="#mxml_attr_t">mxml_attr_t</A></LI>
<LI><A HREF="#mxml_element_t">mxml_element_t</A></LI>
<LI><A HREF="#mxml_fdbuf_t">mxml_fdbuf_t</A></LI>
<LI><A HREF="#mxml_index_t">mxml_index_t</A></LI>
<LI><A HREF="#mxml_node_t">mxml_node_t</A></LI>
<LI><A HREF="#mxml_text_t">mxml_text_t</A></LI>
<LI><A HREF="#mxml_type_t">mxml_type_t</A></LI>
<LI><A HREF="#mxml_value_t">mxml_value_t</A></LI>
</UL>
<LI><A HREF="#_unions">Unions</A></LI>
</LI>
<LI><A HREF="#_unions">Unions</A>
<UL>
<LI><A HREF="#mxml_value_u">mxml_value_u</A></LI>
</UL>
<LI><A HREF="#_variables">Variables</A></LI>
</LI>
<LI><A HREF="#_variables">Variables</A>
<UL>
<LI><A HREF="#num_callbacks">num_callbacks</A></LI>
</UL>
</LI>
</UL>
<HR NOSHADE>
<H1 align="right"><A name="INTRO">Introduction</A></H1>
@ -265,12 +278,12 @@ libxml2</TT> library with something substantially smaller and
<TR><TH>Example</TH><TD>&nbsp;&nbsp;&nbsp;</TD><TH>Description</TH></TR>
<TR><TD colspan="3">&nbsp;</TD></TR>
<TR valign="top"><TD><CODE>lpstat</CODE>
<BR /> <CODE>lpstat(1)</CODE></TD><TD>&nbsp;&nbsp;&nbsp;</TD><TD>The names of commands;
<BR> <CODE>lpstat(1)</CODE></TD><TD>&nbsp;&nbsp;&nbsp;</TD><TD>The names of commands;
the first mention of a command or function in a chapter is followed by
a manual page section number.</TD></TR>
<TR><TD colspan="3">&nbsp;</TD></TR>
<TR valign="top"><TD><VAR>/var</VAR>
<BR /><VAR> /usr/share/cups/data/testprint.ps</VAR></TD><TD>&nbsp;&nbsp;&nbsp;</TD><TD>
<BR><VAR> /usr/share/cups/data/testprint.ps</VAR></TD><TD>&nbsp;&nbsp;&nbsp;</TD><TD>
File and directory names.</TD></TR>
<TR><TD colspan="3">&nbsp;</TD></TR>
<TR valign="top"><TD nowrap><TT>Request ID is Printer-123</TT></TD><TD>
@ -292,22 +305,22 @@ File and directory names.</TD></TR>
<DL>
<DT>Gb</DT>
<DD>Gigabytes, or 1073741824 bytes
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
<DT>kb</DT>
<DD>Kilobytes, or 1024 bytes
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
<DT>Mb</DT>
<DD>Megabytes, or 1048576 bytes
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
<DT>UTF-8, UTF-16</DT>
<DD>Unicode Transformation Format, 8-bit or 16-bit
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
<DT>W3C</DT>
<DD>World Wide Web Consortium
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
<DT>XML</DT>
<DD>Extensible Markup Language
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
</DL>
</BLOCKQUOTE>
<H2><A NAME="1_6">Other References</A></H2>
@ -316,11 +329,11 @@ File and directory names.</TD></TR>
<DT>The Unicode Standard, Version 4.0, Addison-Wesley, ISBN
0-321-18578-1</DT>
<DD>The definition of the Unicode character set which is used for XML.
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
<DT><A href="http://www.w3.org/TR/2004/REC-xml-20040204/">Extensible
Markup Language (XML) 1.0 (Third Edition)</A></DT>
<DD>The XML specification from the World Wide Web Consortium (W3C)
<BR />&nbsp;</DD>
<BR>&nbsp;</DD>
</DL>
</BLOCKQUOTE><HR NOSHADE>
<H1 align="right"><A name="INSTALL">1 - Building, Installing, and
@ -1258,11 +1271,11 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<H1 align="right"><A name="LICENSE">A - GNU Library General Public
License</A></H1>
<P align="center">Version 2, June 1991
<BR /> Copyright (C) 1991 Free Software Foundation, Inc.
<BR /> 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
<BR /> Everyone is permitted to copy and distribute verbatim copies of
<BR> Copyright (C) 1991 Free Software Foundation, Inc.
<BR> 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
<BR> Everyone is permitted to copy and distribute verbatim copies of
this license document, but changing it is not allowed.
<BR /> [This is the first released version of the library GPL. It is
<BR> [This is the first released version of the library GPL. It is
numbered 2 because it goes with version 2 of the ordinary GPL.]</P>
<P><BIG>Preamble</BIG></P>
<P>The licenses for most software are designed to take away your freedom
@ -1632,7 +1645,12 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<P align="center"><BIG>END OF TERMS AND CONDITIONS</BIG></P>
<HR NOSHADE>
<H1 align="right"><A name="RELNOTES">B - Release Notes</A></H1>
<H2><A NAME="7_1">Changes in Mini-XML 2.0</A></H2>
<H2><A NAME="7_1">Changes in Mini-XML 2.1</A></H2>
<UL>
<LI>Added mxmlLoadFd() and mxmlSaveFd() functions.</LI>
<LI>Fixed multi-word UTF-16 handling.</LI>
</UL>
<H2><A NAME="7_2">Changes in Mini-XML 2.0</A></H2>
<UL>
<LI>New programmers manual.</LI>
<LI>Added Visual C++ project files for Microsoft Windows users.</LI>
@ -1665,7 +1683,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
destination path and install path. This caused problems when building
and installing with MingW.</LI>
</UL>
<H2><A NAME="7_2">Changes in Mini-XML 1.3</A></H2>
<H2><A NAME="7_3">Changes in Mini-XML 1.3</A></H2>
<UL>
<LI>Fixes for mxmldoc.</LI>
<LI>Added support for reading standard HTML entity names.</LI>
@ -1681,7 +1699,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI>The load and save functions now properly handle quoted element and
attribute name strings properly, e.g. for !DOCTYPE declarations.</LI>
</UL>
<H2><A NAME="7_3">Changes in Mini-XML 1.2</A></H2>
<H2><A NAME="7_4">Changes in Mini-XML 1.2</A></H2>
<UL>
<LI>Added new &quot;set&quot; methods to set the value of a node.</LI>
<LI>Added new formatted text methods mxmlNewTextf() and mxmlSetTextf()
@ -1694,13 +1712,13 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI>Added --with/without-snprintf configure option to control the
snprintf() and vsnprintf() function checks.</LI>
</UL>
<H2><A NAME="7_4">Changes in Mini-XML 1.1.2</A></H2>
<H2><A NAME="7_5">Changes in Mini-XML 1.1.2</A></H2>
<UL>
<LI>The mxml(3) man page wasn't updated for the string functions.</LI>
<LI>mxmlSaveString() returned the wrong number of characters.</LI>
<LI>mxml_add_char() updated the buffer pointer in the wrong place.</LI>
</UL>
<H2><A NAME="7_5">Changes in Mini-XML 1.1.1</A></H2>
<H2><A NAME="7_6">Changes in Mini-XML 1.1.1</A></H2>
<UL>
<LI>The private mxml_add_ch() function did not update the
start-of-buffer pointer which could cause a crash when using
@ -1711,7 +1729,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI>Added a mxmlSaveAllocString() convenience function for saving an XML
node tree to an allocated string.</LI>
</UL>
<H2><A NAME="7_6">Changes in Mini-XML 1.1</A></H2>
<H2><A NAME="7_7">Changes in Mini-XML 1.1</A></H2>
<UL>
<LI>The mxmlLoadFile() function now uses dynamically allocated string
buffers for element names, attribute names, and attribute values.
@ -1723,7 +1741,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI>Add emulation of strdup() if the local platform does not provide the
function.</LI>
</UL>
<H2><A NAME="7_7">Changes in Mini-XML 1.0</A></H2>
<H2><A NAME="7_8">Changes in Mini-XML 1.0</A></H2>
<UL>
<LI>The mxmldoc program now handles function arguments, structures,
unions, enumerations, classes, and typedefs properly.</LI>
@ -1731,7 +1749,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
code.</LI>
<LI>Added man pages and packaging files.</LI>
</UL>
<H2><A NAME="7_8">Changes in Mini-XML 0.93</A></H2>
<H2><A NAME="7_9">Changes in Mini-XML 0.93</A></H2>
<UL>
<LI>New mxmldoc example program that is also used to create and update
code documentation using XML and produce HTML reference pages.</LI>
@ -1756,15 +1774,15 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI>mxmlSaveFile() now supports a whitespace callback to provide more
human-readable XML output under program control.</LI>
</UL>
<H2><A NAME="7_9">Changes in Mini-XML 0.92</A></H2>
<H2><A NAME="7_10">Changes in Mini-XML 0.92</A></H2>
<UL>
<LI>mxmlSaveFile() didn't return a value on success.</LI>
</UL>
<H2><A NAME="7_10">Changes in Mini-XML 0.91</A></H2>
<H2><A NAME="7_11">Changes in Mini-XML 0.91</A></H2>
<UL>
<LI>mxmlWalkNext() would go into an infinite loop.</LI>
</UL>
<H2><A NAME="7_11">Changes in Mini-XML 0.9</A></H2>
<H2><A NAME="7_12">Changes in Mini-XML 0.9</A></H2>
<UL>
<LI>Initial public release.</LI>
</UL>
@ -1823,6 +1841,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI><A href="#mxmlIndexFind"><TT>mxmlIndexFind()</TT></A></LI>
<LI><A href="#mxmlIndexNew"><TT>mxmlIndexNew()</TT></A></LI>
<LI><A href="#mxmlIndexReset"><TT>mxmlIndexReset()</TT></A></LI>
<LI><A href="#mxmlLoadFd"><TT>mxmlLoadFd()</TT></A></LI>
<LI><A href="#mxmlLoadFile"><TT>mxmlLoadFile()</TT></A></LI>
<LI><A href="#mxmlLoadString"><TT>mxmlLoadString()</TT></A></LI>
<LI><A href="#mxmlNewElement"><TT>mxmlNewElement()</TT></A></LI>
@ -1833,6 +1852,7 @@ mxmldoc</TT> to generate correct documentation for the code. Single line
<LI><A href="#mxmlNewTextf"><TT>mxmlNewTextf()</TT></A></LI>
<LI><A href="#mxmlRemove"><TT>mxmlRemove()</TT></A></LI>
<LI><A href="#mxmlSaveAllocString"><TT>mxmlSaveAllocString()</TT></A></LI>
<LI><A href="#mxmlSaveFd"><TT>mxmlSaveFd()</TT></A></LI>
<LI><A href="#mxmlSaveFile"><TT>mxmlSaveFile()</TT></A></LI>
<LI><A href="#mxmlSaveString"><TT>mxmlSaveString()</TT></A></LI>
<LI><A href="#mxmlSetElement"><TT>mxmlSetElement()</TT></A></LI>
@ -2222,6 +2242,41 @@ mxmlIndexReset(
<H4>Returns</H4>
<P>First node or NULL if there is none</P>
<!-- NEW PAGE -->
<H3><A name="mxmlLoadFd">mxmlLoadFd()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Load a file descriptor into an XML node tree. The nodes in the
specified file are added to the specified top node. If no top node is
provided, the XML file MUST be well-formed with a single parent node
like &lt;?xml&gt; for the entire file. The callback function returns the
value type that should be used for child nodes. If MXML_NO_CALLBACK is
specified then all child nodes will be either MXML_ELEMENT or MXML_TEXT
nodes. The constants MXML_INTEGER_CALLBACK, MXML_OPAQUE_CALLBACK,
MXML_REAL_CALLBACK, and MXML_TEXT_CALLBACK are defined for loading
child nodes of the specified type.</P>
<H4>Syntax</H4>
<PRE>
<A href="#mxml_node_t">mxml_node_t</A> *
mxmlLoadFd(
<A href="#mxml_node_t">mxml_node_t</A> * top,
int fd,
<A href="#mxml_type_t">mxml_type_t</A> (*cb)(mxml_node_t *node));
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>top</TT></TD><TD>Top node</TD></TR>
<TR><TD><TT>fd</TT></TD><TD>File descriptor to read from</TD></TR>
<TR><TD><TT>(*cb)(mxml_node_t *node)</TT></TD><TD>Callback function or
MXML_NO_CALLBACK</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>First node or NULL if the file could not be read.</P>
<!-- NEW PAGE -->
<H3><A name="mxmlLoadFile">mxmlLoadFile()</A></H3>
<HR noshade/>
@ -2496,7 +2551,11 @@ mxmlRemove(
pointer to a string containing the textual representation of the XML
node tree. The string should be freed using the free() function when
you are done with it. NULL is returned if the node would produce an
empty string or if the string cannot be allocated.</P>
empty string or if the string cannot be allocated. The callback
argument specifies a function that returns a whitespace string or NULL
before and after each element. If MXML_NO_CALLBACK is specified,
whitespace will only be added before MXML_TEXT nodes with leading
whitespace and before attribute names inside opening element tags.</P>
<H4>Syntax</H4>
<PRE>
char *
@ -2517,14 +2576,45 @@ mxmlSaveAllocString(
<H4>Returns</H4>
<P>Allocated string or NULL</P>
<!-- NEW PAGE -->
<H3><A name="mxmlSaveFd">mxmlSaveFd()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Save an XML tree to a file descriptor. The callback argument
specifies a function that returns a whitespace string or NULL before
and after each element. If MXML_NO_CALLBACK is specified, whitespace
will only be added before MXML_TEXT nodes with leading whitespace and
before attribute names inside opening element tags.</P>
<H4>Syntax</H4>
<PRE>
int
mxmlSaveFd(
<A href="#mxml_node_t">mxml_node_t</A> * node,
int fd,
const char * (*cb)(mxml_node_t *node, int ws));
</PRE>
<H4>Arguments</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>node</TT></TD><TD>Node to write</TD></TR>
<TR><TD><TT>fd</TT></TD><TD>File descriptor to write to</TD></TR>
<TR><TD><TT>(*cb)(mxml_node_t *node, int ws)</TT></TD><TD>Whitespace
callback or MXML_NO_CALLBACK</TD></TR>
</TABLE>
<H4>Returns</H4>
<P>0 on success, -1 on error.</P>
<!-- NEW PAGE -->
<H3><A name="mxmlSaveFile">mxmlSaveFile()</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>Save an XML tree to a file. The callback argument specifies a
function that returns a whitespace character or nul (0) before and
after each element. If MXML_NO_CALLBACK is specified, whitespace will
only be added before MXML_TEXT nodes with leading whitespace and before
function that returns a whitespace string or NULL before and after each
element. If MXML_NO_CALLBACK is specified, whitespace will only be
added before MXML_TEXT nodes with leading whitespace and before
attribute names inside opening element tags.</P>
<H4>Syntax</H4>
<PRE>
@ -2554,7 +2644,11 @@ mxmlSaveFile(
<H4>Description</H4>
<P>Save an XML node tree to a string. This function returns the total
number of bytes that would be required for the string but only copies
(bufsize - 1) characters into the specified buffer.</P>
(bufsize - 1) characters into the specified buffer. The callback
argument specifies a function that returns a whitespace string or NULL
before and after each element. If MXML_NO_CALLBACK is specified,
whitespace will only be added before MXML_TEXT nodes with leading
whitespace and before attribute names inside opening element tags.</P>
<H4>Syntax</H4>
<PRE>
int
@ -2823,6 +2917,7 @@ mxmlWalkPrev(
<H2><A name="_structures">Structures</A></H2>
<UL>
<LI><A href="#mxml_attr_s"><TT>mxml_attr_s</TT></A></LI>
<LI><A href="#mxml_fdbuf_s"><TT>mxml_fdbuf_s</TT></A></LI>
<LI><A href="#mxml_index_s"><TT>mxml_index_s</TT></A></LI>
<LI><A href="#mxml_node_s"><TT>mxml_node_s</TT></A></LI>
<LI><A href="#mxml_text_s"><TT>mxml_text_s</TT></A></LI>
@ -2852,6 +2947,31 @@ struct mxml_attr_s
<TR><TD><TT>value</TT></TD><TD>Attribute value</TD></TR>
</TABLE>
<!-- NEW PAGE -->
<H3><A name="mxml_fdbuf_s">mxml_fdbuf_s</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>File descriptor buffer (@private)</P>
<H4>Definition</H4>
<PRE>
struct mxml_fdbuf_s
{
end buffer[8192];
unsigned char * current;
int fd;
};
</PRE>
<H4>Members</H4>
<P class="table"></P>
<TABLE align="center" border="1" cellpadding="5" cellspacing="0" width="80%">
<THEAD></THEAD>
<TR bgcolor="#cccccc"><TH>Name</TH><TH>Description</TH></TR>
<TBODY></TBODY>
<TR><TD><TT>buffer[8192]</TT></TD><TD>Character buffer</TD></TR>
<TR><TD><TT>current</TT></TD><TD>Current position in buffer</TD></TR>
<TR><TD><TT>fd</TT></TD><TD>File descriptor</TD></TR>
</TABLE>
<!-- NEW PAGE -->
<H3><A name="mxml_index_s">mxml_index_s</A></H3>
<HR noshade/>
@ -2967,6 +3087,7 @@ struct mxml_value_s
<UL>
<LI><A href="#mxml_attr_t"><TT>mxml_attr_t</TT></A></LI>
<LI><A href="#mxml_element_t"><TT>mxml_element_t</TT></A></LI>
<LI><A href="#mxml_fdbuf_t"><TT>mxml_fdbuf_t</TT></A></LI>
<LI><A href="#mxml_index_t"><TT>mxml_index_t</TT></A></LI>
<LI><A href="#mxml_node_t"><TT>mxml_node_t</TT></A></LI>
<LI><A href="#mxml_text_t"><TT>mxml_text_t</TT></A></LI>
@ -2994,6 +3115,16 @@ typedef struct <A href="#mxml_attr_s">mxml_attr_s</A> mxml_attr_t;
typedef struct <A href="#mxml_value_s">mxml_value_s</A> mxml_element_t;
</PRE>
<!-- NEW PAGE -->
<H3><A name="mxml_fdbuf_t">mxml_fdbuf_t</A></H3>
<HR noshade/>
<H4>Description</H4>
<P>File descriptor buffer (@private)</P>
<H4>Definition</H4>
<PRE>
typedef struct <A href="#mxml_fdbuf_s">mxml_fdbuf_s</A> mxml_fdbuf_t;
</PRE>
<!-- NEW PAGE -->
<H3><A name="mxml_index_t">mxml_index_t</A></H3>
<HR noshade/>

View File

@ -7,6 +7,15 @@
<ul>
<li>Now treat UTF-8 sequences which are longer than
necessary as an error (STR #4)</li>
<li>Fixed entity number support (STR #8)</li>
<li>Fixed mxmlLoadString() bug with UTF-8 (STR #7)</li>
<li>Fixed entity lookup bug (STR #5)</li>
<li>Added mxmlLoadFd() and mxmlSaveFd() functions.</li>
<li>Fixed multi-word UTF-16 handling.</li>

View File

@ -1,5 +1,5 @@
/*
* "$Id: mxml-file.c,v 1.35 2004/10/26 21:04:32 mike Exp $"
* "$Id: mxml-file.c,v 1.36 2004/10/28 01:07:00 mike Exp $"
*
* File loading code for Mini-XML, a small XML-like file parsing library.
*
@ -470,7 +470,7 @@ mxml_add_char(int ch, /* I - Character to add */
*buffer = newbuffer;
}
if (ch < 128)
if (ch < 0x80)
{
/*
* Single byte ASCII...
@ -478,7 +478,7 @@ mxml_add_char(int ch, /* I - Character to add */
*(*bufptr)++ = ch;
}
else if (ch < 2048)
else if (ch < 0x800)
{
/*
* Two-byte UTF-8...
@ -487,7 +487,7 @@ mxml_add_char(int ch, /* I - Character to add */
*(*bufptr)++ = 0xc0 | (ch >> 6);
*(*bufptr)++ = 0x80 | (ch & 0x3f);
}
else if (ch < 65536)
else if (ch < 0x10000)
{
/*
* Three-byte UTF-8...
@ -601,6 +601,9 @@ mxml_fd_getc(void *p, /* I - File descriptor buffer */
return (EOF);
ch = ((ch & 0x1f) << 6) | (temp & 0x3f);
if (ch < 0x80)
return (EOF);
}
else if ((ch & 0xf0) == 0xe0)
{
@ -629,6 +632,9 @@ mxml_fd_getc(void *p, /* I - File descriptor buffer */
return (EOF);
ch = (ch << 6) | (temp & 0x3f);
if (ch < 0x800)
return (EOF);
}
else if ((ch & 0xf8) == 0xf0)
{
@ -668,6 +674,9 @@ mxml_fd_getc(void *p, /* I - File descriptor buffer */
return (EOF);
ch = (ch << 6) | (temp & 0x3f);
if (ch < 0x10000)
return (EOF);
}
else
return (EOF);
@ -784,7 +793,7 @@ mxml_fd_putc(int ch, /* I - Character */
if (mxml_fd_write(buf) < 0)
return (-1);
if (ch < 128)
if (ch < 0x80)
{
/*
* Write ASCII character directly...
@ -792,7 +801,7 @@ mxml_fd_putc(int ch, /* I - Character */
*(buf->current)++ = ch;
}
else if (ch < 2048)
else if (ch < 0x800)
{
/*
* Two-byte UTF-8 character...
@ -801,7 +810,7 @@ mxml_fd_putc(int ch, /* I - Character */
*(buf->current)++ = 0xc0 | (ch >> 6);
*(buf->current)++ = 0x80 | (ch & 0x3f);
}
else if (ch < 65536)
else if (ch < 0x10000)
{
/*
* Three-byte UTF-8 character...
@ -983,6 +992,9 @@ mxml_file_getc(void *p, /* I - Pointer to file */
return (EOF);
ch = ((ch & 0x1f) << 6) | (temp & 0x3f);
if (ch < 0x80)
return (EOF);
}
else if ((ch & 0xf0) == 0xe0)
{
@ -999,6 +1011,9 @@ mxml_file_getc(void *p, /* I - Pointer to file */
return (EOF);
ch = (ch << 6) | (temp & 0x3f);
if (ch < 0x800)
return (EOF);
}
else if ((ch & 0xf8) == 0xf0)
{
@ -1020,6 +1035,9 @@ mxml_file_getc(void *p, /* I - Pointer to file */
return (EOF);
ch = (ch << 6) | (temp & 0x3f);
if (ch < 0x10000)
return (EOF);
}
else
return (EOF);
@ -1087,12 +1105,12 @@ mxml_file_putc(int ch, /* I - Character to write */
int buflen; /* Number of bytes to write */
if (ch < 128)
if (ch < 0x80)
return (putc(ch, (FILE *)p) == EOF ? -1 : 0);
bufptr = buffer;
if (ch < 2048)
if (ch < 0x800)
{
/*
* Two-byte UTF-8 character...
@ -1101,7 +1119,7 @@ mxml_file_putc(int ch, /* I - Character to write */
*bufptr++ = 0xc0 | (ch >> 6);
*bufptr++ = 0x80 | (ch & 0x3f);
}
else if (ch < 65536)
else if (ch < 0x10000)
{
/*
* Three-byte UTF-8 character...
@ -1892,6 +1910,9 @@ mxml_string_getc(void *p, /* I - Pointer to file */
(*s)++;
if (ch < 0x80)
return (EOF);
return (ch);
}
else if ((ch & 0xf0) == 0xe0)
@ -1908,6 +1929,9 @@ mxml_string_getc(void *p, /* I - Pointer to file */
(*s) += 2;
if (ch < 0x800)
return (EOF);
return (ch);
}
else if ((ch & 0xf8) == 0xf0)
@ -1926,6 +1950,9 @@ mxml_string_getc(void *p, /* I - Pointer to file */
(*s) += 3;
if (ch < 0x10000)
return (EOF);
return (ch);
}
else
@ -2019,7 +2046,7 @@ mxml_string_putc(int ch, /* I - Character to write */
pp = (char **)p;
if (ch < 128)
if (ch < 0x80)
{
/*
* Plain ASCII doesn't need special encoding...
@ -2030,7 +2057,7 @@ mxml_string_putc(int ch, /* I - Character to write */
pp[0] ++;
}
else if (ch < 2048)
else if (ch < 0x800)
{
/*
* Two-byte UTF-8 character...
@ -2044,7 +2071,7 @@ mxml_string_putc(int ch, /* I - Character to write */
pp[0] += 2;
}
else if (ch < 65536)
else if (ch < 0x10000)
{
/*
* Three-byte UTF-8 character...
@ -2470,5 +2497,5 @@ mxml_write_ws(mxml_node_t *node, /* I - Current node */
/*
* End of "$Id: mxml-file.c,v 1.35 2004/10/26 21:04:32 mike Exp $".
* End of "$Id: mxml-file.c,v 1.36 2004/10/28 01:07:00 mike Exp $".
*/

View File

@ -1,5 +1,5 @@
/*
* "$Id: mxmldoc.c,v 1.37 2004/06/01 20:19:34 mike Exp $"
* "$Id: mxmldoc.c,v 1.38 2004/10/28 01:07:00 mike Exp $"
*
* Documentation generator using Mini-XML, a small XML-like file parsing
* library.
@ -894,6 +894,16 @@ scan_file(const char *filename, /* I - Filename */
}
break;
case '&' :
if (type)
{
#ifdef DEBUG
fputs("Identifier: <<<< & >>>\n", stderr);
#endif /* DEBUG */
mxmlNewText(type, 1, "&");
}
break;
case '+' :
if (type)
{
@ -2735,5 +2745,5 @@ ws_cb(mxml_node_t *node, /* I - Element node */
/*
* End of "$Id: mxmldoc.c,v 1.37 2004/06/01 20:19:34 mike Exp $".
* End of "$Id: mxmldoc.c,v 1.38 2004/10/28 01:07:00 mike Exp $".
*/