merge expat-2.2.0 and document
This commit is contained in:
parent
024103ff9f
commit
10927b73f6
@ -1,4 +1,4 @@
|
||||
# $NetBSD: 3RDPARTY,v 1.1406 2017/01/31 23:56:41 christos Exp $
|
||||
# $NetBSD: 3RDPARTY,v 1.1407 2017/02/04 10:56:10 spz Exp $
|
||||
#
|
||||
# This file contains a list of the software that has been integrated into
|
||||
# NetBSD where we are not the primary maintainer.
|
||||
@ -413,7 +413,7 @@ Location: external/bsd/ekermit
|
||||
Notes:
|
||||
|
||||
Package: expat
|
||||
Version: 2.1.1
|
||||
Version: 2.2.0
|
||||
Current Vers: 2.2.0
|
||||
Maintainer: Expat Project
|
||||
Archive Site: http://sourceforge.net/projects/expat/files/expat/
|
||||
|
13
external/mit/expat/dist/conftools/config.guess
vendored
13
external/mit/expat/dist/conftools/config.guess
vendored
@ -1057,7 +1057,18 @@ EOF
|
||||
echo ${UNAME_MACHINE}-dec-linux-${LIBC}
|
||||
exit ;;
|
||||
x86_64:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-linux-${LIBC}
|
||||
eval $set_cc_for_build
|
||||
X86_64_ABI=
|
||||
# If there is a compiler, see if it is configured for 32-bit objects.
|
||||
if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
|
||||
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
|
||||
(CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
|
||||
grep IS_X32 >/dev/null
|
||||
then
|
||||
X86_64_ABI=x32
|
||||
fi
|
||||
fi
|
||||
echo ${UNAME_MACHINE}-pc-linux-${LIBC}${X86_64_ABI}
|
||||
exit ;;
|
||||
xtensa*:Linux:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
|
||||
|
20
external/mit/expat/dist/conftools/config.sub
vendored
20
external/mit/expat/dist/conftools/config.sub
vendored
@ -838,6 +838,24 @@ case $basic_machine in
|
||||
basic_machine=m68k-atari
|
||||
os=-mint
|
||||
;;
|
||||
mipsEE* | ee | ps2)
|
||||
basic_machine=mips64r5900el-scei
|
||||
case $os in
|
||||
-linux*)
|
||||
;;
|
||||
*)
|
||||
os=-elf
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
iop)
|
||||
basic_machine=mipsel-scei
|
||||
os=-irx
|
||||
;;
|
||||
dvp)
|
||||
basic_machine=dvp-scei
|
||||
os=-elf
|
||||
;;
|
||||
mips3*-*)
|
||||
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
|
||||
;;
|
||||
@ -1404,7 +1422,7 @@ case $os in
|
||||
| -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* | -irx* \
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
|
||||
|
467
external/mit/expat/dist/doc/xmlwf.sgml
vendored
467
external/mit/expat/dist/doc/xmlwf.sgml
vendored
@ -1,467 +0,0 @@
|
||||
<!doctype refentry PUBLIC "-//OASIS//DTD DocBook V4.1//EN" [
|
||||
|
||||
<!-- Process this file with docbook-to-man to generate an nroff manual
|
||||
page: `docbook-to-man manpage.sgml > manpage.1'. You may view
|
||||
the manual page with: `docbook-to-man manpage.sgml | nroff -man |
|
||||
less'. A typical entry in a Makefile or Makefile.am is:
|
||||
|
||||
manpage.1: manpage.sgml
|
||||
docbook-to-man $< > $@
|
||||
-->
|
||||
|
||||
<!-- Fill in your name for FIRSTNAME and SURNAME. -->
|
||||
<!ENTITY dhfirstname "<firstname>Scott</firstname>">
|
||||
<!ENTITY dhsurname "<surname>Bronson</surname>">
|
||||
<!-- Please adjust the date whenever revising the manpage. -->
|
||||
<!ENTITY dhdate "<date>March 11, 2016</date>">
|
||||
<!-- SECTION should be 1-8, maybe w/ subsection other parameters are
|
||||
allowed: see man(7), man(1). -->
|
||||
<!ENTITY dhsection "<manvolnum>1</manvolnum>">
|
||||
<!ENTITY dhemail "<email>bronson@rinspin.com</email>">
|
||||
<!ENTITY dhusername "Scott Bronson">
|
||||
<!ENTITY dhucpackage "<refentrytitle>XMLWF</refentrytitle>">
|
||||
<!ENTITY dhpackage "xmlwf">
|
||||
|
||||
<!ENTITY debian "<productname>Debian GNU/Linux</productname>">
|
||||
<!ENTITY gnu "<acronym>GNU</acronym>">
|
||||
]>
|
||||
|
||||
<refentry>
|
||||
<refentryinfo>
|
||||
<address>
|
||||
&dhemail;
|
||||
</address>
|
||||
<author>
|
||||
&dhfirstname;
|
||||
&dhsurname;
|
||||
</author>
|
||||
<copyright>
|
||||
<year>2001</year>
|
||||
<holder>&dhusername;</holder>
|
||||
</copyright>
|
||||
&dhdate;
|
||||
</refentryinfo>
|
||||
<refmeta>
|
||||
&dhucpackage;
|
||||
|
||||
&dhsection;
|
||||
</refmeta>
|
||||
<refnamediv>
|
||||
<refname>&dhpackage;</refname>
|
||||
|
||||
<refpurpose>Determines if an XML document is well-formed</refpurpose>
|
||||
</refnamediv>
|
||||
<refsynopsisdiv>
|
||||
<cmdsynopsis>
|
||||
<command>&dhpackage;</command>
|
||||
<arg><option>-s</option></arg>
|
||||
<arg><option>-n</option></arg>
|
||||
<arg><option>-p</option></arg>
|
||||
<arg><option>-x</option></arg>
|
||||
|
||||
<arg><option>-e <replaceable>encoding</replaceable></option></arg>
|
||||
<arg><option>-w</option></arg>
|
||||
|
||||
<arg><option>-d <replaceable>output-dir</replaceable></option></arg>
|
||||
<arg><option>-c</option></arg>
|
||||
<arg><option>-m</option></arg>
|
||||
|
||||
<arg><option>-r</option></arg>
|
||||
<arg><option>-t</option></arg>
|
||||
|
||||
<arg><option>-v</option></arg>
|
||||
|
||||
<arg>file ...</arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
<refsect1>
|
||||
<title>DESCRIPTION</title>
|
||||
|
||||
<para>
|
||||
<command>&dhpackage;</command> uses the Expat library to
|
||||
determine if an XML document is well-formed. It is
|
||||
non-validating.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
If you do not specify any files on the command-line, and you
|
||||
have a recent version of <command>&dhpackage;</command>, the
|
||||
input file will be read from standard input.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>WELL-FORMED DOCUMENTS</title>
|
||||
|
||||
<para>
|
||||
A well-formed document must adhere to the
|
||||
following rules:
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
The file begins with an XML declaration. For instance,
|
||||
<literal><?xml version="1.0" standalone="yes"?></literal>.
|
||||
<emphasis>NOTE:</emphasis>
|
||||
<command>&dhpackage;</command> does not currently
|
||||
check for a valid XML declaration.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
Every start tag is either empty (<tag/>)
|
||||
or has a corresponding end tag.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
There is exactly one root element. This element must contain
|
||||
all other elements in the document. Only comments, white
|
||||
space, and processing instructions may come after the close
|
||||
of the root element.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
All elements nest properly.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
All attribute values are enclosed in quotes (either single
|
||||
or double).
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
If the document has a DTD, and it strictly complies with that
|
||||
DTD, then the document is also considered <emphasis>valid</emphasis>.
|
||||
<command>&dhpackage;</command> is a non-validating parser --
|
||||
it does not check the DTD. However, it does support
|
||||
external entities (see the <option>-x</option> option).
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>OPTIONS</title>
|
||||
|
||||
<para>
|
||||
When an option includes an argument, you may specify the argument either
|
||||
separately ("<option>-d</option> output") or concatenated with the
|
||||
option ("<option>-d</option>output"). <command>&dhpackage;</command>
|
||||
supports both.
|
||||
</para>
|
||||
|
||||
<variablelist>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-c</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If the input file is well-formed and <command>&dhpackage;</command>
|
||||
doesn't encounter any errors, the input file is simply copied to
|
||||
the output directory unchanged.
|
||||
This implies no namespaces (turns off <option>-n</option>) and
|
||||
requires <option>-d</option> to specify an output file.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-d output-dir</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies a directory to contain transformed
|
||||
representations of the input files.
|
||||
By default, <option>-d</option> outputs a canonical representation
|
||||
(described below).
|
||||
You can select different output formats using <option>-c</option>
|
||||
and <option>-m</option>.
|
||||
</para>
|
||||
<para>
|
||||
The output filenames will
|
||||
be exactly the same as the input filenames or "STDIN" if the input is
|
||||
coming from standard input. Therefore, you must be careful that the
|
||||
output file does not go into the same directory as the input
|
||||
file. Otherwise, <command>&dhpackage;</command> will delete the
|
||||
input file before it generates the output file (just like running
|
||||
<literal>cat < file > file</literal> in most shells).
|
||||
</para>
|
||||
<para>
|
||||
Two structurally equivalent XML documents have a byte-for-byte
|
||||
identical canonical XML representation.
|
||||
Note that ignorable white space is considered significant and
|
||||
is treated equivalently to data.
|
||||
More on canonical XML can be found at
|
||||
http://www.jclark.com/xml/canonxml.html .
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-e encoding</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specifies the character encoding for the document, overriding
|
||||
any document encoding declaration. <command>&dhpackage;</command>
|
||||
supports four built-in encodings:
|
||||
<literal>US-ASCII</literal>,
|
||||
<literal>UTF-8</literal>,
|
||||
<literal>UTF-16</literal>, and
|
||||
<literal>ISO-8859-1</literal>.
|
||||
Also see the <option>-w</option> option.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-m</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Outputs some strange sort of XML file that completely
|
||||
describes the input file, including character positions.
|
||||
Requires <option>-d</option> to specify an output file.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-n</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Turns on namespace processing. (describe namespaces)
|
||||
<option>-c</option> disables namespaces.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-p</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Tells xmlwf to process external DTDs and parameter
|
||||
entities.
|
||||
</para>
|
||||
<para>
|
||||
Normally <command>&dhpackage;</command> never parses parameter
|
||||
entities. <option>-p</option> tells it to always parse them.
|
||||
<option>-p</option> implies <option>-x</option>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-r</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Normally <command>&dhpackage;</command> memory-maps the XML file
|
||||
before parsing; this can result in faster parsing on many
|
||||
platforms.
|
||||
<option>-r</option> turns off memory-mapping and uses normal file
|
||||
IO calls instead.
|
||||
Of course, memory-mapping is automatically turned off
|
||||
when reading from standard input.
|
||||
</para>
|
||||
<para>
|
||||
Use of memory-mapping can cause some platforms to report
|
||||
substantially higher memory usage for
|
||||
<command>&dhpackage;</command>, but this appears to be a matter of
|
||||
the operating system reporting memory in a strange way; there is
|
||||
not a leak in <command>&dhpackage;</command>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-s</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints an error if the document is not standalone.
|
||||
A document is standalone if it has no external subset and no
|
||||
references to parameter entities.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-t</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Turns on timings. This tells Expat to parse the entire file,
|
||||
but not perform any processing.
|
||||
This gives a fairly accurate idea of the raw speed of Expat itself
|
||||
without client overhead.
|
||||
<option>-t</option> turns off most of the output options
|
||||
(<option>-d</option>, <option>-m</option>, <option>-c</option>, ...).
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-v</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Prints the version of the Expat library being used, including some
|
||||
information on the compile-time configuration of the library, and
|
||||
then exits.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-w</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Enables support for Windows code pages.
|
||||
Normally, <command>&dhpackage;</command> will throw an error if it
|
||||
runs across an encoding that it is not equipped to handle itself. With
|
||||
<option>-w</option>, &dhpackage; will try to use a Windows code
|
||||
page. See also <option>-e</option>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>-x</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Turns on parsing external entities.
|
||||
</para>
|
||||
<para>
|
||||
Non-validating parsers are not required to resolve external
|
||||
entities, or even expand entities at all.
|
||||
Expat always expands internal entities (?),
|
||||
but external entity parsing must be enabled explicitly.
|
||||
</para>
|
||||
<para>
|
||||
External entities are simply entities that obtain their
|
||||
data from outside the XML file currently being parsed.
|
||||
</para>
|
||||
<para>
|
||||
This is an example of an internal entity:
|
||||
<literallayout>
|
||||
<!ENTITY vers '1.0.2'>
|
||||
</literallayout>
|
||||
</para>
|
||||
<para>
|
||||
And here are some examples of external entities:
|
||||
|
||||
<literallayout>
|
||||
<!ENTITY header SYSTEM "header-&vers;.xml"> (parsed)
|
||||
<!ENTITY logo SYSTEM "logo.png" PNG> (unparsed)
|
||||
</literallayout>
|
||||
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><option>--</option></term>
|
||||
<listitem>
|
||||
<para>
|
||||
(Two hyphens.)
|
||||
Terminates the list of options. This is only needed if a filename
|
||||
starts with a hyphen. For example:
|
||||
</para>
|
||||
<literallayout>
|
||||
&dhpackage; -- -myfile.xml
|
||||
</literallayout>
|
||||
<para>
|
||||
will run <command>&dhpackage;</command> on the file
|
||||
<filename>-myfile.xml</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
||||
<para>
|
||||
Older versions of <command>&dhpackage;</command> do not support
|
||||
reading from standard input.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>OUTPUT</title>
|
||||
<para>
|
||||
If an input file is not well-formed,
|
||||
<command>&dhpackage;</command> prints a single line describing
|
||||
the problem to standard output. If a file is well formed,
|
||||
<command>&dhpackage;</command> outputs nothing.
|
||||
Note that the result code is <emphasis>not</emphasis> set.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>BUGS</title>
|
||||
<para>
|
||||
<command>&dhpackage;</command> returns a 0 - noerr result,
|
||||
even if the file is not well-formed. There is no good way for
|
||||
a program to use <command>&dhpackage;</command> to quickly
|
||||
check a file -- it must parse <command>&dhpackage;</command>'s
|
||||
standard output.
|
||||
</para>
|
||||
<para>
|
||||
The errors should go to standard error, not standard output.
|
||||
</para>
|
||||
<para>
|
||||
There should be a way to get <option>-d</option> to send its
|
||||
output to standard output rather than forcing the user to send
|
||||
it to a file.
|
||||
</para>
|
||||
<para>
|
||||
I have no idea why anyone would want to use the
|
||||
<option>-d</option>, <option>-c</option>, and
|
||||
<option>-m</option> options. If someone could explain it to
|
||||
me, I'd like to add this information to this manpage.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>ALTERNATIVES</title>
|
||||
<para>
|
||||
Here are some XML validators on the web:
|
||||
|
||||
<literallayout>
|
||||
http://www.hcrc.ed.ac.uk/~richard/xml-check.html
|
||||
http://www.stg.brown.edu/service/xmlvalid/
|
||||
http://www.scripting.com/frontier5/xml/code/xmlValidator.html
|
||||
http://www.xml.com/pub/a/tools/ruwf/check.html
|
||||
</literallayout>
|
||||
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>SEE ALSO</title>
|
||||
<para>
|
||||
|
||||
<literallayout>
|
||||
The Expat home page: http://www.libexpat.org/
|
||||
The W3 XML specification: http://www.w3.org/TR/REC-xml
|
||||
</literallayout>
|
||||
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1>
|
||||
<title>AUTHOR</title>
|
||||
<para>
|
||||
This manual page was written by &dhusername; &dhemail; for
|
||||
the &debian; system (but may be used by others). Permission is
|
||||
granted to copy, distribute and/or modify this document under
|
||||
the terms of the <acronym>GNU</acronym> Free Documentation
|
||||
License, Version 1.1.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
sgml-omittag:t
|
||||
sgml-shorttag:t
|
||||
sgml-minimize-attributes:nil
|
||||
sgml-always-quote-attributes:t
|
||||
sgml-indent-step:2
|
||||
sgml-indent-data:t
|
||||
sgml-parent-document:nil
|
||||
sgml-default-dtd-file:nil
|
||||
sgml-exposed-tags:nil
|
||||
sgml-local-catalogs:nil
|
||||
sgml-local-ecat-files:nil
|
||||
End:
|
||||
-->
|
66
external/mit/expat/dist/lib/xmlparse.c
vendored
66
external/mit/expat/dist/lib/xmlparse.c
vendored
@ -6,11 +6,18 @@
|
||||
#include <string.h> /* memset(), memcpy() */
|
||||
#include <assert.h>
|
||||
#include <limits.h> /* UINT_MAX */
|
||||
#include <time.h> /* time() */
|
||||
|
||||
#ifdef WIN32
|
||||
#define getpid GetCurrentProcessId
|
||||
#else
|
||||
#include <sys/time.h> /* gettimeofday() */
|
||||
#include <sys/types.h> /* getpid() */
|
||||
#include <unistd.h> /* getpid() */
|
||||
#endif
|
||||
|
||||
#define XML_BUILDING_EXPAT 1
|
||||
|
||||
#ifdef COMPILED_FROM_DSP
|
||||
#ifdef WIN32
|
||||
#include "winconfig.h"
|
||||
#elif defined(MACOS_CLASSIC)
|
||||
#include "macconfig.h"
|
||||
@ -20,7 +27,7 @@
|
||||
#include "watcomconfig.h"
|
||||
#elif defined(HAVE_EXPAT_CONFIG_H)
|
||||
#include <expat_config.h>
|
||||
#endif /* ndef COMPILED_FROM_DSP */
|
||||
#endif /* ndef WIN32 */
|
||||
|
||||
#include "ascii.h"
|
||||
#include "expat.h"
|
||||
@ -432,7 +439,7 @@ static ELEMENT_TYPE *
|
||||
getElementType(XML_Parser parser, const ENCODING *enc,
|
||||
const char *ptr, const char *end);
|
||||
|
||||
static unsigned long generate_hash_secret_salt(void);
|
||||
static unsigned long generate_hash_secret_salt(XML_Parser parser);
|
||||
static XML_Bool startParsing(XML_Parser parser);
|
||||
|
||||
static XML_Parser
|
||||
@ -691,11 +698,38 @@ static const XML_Char implicitContext[] = {
|
||||
};
|
||||
|
||||
static unsigned long
|
||||
generate_hash_secret_salt(void)
|
||||
gather_time_entropy(void)
|
||||
{
|
||||
unsigned int seed = time(NULL) % UINT_MAX;
|
||||
srand(seed);
|
||||
return rand();
|
||||
#ifdef WIN32
|
||||
FILETIME ft;
|
||||
GetSystemTimeAsFileTime(&ft); /* never fails */
|
||||
return ft.dwHighDateTime ^ ft.dwLowDateTime;
|
||||
#else
|
||||
struct timeval tv;
|
||||
int gettimeofday_res;
|
||||
|
||||
gettimeofday_res = gettimeofday(&tv, NULL);
|
||||
assert (gettimeofday_res == 0);
|
||||
|
||||
/* Microseconds time is <20 bits entropy */
|
||||
return tv.tv_usec;
|
||||
#endif
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
generate_hash_secret_salt(XML_Parser parser)
|
||||
{
|
||||
/* Process ID is 0 bits entropy if attacker has local access
|
||||
* XML_Parser address is few bits of entropy if attacker has local access */
|
||||
const unsigned long entropy =
|
||||
gather_time_entropy() ^ getpid() ^ (unsigned long)parser;
|
||||
|
||||
/* Factors are 2^31-1 and 2^61-1 (Mersenne primes M31 and M61) */
|
||||
if (sizeof(unsigned long) == 4) {
|
||||
return entropy * 2147483647;
|
||||
} else {
|
||||
return entropy * (unsigned long)2305843009213693951;
|
||||
}
|
||||
}
|
||||
|
||||
static XML_Bool /* only valid for root parser */
|
||||
@ -703,7 +737,7 @@ startParsing(XML_Parser parser)
|
||||
{
|
||||
/* hash functions must be initialized before setContext() is called */
|
||||
if (hash_secret_salt == 0)
|
||||
hash_secret_salt = generate_hash_secret_salt();
|
||||
hash_secret_salt = generate_hash_secret_salt(parser);
|
||||
if (ns) {
|
||||
/* implicit context only set for root parser, since child
|
||||
parsers (i.e. external entity parsers) will inherit it
|
||||
@ -1693,6 +1727,9 @@ XML_GetBuffer(XML_Parser parser, int len)
|
||||
}
|
||||
|
||||
if (len > bufferLim - bufferEnd) {
|
||||
#ifdef XML_CONTEXT_BYTES
|
||||
int keep;
|
||||
#endif /* defined XML_CONTEXT_BYTES */
|
||||
/* Do not invoke signed arithmetic overflow: */
|
||||
int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr));
|
||||
if (neededSize < 0) {
|
||||
@ -1700,8 +1737,7 @@ XML_GetBuffer(XML_Parser parser, int len)
|
||||
return NULL;
|
||||
}
|
||||
#ifdef XML_CONTEXT_BYTES
|
||||
int keep = (int)(bufferPtr - buffer);
|
||||
|
||||
keep = (int)(bufferPtr - buffer);
|
||||
if (keep > XML_CONTEXT_BYTES)
|
||||
keep = XML_CONTEXT_BYTES;
|
||||
neededSize += keep;
|
||||
@ -1854,7 +1890,7 @@ XML_Index XMLCALL
|
||||
XML_GetCurrentByteIndex(XML_Parser parser)
|
||||
{
|
||||
if (eventPtr)
|
||||
return parseEndByteIndex - (parseEndPtr - eventPtr);
|
||||
return (XML_Index)(parseEndByteIndex - (parseEndPtr - eventPtr));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -4926,9 +4962,9 @@ internalEntityProcessor(XML_Parser parser,
|
||||
|
||||
static enum XML_Error PTRCALL
|
||||
errorProcessor(XML_Parser parser,
|
||||
const char *s,
|
||||
const char *end,
|
||||
const char **nextPtr)
|
||||
const char *UNUSED_P(s),
|
||||
const char *UNUSED_P(end),
|
||||
const char **UNUSED_P(nextPtr))
|
||||
{
|
||||
return errorCode;
|
||||
}
|
||||
|
111
external/mit/expat/dist/lib/xmltok.c
vendored
111
external/mit/expat/dist/lib/xmltok.c
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef COMPILED_FROM_DSP
|
||||
#ifdef WIN32
|
||||
#include "winconfig.h"
|
||||
#elif defined(MACOS_CLASSIC)
|
||||
#include "macconfig.h"
|
||||
@ -16,7 +16,7 @@
|
||||
#ifdef HAVE_EXPAT_CONFIG_H
|
||||
#include <expat_config.h>
|
||||
#endif
|
||||
#endif /* ndef COMPILED_FROM_DSP */
|
||||
#endif /* ndef WIN32 */
|
||||
|
||||
#include "expat_external.h"
|
||||
#include "internal.h"
|
||||
@ -122,19 +122,19 @@
|
||||
((*p) == 0xF4 ? (p)[1] > 0x8F : ((p)[1] & 0xC0) == 0xC0)))
|
||||
|
||||
static int PTRFASTCALL
|
||||
isNever(const ENCODING *enc, const char *p)
|
||||
isNever(const ENCODING *UNUSED_P(enc), const char *UNUSED_P(p))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isName2(const ENCODING *enc, const char *p)
|
||||
utf8_isName2(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_GET_NAMING2(namePages, (const unsigned char *)p);
|
||||
}
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isName3(const ENCODING *enc, const char *p)
|
||||
utf8_isName3(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_GET_NAMING3(namePages, (const unsigned char *)p);
|
||||
}
|
||||
@ -142,13 +142,13 @@ utf8_isName3(const ENCODING *enc, const char *p)
|
||||
#define utf8_isName4 isNever
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isNmstrt2(const ENCODING *enc, const char *p)
|
||||
utf8_isNmstrt2(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_GET_NAMING2(nmstrtPages, (const unsigned char *)p);
|
||||
}
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isNmstrt3(const ENCODING *enc, const char *p)
|
||||
utf8_isNmstrt3(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_GET_NAMING3(nmstrtPages, (const unsigned char *)p);
|
||||
}
|
||||
@ -156,19 +156,19 @@ utf8_isNmstrt3(const ENCODING *enc, const char *p)
|
||||
#define utf8_isNmstrt4 isNever
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isInvalid2(const ENCODING *enc, const char *p)
|
||||
utf8_isInvalid2(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_INVALID2((const unsigned char *)p);
|
||||
}
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isInvalid3(const ENCODING *enc, const char *p)
|
||||
utf8_isInvalid3(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_INVALID3((const unsigned char *)p);
|
||||
}
|
||||
|
||||
static int PTRFASTCALL
|
||||
utf8_isInvalid4(const ENCODING *enc, const char *p)
|
||||
utf8_isInvalid4(const ENCODING *UNUSED_P(enc), const char *p)
|
||||
{
|
||||
return UTF8_INVALID4((const unsigned char *)p);
|
||||
}
|
||||
@ -222,6 +222,17 @@ struct normal_encoding {
|
||||
E ## isInvalid3, \
|
||||
E ## isInvalid4
|
||||
|
||||
#define NULL_VTABLE \
|
||||
/* isName2 */ NULL, \
|
||||
/* isName3 */ NULL, \
|
||||
/* isName4 */ NULL, \
|
||||
/* isNmstrt2 */ NULL, \
|
||||
/* isNmstrt3 */ NULL, \
|
||||
/* isNmstrt4 */ NULL, \
|
||||
/* isInvalid2 */ NULL, \
|
||||
/* isInvalid3 */ NULL, \
|
||||
/* isInvalid4 */ NULL
|
||||
|
||||
static int FASTCALL checkCharRefNumber(int);
|
||||
|
||||
#include "xmltok_impl.h"
|
||||
@ -318,8 +329,43 @@ enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */
|
||||
UTF8_cval4 = 0xf0
|
||||
};
|
||||
|
||||
void
|
||||
align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef)
|
||||
{
|
||||
const char * fromLim = *fromLimRef;
|
||||
size_t walked = 0;
|
||||
for (; fromLim > from; fromLim--, walked++) {
|
||||
const unsigned char prev = (unsigned char)fromLim[-1];
|
||||
if ((prev & 0xf8u) == 0xf0u) { /* 4-byte character, lead by 0b11110xxx byte */
|
||||
if (walked + 1 >= 4) {
|
||||
fromLim += 4 - 1;
|
||||
break;
|
||||
} else {
|
||||
walked = 0;
|
||||
}
|
||||
} else if ((prev & 0xf0u) == 0xe0u) { /* 3-byte character, lead by 0b1110xxxx byte */
|
||||
if (walked + 1 >= 3) {
|
||||
fromLim += 3 - 1;
|
||||
break;
|
||||
} else {
|
||||
walked = 0;
|
||||
}
|
||||
} else if ((prev & 0xe0u) == 0xc0u) { /* 2-byte character, lead by 0b110xxxxx byte */
|
||||
if (walked + 1 >= 2) {
|
||||
fromLim += 2 - 1;
|
||||
break;
|
||||
} else {
|
||||
walked = 0;
|
||||
}
|
||||
} else if ((prev & 0x80u) == 0x00u) { /* 1-byte character, matching 0b0xxxxxxx */
|
||||
break;
|
||||
}
|
||||
}
|
||||
*fromLimRef = fromLim;
|
||||
}
|
||||
|
||||
static enum XML_Convert_Result PTRCALL
|
||||
utf8_toUtf8(const ENCODING *enc,
|
||||
utf8_toUtf8(const ENCODING *UNUSED_P(enc),
|
||||
const char **fromP, const char *fromLim,
|
||||
char **toP, const char *toLim)
|
||||
{
|
||||
@ -329,9 +375,8 @@ utf8_toUtf8(const ENCODING *enc,
|
||||
if (fromLim - *fromP > toLim - *toP) {
|
||||
/* Avoid copying partial characters. */
|
||||
res = XML_CONVERT_OUTPUT_EXHAUSTED;
|
||||
for (fromLim = *fromP + (toLim - *toP); fromLim > *fromP; fromLim--)
|
||||
if (((unsigned char)fromLim[-1] & 0xc0) != 0x80)
|
||||
break;
|
||||
fromLim = *fromP + (toLim - *toP);
|
||||
align_limit_to_full_utf8_characters(*fromP, &fromLim);
|
||||
}
|
||||
for (to = *toP, from = *fromP; (from < fromLim) && (to < toLim); from++, to++)
|
||||
*to = *from;
|
||||
@ -449,7 +494,7 @@ static const struct normal_encoding internal_utf8_encoding = {
|
||||
};
|
||||
|
||||
static enum XML_Convert_Result PTRCALL
|
||||
latin1_toUtf8(const ENCODING *enc,
|
||||
latin1_toUtf8(const ENCODING *UNUSED_P(enc),
|
||||
const char **fromP, const char *fromLim,
|
||||
char **toP, const char *toLim)
|
||||
{
|
||||
@ -474,7 +519,7 @@ latin1_toUtf8(const ENCODING *enc,
|
||||
}
|
||||
|
||||
static enum XML_Convert_Result PTRCALL
|
||||
latin1_toUtf16(const ENCODING *enc,
|
||||
latin1_toUtf16(const ENCODING *UNUSED_P(enc),
|
||||
const char **fromP, const char *fromLim,
|
||||
unsigned short **toP, const unsigned short *toLim)
|
||||
{
|
||||
@ -495,7 +540,7 @@ static const struct normal_encoding latin1_encoding_ns = {
|
||||
#include "asciitab.h"
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(sb_)
|
||||
STANDARD_VTABLE(sb_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -508,11 +553,11 @@ static const struct normal_encoding latin1_encoding = {
|
||||
#undef BT_COLON
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(sb_)
|
||||
STANDARD_VTABLE(sb_) NULL_VTABLE
|
||||
};
|
||||
|
||||
static enum XML_Convert_Result PTRCALL
|
||||
ascii_toUtf8(const ENCODING *enc,
|
||||
ascii_toUtf8(const ENCODING *UNUSED_P(enc),
|
||||
const char **fromP, const char *fromLim,
|
||||
char **toP, const char *toLim)
|
||||
{
|
||||
@ -533,7 +578,7 @@ static const struct normal_encoding ascii_encoding_ns = {
|
||||
#include "asciitab.h"
|
||||
/* BT_NONXML == 0 */
|
||||
},
|
||||
STANDARD_VTABLE(sb_)
|
||||
STANDARD_VTABLE(sb_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -546,7 +591,7 @@ static const struct normal_encoding ascii_encoding = {
|
||||
#undef BT_COLON
|
||||
/* BT_NONXML == 0 */
|
||||
},
|
||||
STANDARD_VTABLE(sb_)
|
||||
STANDARD_VTABLE(sb_) NULL_VTABLE
|
||||
};
|
||||
|
||||
static int PTRFASTCALL
|
||||
@ -570,7 +615,7 @@ unicode_byte_type(char hi, char lo)
|
||||
|
||||
#define DEFINE_UTF16_TO_UTF8(E) \
|
||||
static enum XML_Convert_Result PTRCALL \
|
||||
E ## toUtf8(const ENCODING *enc, \
|
||||
E ## toUtf8(const ENCODING *UNUSED_P(enc), \
|
||||
const char **fromP, const char *fromLim, \
|
||||
char **toP, const char *toLim) \
|
||||
{ \
|
||||
@ -616,7 +661,7 @@ E ## toUtf8(const ENCODING *enc, \
|
||||
*fromP = from; \
|
||||
return XML_CONVERT_OUTPUT_EXHAUSTED; \
|
||||
} \
|
||||
if (from + 4 > fromLim) { \
|
||||
if (fromLim - from < 4) { \
|
||||
*fromP = from; \
|
||||
return XML_CONVERT_INPUT_INCOMPLETE; \
|
||||
} \
|
||||
@ -642,7 +687,7 @@ E ## toUtf8(const ENCODING *enc, \
|
||||
|
||||
#define DEFINE_UTF16_TO_UTF16(E) \
|
||||
static enum XML_Convert_Result PTRCALL \
|
||||
E ## toUtf16(const ENCODING *enc, \
|
||||
E ## toUtf16(const ENCODING *UNUSED_P(enc), \
|
||||
const char **fromP, const char *fromLim, \
|
||||
unsigned short **toP, const unsigned short *toLim) \
|
||||
{ \
|
||||
@ -776,7 +821,7 @@ static const struct normal_encoding little2_encoding_ns = {
|
||||
#include "asciitab.h"
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(little2_)
|
||||
STANDARD_VTABLE(little2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -795,7 +840,7 @@ static const struct normal_encoding little2_encoding = {
|
||||
#undef BT_COLON
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(little2_)
|
||||
STANDARD_VTABLE(little2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#if BYTEORDER != 4321
|
||||
@ -808,7 +853,7 @@ static const struct normal_encoding internal_little2_encoding_ns = {
|
||||
#include "iasciitab.h"
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(little2_)
|
||||
STANDARD_VTABLE(little2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -821,7 +866,7 @@ static const struct normal_encoding internal_little2_encoding = {
|
||||
#undef BT_COLON
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(little2_)
|
||||
STANDARD_VTABLE(little2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -917,7 +962,7 @@ static const struct normal_encoding big2_encoding_ns = {
|
||||
#include "asciitab.h"
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(big2_)
|
||||
STANDARD_VTABLE(big2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -936,7 +981,7 @@ static const struct normal_encoding big2_encoding = {
|
||||
#undef BT_COLON
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(big2_)
|
||||
STANDARD_VTABLE(big2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#if BYTEORDER != 1234
|
||||
@ -949,7 +994,7 @@ static const struct normal_encoding internal_big2_encoding_ns = {
|
||||
#include "iasciitab.h"
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(big2_)
|
||||
STANDARD_VTABLE(big2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -962,7 +1007,7 @@ static const struct normal_encoding internal_big2_encoding = {
|
||||
#undef BT_COLON
|
||||
#include "latin1tab.h"
|
||||
},
|
||||
STANDARD_VTABLE(big2_)
|
||||
STANDARD_VTABLE(big2_) NULL_VTABLE
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -988,7 +1033,7 @@ streqci(const char *s1, const char *s2)
|
||||
}
|
||||
|
||||
static void PTRCALL
|
||||
initUpdatePosition(const ENCODING *enc, const char *ptr,
|
||||
initUpdatePosition(const ENCODING *UNUSED_P(enc), const char *ptr,
|
||||
const char *end, POSITION *pos)
|
||||
{
|
||||
normal_updatePosition(&utf8_encoding.enc, ptr, end, pos);
|
||||
|
216
external/mit/expat/dist/lib/xmltok_impl.c
vendored
216
external/mit/expat/dist/lib/xmltok_impl.c
vendored
@ -87,27 +87,45 @@
|
||||
#define PREFIX(ident) ident
|
||||
#endif
|
||||
|
||||
|
||||
#define HAS_CHARS(enc, ptr, end, count) \
|
||||
(end - ptr >= count * MINBPC(enc))
|
||||
|
||||
#define HAS_CHAR(enc, ptr, end) \
|
||||
HAS_CHARS(enc, ptr, end, 1)
|
||||
|
||||
#define REQUIRE_CHARS(enc, ptr, end, count) \
|
||||
{ \
|
||||
if (! HAS_CHARS(enc, ptr, end, count)) { \
|
||||
return XML_TOK_PARTIAL; \
|
||||
} \
|
||||
}
|
||||
|
||||
#define REQUIRE_CHAR(enc, ptr, end) \
|
||||
REQUIRE_CHARS(enc, ptr, end, 1)
|
||||
|
||||
|
||||
/* ptr points to character following "<!-" */
|
||||
|
||||
static int PTRCALL
|
||||
PREFIX(scanComment)(const ENCODING *enc, const char *ptr,
|
||||
const char *end, const char **nextTokPtr)
|
||||
{
|
||||
if (ptr < end) {
|
||||
if (HAS_CHAR(enc, ptr, end)) {
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
ptr += MINBPC(enc);
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
INVALID_CASES(ptr, nextTokPtr)
|
||||
case BT_MINUS:
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_MINUS)) {
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
@ -131,8 +149,7 @@ static int PTRCALL
|
||||
PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
|
||||
const char *end, const char **nextTokPtr)
|
||||
{
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_MINUS:
|
||||
return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||
@ -147,11 +164,10 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_PERCNT:
|
||||
if (ptr + MINBPC(enc) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHARS(enc, ptr, end, 2);
|
||||
/* don't allow <!ENTITY% foo "whatever"> */
|
||||
switch (BYTE_TYPE(enc, ptr + MINBPC(enc))) {
|
||||
case BT_S: case BT_CR: case BT_LF: case BT_PERCNT:
|
||||
@ -175,7 +191,7 @@ PREFIX(scanDecl)(const ENCODING *enc, const char *ptr,
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
PREFIX(checkPiTarget)(const ENCODING *enc, const char *ptr,
|
||||
PREFIX(checkPiTarget)(const ENCODING *UNUSED_P(enc), const char *ptr,
|
||||
const char *end, int *tokPtr)
|
||||
{
|
||||
int upper = 0;
|
||||
@ -225,15 +241,14 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
||||
{
|
||||
int tok;
|
||||
const char *target = ptr;
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
default:
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_S: case BT_CR: case BT_LF:
|
||||
@ -242,13 +257,12 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
ptr += MINBPC(enc);
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
INVALID_CASES(ptr, nextTokPtr)
|
||||
case BT_QUEST:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
*nextTokPtr = ptr + MINBPC(enc);
|
||||
return tok;
|
||||
@ -266,8 +280,7 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
*nextTokPtr = ptr + MINBPC(enc);
|
||||
return tok;
|
||||
@ -282,15 +295,14 @@ PREFIX(scanPi)(const ENCODING *enc, const char *ptr,
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
PREFIX(scanCdataSection)(const ENCODING *enc, const char *ptr,
|
||||
PREFIX(scanCdataSection)(const ENCODING *UNUSED_P(enc), const char *ptr,
|
||||
const char *end, const char **nextTokPtr)
|
||||
{
|
||||
static const char CDATA_LSQB[] = { ASCII_C, ASCII_D, ASCII_A,
|
||||
ASCII_T, ASCII_A, ASCII_LSQB };
|
||||
int i;
|
||||
/* CDATA[ */
|
||||
if (end - ptr < 6 * MINBPC(enc))
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHARS(enc, ptr, end, 6);
|
||||
for (i = 0; i < 6; i++, ptr += MINBPC(enc)) {
|
||||
if (!CHAR_MATCHES(enc, ptr, CDATA_LSQB[i])) {
|
||||
*nextTokPtr = ptr;
|
||||
@ -319,13 +331,11 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_RSQB:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
|
||||
break;
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
ptr -= MINBPC(enc);
|
||||
break;
|
||||
@ -334,8 +344,7 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
|
||||
return XML_TOK_CDATA_SECT_CLOSE;
|
||||
case BT_CR:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (BYTE_TYPE(enc, ptr) == BT_LF)
|
||||
ptr += MINBPC(enc);
|
||||
*nextTokPtr = ptr;
|
||||
@ -348,7 +357,7 @@ PREFIX(cdataSectionTok)(const ENCODING *enc, const char *ptr,
|
||||
ptr += MINBPC(enc);
|
||||
break;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
#define LEAD_CASE(n) \
|
||||
case BT_LEAD ## n: \
|
||||
@ -383,19 +392,18 @@ static int PTRCALL
|
||||
PREFIX(scanEndTag)(const ENCODING *enc, const char *ptr,
|
||||
const char *end, const char **nextTokPtr)
|
||||
{
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
default:
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_S: case BT_CR: case BT_LF:
|
||||
for (ptr += MINBPC(enc); ptr < end; ptr += MINBPC(enc)) {
|
||||
for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_S: case BT_CR: case BT_LF:
|
||||
break;
|
||||
@ -432,7 +440,7 @@ static int PTRCALL
|
||||
PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
|
||||
const char *end, const char **nextTokPtr)
|
||||
{
|
||||
if (ptr < end) {
|
||||
if (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_DIGIT:
|
||||
case BT_HEX:
|
||||
@ -441,7 +449,7 @@ PREFIX(scanHexCharRef)(const ENCODING *enc, const char *ptr,
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
for (ptr += MINBPC(enc); ptr < end; ptr += MINBPC(enc)) {
|
||||
for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_DIGIT:
|
||||
case BT_HEX:
|
||||
@ -464,7 +472,7 @@ static int PTRCALL
|
||||
PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
|
||||
const char *end, const char **nextTokPtr)
|
||||
{
|
||||
if (ptr < end) {
|
||||
if (HAS_CHAR(enc, ptr, end)) {
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_x))
|
||||
return PREFIX(scanHexCharRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
@ -474,7 +482,7 @@ PREFIX(scanCharRef)(const ENCODING *enc, const char *ptr,
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
for (ptr += MINBPC(enc); ptr < end; ptr += MINBPC(enc)) {
|
||||
for (ptr += MINBPC(enc); HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_DIGIT:
|
||||
break;
|
||||
@ -496,8 +504,7 @@ static int PTRCALL
|
||||
PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_NUM:
|
||||
@ -506,7 +513,7 @@ PREFIX(scanRef)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_SEMI:
|
||||
@ -529,7 +536,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
#ifdef XML_NS
|
||||
int hadColon = 0;
|
||||
#endif
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
#ifdef XML_NS
|
||||
@ -540,8 +547,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
}
|
||||
hadColon = 1;
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
default:
|
||||
@ -555,8 +561,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
int t;
|
||||
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
t = BYTE_TYPE(enc, ptr);
|
||||
if (t == BT_EQUALS)
|
||||
break;
|
||||
@ -579,8 +584,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
#endif
|
||||
for (;;) {
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
open = BYTE_TYPE(enc, ptr);
|
||||
if (open == BT_QUOT || open == BT_APOS)
|
||||
break;
|
||||
@ -598,8 +602,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
/* in attribute value */
|
||||
for (;;) {
|
||||
int t;
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
t = BYTE_TYPE(enc, ptr);
|
||||
if (t == open)
|
||||
break;
|
||||
@ -624,8 +627,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
}
|
||||
}
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_S:
|
||||
case BT_CR:
|
||||
@ -642,8 +644,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
/* ptr points to closing quote */
|
||||
for (;;) {
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_S: case BT_CR: case BT_LF:
|
||||
@ -655,8 +656,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
case BT_SOL:
|
||||
sol:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
@ -688,13 +688,12 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
#ifdef XML_NS
|
||||
int hadColon;
|
||||
#endif
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_EXCL:
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_MINUS:
|
||||
return PREFIX(scanComment)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||
@ -716,7 +715,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
hadColon = 0;
|
||||
#endif
|
||||
/* we have a start-tag */
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
#ifdef XML_NS
|
||||
@ -727,8 +726,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
}
|
||||
hadColon = 1;
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
default:
|
||||
@ -740,7 +738,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
case BT_S: case BT_CR: case BT_LF:
|
||||
{
|
||||
ptr += MINBPC(enc);
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_GT:
|
||||
@ -765,8 +763,7 @@ PREFIX(scanLt)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
case BT_SOL:
|
||||
sol:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
@ -803,7 +800,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
return PREFIX(scanRef)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||
case BT_CR:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_TRAILING_CR;
|
||||
if (BYTE_TYPE(enc, ptr) == BT_LF)
|
||||
ptr += MINBPC(enc);
|
||||
@ -814,12 +811,12 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
return XML_TOK_DATA_NEWLINE;
|
||||
case BT_RSQB:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_TRAILING_RSQB;
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_RSQB))
|
||||
break;
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_TRAILING_RSQB;
|
||||
if (!CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
ptr -= MINBPC(enc);
|
||||
@ -832,7 +829,7 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
ptr += MINBPC(enc);
|
||||
break;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
#define LEAD_CASE(n) \
|
||||
case BT_LEAD ## n: \
|
||||
@ -845,12 +842,12 @@ PREFIX(contentTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
LEAD_CASE(2) LEAD_CASE(3) LEAD_CASE(4)
|
||||
#undef LEAD_CASE
|
||||
case BT_RSQB:
|
||||
if (ptr + MINBPC(enc) != end) {
|
||||
if (HAS_CHARS(enc, ptr, end, 2)) {
|
||||
if (!CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_RSQB)) {
|
||||
ptr += MINBPC(enc);
|
||||
break;
|
||||
}
|
||||
if (ptr + 2*MINBPC(enc) != end) {
|
||||
if (HAS_CHARS(enc, ptr, end, 3)) {
|
||||
if (!CHAR_MATCHES(enc, ptr + 2*MINBPC(enc), ASCII_GT)) {
|
||||
ptr += MINBPC(enc);
|
||||
break;
|
||||
@ -884,8 +881,7 @@ static int PTRCALL
|
||||
PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_S: case BT_LF: case BT_CR: case BT_PERCNT:
|
||||
@ -895,7 +891,7 @@ PREFIX(scanPercent)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_SEMI:
|
||||
@ -913,15 +909,14 @@ static int PTRCALL
|
||||
PREFIX(scanPoundName)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NMSTRT_CASES(enc, ptr, end, nextTokPtr)
|
||||
default:
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_CR: case BT_LF: case BT_S:
|
||||
@ -941,7 +936,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc,
|
||||
const char *ptr, const char *end,
|
||||
const char **nextTokPtr)
|
||||
{
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
int t = BYTE_TYPE(enc, ptr);
|
||||
switch (t) {
|
||||
INVALID_CASES(ptr, nextTokPtr)
|
||||
@ -950,7 +945,7 @@ PREFIX(scanLit)(int open, const ENCODING *enc,
|
||||
ptr += MINBPC(enc);
|
||||
if (t != open)
|
||||
break;
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return -XML_TOK_LITERAL;
|
||||
*nextTokPtr = ptr;
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
@ -992,8 +987,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
case BT_LT:
|
||||
{
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_EXCL:
|
||||
return PREFIX(scanDecl)(enc, ptr + MINBPC(enc), end, nextTokPtr);
|
||||
@ -1021,7 +1015,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
case BT_S: case BT_LF:
|
||||
for (;;) {
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
break;
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_S: case BT_LF:
|
||||
@ -1048,11 +1042,10 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
return XML_TOK_OPEN_BRACKET;
|
||||
case BT_RSQB:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return -XML_TOK_CLOSE_BRACKET;
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
|
||||
if (ptr + MINBPC(enc) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHARS(enc, ptr, end, 2);
|
||||
if (CHAR_MATCHES(enc, ptr + MINBPC(enc), ASCII_GT)) {
|
||||
*nextTokPtr = ptr + 2*MINBPC(enc);
|
||||
return XML_TOK_COND_SECT_CLOSE;
|
||||
@ -1065,7 +1058,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
return XML_TOK_OPEN_PAREN;
|
||||
case BT_RPAR:
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return -XML_TOK_CLOSE_PAREN;
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_AST:
|
||||
@ -1141,7 +1134,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
*nextTokPtr = ptr;
|
||||
return XML_TOK_INVALID;
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
case BT_GT: case BT_RPAR: case BT_COMMA:
|
||||
@ -1154,8 +1147,7 @@ PREFIX(prologTok)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
ptr += MINBPC(enc);
|
||||
switch (tok) {
|
||||
case XML_TOK_NAME:
|
||||
if (ptr == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
tok = XML_TOK_PREFIXED_NAME;
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
CHECK_NAME_CASES(enc, ptr, end, nextTokPtr)
|
||||
@ -1206,8 +1198,10 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
|
||||
const char *start;
|
||||
if (ptr >= end)
|
||||
return XML_TOK_NONE;
|
||||
else if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_PARTIAL;
|
||||
start = ptr;
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
#define LEAD_CASE(n) \
|
||||
case BT_LEAD ## n: ptr += n; break;
|
||||
@ -1232,7 +1226,7 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr,
|
||||
case BT_CR:
|
||||
if (ptr == start) {
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_TRAILING_CR;
|
||||
if (BYTE_TYPE(enc, ptr) == BT_LF)
|
||||
ptr += MINBPC(enc);
|
||||
@ -1264,8 +1258,10 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
|
||||
const char *start;
|
||||
if (ptr >= end)
|
||||
return XML_TOK_NONE;
|
||||
else if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_PARTIAL;
|
||||
start = ptr;
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
#define LEAD_CASE(n) \
|
||||
case BT_LEAD ## n: ptr += n; break;
|
||||
@ -1294,7 +1290,7 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr,
|
||||
case BT_CR:
|
||||
if (ptr == start) {
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr == end)
|
||||
if (! HAS_CHAR(enc, ptr, end))
|
||||
return XML_TOK_TRAILING_CR;
|
||||
if (BYTE_TYPE(enc, ptr) == BT_LF)
|
||||
ptr += MINBPC(enc);
|
||||
@ -1326,15 +1322,15 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
|
||||
end = ptr + n;
|
||||
}
|
||||
}
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
INVALID_CASES(ptr, nextTokPtr)
|
||||
case BT_LT:
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_EXCL)) {
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_LSQB)) {
|
||||
++level;
|
||||
ptr += MINBPC(enc);
|
||||
@ -1342,11 +1338,11 @@ PREFIX(ignoreSectionTok)(const ENCODING *enc, const char *ptr,
|
||||
}
|
||||
break;
|
||||
case BT_RSQB:
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_RSQB)) {
|
||||
if ((ptr += MINBPC(enc)) == end)
|
||||
return XML_TOK_PARTIAL;
|
||||
ptr += MINBPC(enc);
|
||||
REQUIRE_CHAR(enc, ptr, end);
|
||||
if (CHAR_MATCHES(enc, ptr, ASCII_GT)) {
|
||||
ptr += MINBPC(enc);
|
||||
if (level == 0) {
|
||||
@ -1373,7 +1369,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end,
|
||||
{
|
||||
ptr += MINBPC(enc);
|
||||
end -= MINBPC(enc);
|
||||
for (; ptr < end; ptr += MINBPC(enc)) {
|
||||
for (; HAS_CHAR(enc, ptr, end); ptr += MINBPC(enc)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
case BT_DIGIT:
|
||||
case BT_HEX:
|
||||
@ -1521,7 +1517,7 @@ PREFIX(getAtts)(const ENCODING *enc, const char *ptr,
|
||||
}
|
||||
|
||||
static int PTRFASTCALL
|
||||
PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
|
||||
PREFIX(charRefNumber)(const ENCODING *UNUSED_P(enc), const char *ptr)
|
||||
{
|
||||
int result = 0;
|
||||
/* skip &# */
|
||||
@ -1565,7 +1561,7 @@ PREFIX(charRefNumber)(const ENCODING *enc, const char *ptr)
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
PREFIX(predefinedEntityName)(const ENCODING *enc, const char *ptr,
|
||||
PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr,
|
||||
const char *end)
|
||||
{
|
||||
switch ((end - ptr)/MINBPC(enc)) {
|
||||
@ -1683,11 +1679,11 @@ PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2)
|
||||
}
|
||||
|
||||
static int PTRCALL
|
||||
PREFIX(nameMatchesAscii)(const ENCODING *enc, const char *ptr1,
|
||||
PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1,
|
||||
const char *end1, const char *ptr2)
|
||||
{
|
||||
for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) {
|
||||
if (ptr1 == end1)
|
||||
if (end1 - ptr1 < MINBPC(enc))
|
||||
return 0;
|
||||
if (!CHAR_MATCHES(enc, ptr1, *ptr2))
|
||||
return 0;
|
||||
@ -1744,7 +1740,7 @@ PREFIX(updatePosition)(const ENCODING *enc,
|
||||
const char *end,
|
||||
POSITION *pos)
|
||||
{
|
||||
while (ptr < end) {
|
||||
while (HAS_CHAR(enc, ptr, end)) {
|
||||
switch (BYTE_TYPE(enc, ptr)) {
|
||||
#define LEAD_CASE(n) \
|
||||
case BT_LEAD ## n: \
|
||||
@ -1760,7 +1756,7 @@ PREFIX(updatePosition)(const ENCODING *enc,
|
||||
case BT_CR:
|
||||
pos->lineNumber++;
|
||||
ptr += MINBPC(enc);
|
||||
if (ptr < end && BYTE_TYPE(enc, ptr) == BT_LF)
|
||||
if (HAS_CHAR(enc, ptr, end) && BYTE_TYPE(enc, ptr) == BT_LF)
|
||||
ptr += MINBPC(enc);
|
||||
pos->columnNumber = (XML_Size)-1;
|
||||
break;
|
||||
|
6
external/mit/expat/dist/tests/xmltest.sh
vendored
6
external/mit/expat/dist/tests/xmltest.sh
vendored
@ -25,9 +25,9 @@ shopt -s nullglob
|
||||
MYDIR="`dirname \"$0\"`"
|
||||
cd "$MYDIR"
|
||||
MYDIR="`pwd`"
|
||||
XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
|
||||
# XMLWF=/usr/local/bin/xmlwf
|
||||
TS="$MYDIR"
|
||||
# XMLWF="`dirname \"$MYDIR\"`/xmlwf/xmlwf"
|
||||
XMLWF=/usr/bin/xmlwf
|
||||
TS="$MYDIR/XML-Test-Suite"
|
||||
# OUTPUT must terminate with the directory separator.
|
||||
OUTPUT="$TS/out/"
|
||||
# OUTPUT=/home/tmp/xml-testsuite-out/
|
||||
|
@ -1,5 +1,5 @@
|
||||
/* expat_config.h. Generated from expat_config.h.in by configure. */
|
||||
/* expat_config.h.in. Generated from configure.in by autoheader. */
|
||||
/* expat_config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
|
||||
#define BYTEORDER BYTE_ORDER
|
||||
@ -52,8 +52,7 @@
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#define HAVE_UNISTD_H 1
|
||||
|
||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
||||
*/
|
||||
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||
#define LT_OBJDIR ".libs/"
|
||||
|
||||
/* Define to the address where bug reports for this package should be sent. */
|
||||
@ -63,7 +62,7 @@
|
||||
#define PACKAGE_NAME "expat"
|
||||
|
||||
/* Define to the full name and version of this package. */
|
||||
#define PACKAGE_STRING "expat 2.1.1"
|
||||
#define PACKAGE_STRING "expat 2.2.0"
|
||||
|
||||
/* Define to the one symbol short name of this package. */
|
||||
#define PACKAGE_TARNAME "expat"
|
||||
@ -72,7 +71,7 @@
|
||||
#define PACKAGE_URL ""
|
||||
|
||||
/* Define to the version of this package. */
|
||||
#define PACKAGE_VERSION "2.1.1"
|
||||
#define PACKAGE_VERSION "2.2.0"
|
||||
|
||||
/* Define to 1 if you have the ANSI C header files. */
|
||||
#define STDC_HEADERS 1
|
||||
|
Loading…
Reference in New Issue
Block a user