···2828#include <libxml/xpath.h>
29293030/*
3131- * XML Canonicazation
3131+ * XML Canonicalization
3232 * http://www.w3.org/TR/xml-c14n
3333 *
3434- * Exclusive XML Canonicazation
3434+ * Exclusive XML Canonicalization
3535 * http://www.w3.org/TR/xml-exc-c14n
3636 *
3737 * Canonical form of an XML document could be created if and only if
3838 * a) default attributes (if any) are added to all nodes
3939 * b) all character and parsed entity references are resolved
4040- * In order to achive this in libxml2 the document MUST be loaded with
4141- * following global setings:
4040+ * In order to achieve this in libxml2 the document MUST be loaded with
4141+ * following global settings:
4242 *
4343 * xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;
4444 * xmlSubstituteEntitiesDefault(1);
···5959 *
6060 */
6161typedef enum {
6262- XML_C14N_1_0 = 0, /* Origianal C14N 1.0 spec */
6262+ XML_C14N_1_0 = 0, /* Original C14N 1.0 spec */
6363 XML_C14N_EXCLUSIVE_1_0 = 1, /* Exclusive C14N 1.0 spec */
6464 XML_C14N_1_1 = 2 /* C14N 1.1 spec */
6565} xmlC14NMode;
···9696/**
9797 * xmlC14NIsVisibleCallback:
9898 * @user_data: user data
9999- * @node: the curent node
9999+ * @node: the current node
100100 * @parent: the parent node
101101 *
102102 * Signature for a C14N callback on visible nodes
+1-1
sdk/include/reactos/libs/libxml/catalog.h
···3939/**
4040 * XML_CATALOG_PI:
4141 *
4242- * The specific XML Catalog Processing Instuction name.
4242+ * The specific XML Catalog Processing Instruction name.
4343 */
4444#define XML_CATALOG_PI \
4545 (const xmlChar *) "oasis-xml-catalog"
···8080/**
8181 * xmlHashScanner:
8282 * @payload: the data in the hash
8383- * @data: extra scannner data
8383+ * @data: extra scanner data
8484 * @name: the name associated
8585 *
8686 * Callback when scanning data in a hash with the simple scanner.
···8989/**
9090 * xmlHashScannerFull:
9191 * @payload: the data in the hash
9292- * @data: extra scannner data
9292+ * @data: extra scanner data
9393 * @name: the name associated
9494 * @name2: the second name associated
9595 * @name3: the third name associated
+4-4
sdk/include/reactos/libs/libxml/parser.h
···283283 void * *pushTab; /* array of data for push */
284284 xmlHashTablePtr attsDefault; /* defaulted attributes if any */
285285 xmlHashTablePtr attsSpecial; /* non-CDATA attributes if any */
286286- int nsWellFormed; /* is the document XML Nanespace okay */
286286+ int nsWellFormed; /* is the document XML Namespace okay */
287287 int options; /* Extra options */
288288289289 /*
290290- * Those fields are needed only for treaming parsing so far
290290+ * Those fields are needed only for streaming parsing so far
291291 */
292292 int dictNames; /* Use dictionary names for the tree */
293293 int freeElemsNr; /* number of freed element nodes */
···10971097 XML_PARSE_PEDANTIC = 1<<7, /* pedantic error reporting */
10981098 XML_PARSE_NOBLANKS = 1<<8, /* remove blank nodes */
10991099 XML_PARSE_SAX1 = 1<<9, /* use the SAX1 interface internally */
11001100- XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitition */
11001100+ XML_PARSE_XINCLUDE = 1<<10,/* Implement XInclude substitution */
11011101 XML_PARSE_NONET = 1<<11,/* Forbid network access */
11021102 XML_PARSE_NODICT = 1<<12,/* Do not reuse the context dictionary */
11031103 XML_PARSE_NSCLEAN = 1<<13,/* remove redundant namespaces declarations */
···11911191/**
11921192 * xmlFeature:
11931193 *
11941194- * Used to examine the existance of features that can be enabled
11941194+ * Used to examine the existence of features that can be enabled
11951195 * or disabled at compile-time.
11961196 * They used to be called XML_FEATURE_xxx but this clashed with Expat
11971197 */
+1-1
sdk/include/reactos/libs/libxml/parserInternals.h
···4343/**
4444 * XML_MAX_NAME_LENGTH:
4545 *
4646- * Maximum size allowed for a markup identitier
4646+ * Maximum size allowed for a markup identifier.
4747 * This is not a limitation of the parser but a safety boundary feature,
4848 * use XML_PARSE_HUGE option to override it.
4949 * Note that with the use of parsing dictionaries overriding the limit
···321321/**
322322 * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:
323323 *
324324- * The attribute wildcard has been already builded.
324324+ * The attribute wildcard has been built.
325325 */
326326#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0
327327/**
328328 * XML_SCHEMAS_ATTRGROUP_GLOBAL:
329329 *
330330- * The attribute wildcard has been already builded.
330330+ * The attribute group has been defined.
331331 */
332332#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1
333333/**
···725725/**
726726 * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:
727727 *
728728- * disallowed substitutions: "substituion"
728728+ * disallowed substitutions: "substitution"
729729 */
730730#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION 1 << 13
731731/**
···789789 xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */
790790 xmlSchemaContentType contentType;
791791 const xmlChar *refPrefix; /* Deprecated; not used */
792792- xmlSchemaValPtr defVal; /* The compiled value contraint. */
792792+ xmlSchemaValPtr defVal; /* The compiled value constraint. */
793793 void *idcs; /* The identity-constraint defs */
794794};
795795···881881/**
882882 * XML_SCHEMAS_FINAL_DEFAULT_LIST:
883883 *
884884- * the cshema has "list" in the set of finalDefault.
884884+ * the schema has "list" in the set of finalDefault.
885885 */
886886#define XML_SCHEMAS_FINAL_DEFAULT_LIST 1 << 4
887887/**
···942942 xmlDictPtr dict;
943943 void *includes; /* the includes, this is opaque for now */
944944 int preserve; /* whether to free the document */
945945- int counter; /* used to give ononymous components unique names */
945945+ int counter; /* used to give anonymous components unique names */
946946 xmlHashTablePtr idcDef; /* All identity-constraint defs. */
947947 void *volatiles; /* Obsolete */
948948};
+1-1
sdk/include/reactos/libs/libxml/tree.h
···527527 * xmlDocProperty
528528 *
529529 * Set of properties of the document as found by the parser
530530- * Some of them are linked to similary named xmlParserOption
530530+ * Some of them are linked to similarly named xmlParserOption
531531 */
532532typedef enum {
533533 XML_DOC_WELLFORMED = 1<<0, /* document is XML well formed */
+1-1
sdk/include/reactos/libs/libxml/xlink.h
···2626 * of namespaces. If "foo" is the prefix for "http://foo.com/"
2727 * then the link detection layer will expand role="foo:myrole"
2828 * to "http://foo.com/:myrole".
2929- * NOTE: the link detection layer will expand URI-Refences found on
2929+ * NOTE: the link detection layer will expand URI-References found on
3030 * href attributes by using the base mechanism if found.
3131 */
3232typedef xmlChar *xlinkHRef;
+2-2
sdk/include/reactos/libs/libxml/xmlIO.h
···2727 * @filename: the filename or URI
2828 *
2929 * Callback used in the I/O Input API to detect if the current handler
3030- * can provide input fonctionnalities for this resource.
3030+ * can provide input functionality for this resource.
3131 *
3232 * Returns 1 if yes and 0 if another Input module should be used
3333 */
···7373 * @filename: the filename or URI
7474 *
7575 * Callback used in the I/O Output API to detect if the current handler
7676- * can provide output fonctionnalities for this resource.
7676+ * can provide output functionality for this resource.
7777 *
7878 * Returns 1 if yes and 0 if another Output module should be used
7979 */
+1-1
sdk/include/reactos/libs/libxml/xmlerror.h
···837837 * xmlGenericErrorFunc:
838838 * @ctx: a parsing context
839839 * @msg: the message
840840- * @...: the extra arguments of the varags to format the message
840840+ * @...: the extra arguments of the varargs to format the message
841841 *
842842 * Signature of the function to use when there is an error and
843843 * no parsing or validity context available .
···2929 *
3030 * the version string like "1.2.3"
3131 */
3232-#define LIBXML_DOTTED_VERSION "2.9.9"
3232+#define LIBXML_DOTTED_VERSION "2.9.10"
33333434/**
3535 * LIBXML_VERSION:
3636 *
3737 * the version number: 1.2.3 value is 10203
3838 */
3939-#define LIBXML_VERSION 20909
3939+#define LIBXML_VERSION 20910
40404141/**
4242 * LIBXML_VERSION_STRING:
4343 *
4444 * the version number string, 1.2.3 value is "10203"
4545 */
4646-#define LIBXML_VERSION_STRING "20909"
4646+#define LIBXML_VERSION_STRING "20910"
47474848/**
4949 * LIBXML_VERSION_EXTRA:
5050 *
5151 * extra version information, used to show a CVS compilation
5252 */
5353-#define LIBXML_VERSION_EXTRA "-GITv2.9.9-rc2-2-g7c4949afa"
5353+#define LIBXML_VERSION_EXTRA "-GITv2.9.10-rc1-2-ga5bb6aaa2"
54545555/**
5656 * LIBXML_TEST_VERSION:
···5858 * Macro to check that the libxml version in use is compatible with
5959 * the version the software has been compiled against
6060 */
6161-#define LIBXML_TEST_VERSION xmlCheckVersion(20909);
6161+#define LIBXML_TEST_VERSION xmlCheckVersion(20910);
62626363#ifndef VMS
6464#if 0
···9191 * Whether the thread support is configured in
9292 */
9393#if 1
9494-#if defined(_REENTRANT) || defined(__MT__) || \
9595- (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
9694#define LIBXML_THREAD_ENABLED
9797-#endif
9895#endif
999610097/**
···291288 *
292289 * Whether ISO-8859-* support is made available in case iconv is not
293290 */
294294-#if 0
291291+#if 1
295292#define LIBXML_ISO8859X_ENABLED
296293#endif
297294···353350 * LIBXML_EXPR_ENABLED:
354351 *
355352 * Whether the formal expressions interfaces are compiled in
353353+ *
354354+ * This code is unused and disabled unconditionally for now.
356355 */
357357-#if 1
356356+#if 0
358357#define LIBXML_EXPR_ENABLED
359358#endif
360359
+3-4
sdk/include/reactos/libs/libxml/xmlversion.h.in
···9191 * Whether the thread support is configured in
9292 */
9393#if @WITH_THREADS@
9494-#if defined(_REENTRANT) || defined(__MT__) || \
9595- (defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE - 0 >= 199506L))
9694#define LIBXML_THREAD_ENABLED
9797-#endif
9895#endif
999610097/**
···353350 * LIBXML_EXPR_ENABLED:
354351 *
355352 * Whether the formal expressions interfaces are compiled in
353353+ *
354354+ * This code is unused and disabled unconditionally for now.
356355 */
357357-#if @WITH_SCHEMAS@
356356+#if 0
358357#define LIBXML_EXPR_ENABLED
359358#endif
360359
+11-2
sdk/include/reactos/libs/libxml/xpath.h
···7070 XPATH_INVALID_CHAR_ERROR,
7171 XPATH_INVALID_CTXT,
7272 XPATH_STACK_ERROR,
7373- XPATH_FORBID_VARIABLE_ERROR
7373+ XPATH_FORBID_VARIABLE_ERROR,
7474+ XPATH_OP_LIMIT_EXCEEDED,
7575+ XPATH_RECURSION_LIMIT_EXCEEDED
7476} xmlXPathError;
75777678/*
···8284 int nodeNr; /* number of nodes in the set */
8385 int nodeMax; /* size of the array as allocated */
8486 xmlNodePtr *nodeTab; /* array of nodes in no particular order */
8585- /* @@ with_ns to check wether namespace nodes should be looked at @@ */
8787+ /* @@ with_ns to check whether namespace nodes should be looked at @@ */
8688};
87898890/*
···352354353355 /* Cache for reusal of XPath objects */
354356 void *cache;
357357+358358+ /* Resource limits */
359359+ unsigned long opLimit;
360360+ unsigned long opCount;
361361+ int depth;
362362+ int maxDepth;
363363+ int maxParserDepth;
355364};
356365357366/*
+56-56
sdk/lib/3rdparty/libxml2/ChangeLog
···463463 allow to make Name and NmToken validations based on the parser
464464 flags, more specifically the 5th edition of XML or not
465465 * HTMLparser.c tree.c: small side effects for the previous changes
466466- * parser.c SAX2.c valid.c: the bulk of teh changes are here,
466466+ * parser.c SAX2.c valid.c: the bulk of the changes are here,
467467 the parser and validation behaviour can be affected, parsing
468468 flags need to be copied, lot of changes. Also fixing various
469469 validation problems in the regression tests.
···13281328Tue Mar 20 09:58:13 CET 2007 Daniel Veillard <daniel@veillard.com>
1329132913301330 * nanoftp.c: applied patch from Björn Wiberg to try to fix again
13311331- the silly __ss_familly problem on various AIXes, should fix #420184
13311331+ the silly __ss_family problem on various AIXes, should fix #420184
1332133213331333Wed Mar 14 20:30:38 HKT 2007 William Brack <wbrack@mmm.com.hk>
13341334···1519151915201520Tue Oct 17 22:04:31 CEST 2006 Daniel Veillard <daniel@veillard.com>
1521152115221522- * HTMLparser.c: fixed teh 2 stupid bugs affecting htmlReadDoc() and
15221522+ * HTMLparser.c: fixed the 2 stupid bugs affecting htmlReadDoc() and
15231523 htmlReadIO() this should fix #340322
1524152415251525Tue Oct 17 21:39:23 CEST 2006 Daniel Veillard <daniel@veillard.com>
···16801680Tue Oct 10 10:33:43 CEST 2006 Daniel Veillard <daniel@veillard.com>
1681168116821682 * python/libxml.py python/types.c: applied patch from Ross Reedstrom,
16831683- Brian West and Stefan Anca to add XPointer suport to the Python bindings
16831683+ Brian West and Stefan Anca to add XPointer support to the Python bindings
1684168416851685Fri Sep 29 11:13:59 CEST 2006 Daniel Veillard <daniel@veillard.com>
16861686···2022202220232023 * xpath.c: Enhanced xmlXPathNodeCollectAndTest() to avoid
20242024 recreation (if possible) of the node-set which is used to
20252025- collect the nodes in the current axis for the currect context
20252025+ collect the nodes in the current axis for the current context
20262026 node. Especially for "//foo" this will decrease dramatically
20272027 the number of created node-sets, since for each node in the
20282028 result node-set of the evaluation of descendant-or-self::node()
···20562056 xmlXPathNodeSetDupNs(); thus a pure memcpy is not possible.
20572057 A flag on the node-set indicating if namespace nodes are in
20582058 the set would help here; this is the 3rd flag which would
20592059- be usefull with node-sets. The current flags I have in mind:
20592059+ be useful with node-sets. The current flags I have in mind:
20602060 1) Is a node-set already sorted?
20612061 This would allow for rebust and optimizable sorting
20622062 behaviour.
···21122112 compilation time (unlike normal XPath, where we can bind
21132113 namespace names to prefixes at execution time).
21142114 * pattern.c: Enhanced to use a string dict for local-names,
21152115- ns-prefixes and and namespace-names.
21152115+ ns-prefixes and namespace-names.
21162116 Fixed xmlStreamPushInternal() not to use string-pointer
21172117 comparison if a dict is available; this won't work, since
21182118 one does not know it the given strings originate from the
···22692269Fri Mar 10 08:40:55 EST 2006 Daniel Veillard <daniel@veillard.com>
2270227022712271 * c14n.c encoding.c xmlschemas.c xpath.c xpointer.c: fix a few
22722272- warning raised by gcc-4.1 and latests changes
22722272+ warning raised by gcc-4.1 and latest changes
2273227322742274Fri Mar 10 01:34:42 CET 2006 Daniel Veillard <daniel@veillard.com>
22752275···29672967 Fixed default/fixed values for attributes (looks like they
29682968 did not work in the last releases).
29692969 Completed constraints for attribute uses.
29702970- Seperated attribute derivation from attribute constraints.
29702970+ Separated attribute derivation from attribute constraints.
29712971 Completed constraints for attribute group definitions.
29722972 Disallowing <import>s of schemas in no target namespace if the
29732973 importing schema is a chameleon schema. This contradicts
29742974 the way Saxon, Xerces-J, XSV and IBM's SQC works, but the
29752975- W3C XML Schema WG, thinks it is correct to dissalow such
29752975+ W3C XML Schema WG, thinks it is correct to disallow such
29762976 imports.
29772977 Added cos-all-limited constraints.
29782978 Restructured reference resolution to model groups and element
···49804980 modules.
49814981 Added machanism to store element information for the
49824982 ancestor-or-self axis; this is needed for identity-constraints
49834983- and should be helpfull for a future streamable validation.
49834983+ and should be helpful for a future streamable validation.
49844984 * include/libxml/xmlerror.h: Added an error code for
49854985 identity-constraints.
49864986···56395639 automatic API regression test tool.
56405640 * SAX2.c nanoftp.c parser.c parserInternals.c tree.c xmlIO.c
56415641 xmlstring.c: various API hardeing changes as a result of running
56425642- teh first set of automatic API regression tests.
56425642+ the first set of automatic API regression tests.
56435643 * test/slashdot16.xml: apparently missing from CVS, commited it
5644564456455645Mon Nov 1 15:54:18 CET 2004 Daniel Veillard <daniel@veillard.com>
···5729572957305730Fri Oct 22 21:04:20 CEST 2004 Daniel Veillard <daniel@veillard.com>
5731573157325732- * python/libxml.c: fixed a problem occuring only in x86_64 when
57325732+ * python/libxml.c: fixed a problem occurring only in x86_64 when
57335733 very large error messages are raised to the Python handlers.
5734573457355735Thu Oct 21 18:03:21 CEST 2004 Daniel Veillard <daniel@veillard.com>
···5908590859095909Thu Sep 23 18:23:46 CEST 2004 Daniel Veillard <daniel@veillard.com>
5910591059115911- * xmlschemastypes.c: fixing an out of bound adressing issue
59115911+ * xmlschemastypes.c: fixing an out of bound addressing issue
5912591259135913Thu Sep 23 15:14:12 CEST 2004 Daniel Veillard <daniel@veillard.com>
59145914···60696069 of the wildcard.
60706070 Added a check for circular attribute group references.
60716071 Added a check for circular model group definition references.
60726072- Fixed a dublicate xmlParserErrors enum value - see bug #151738.
60726072+ Fixed a duplicate xmlParserErrors enum value - see bug #151738.
6073607360746074Fri Sep 3 10:08:13 PDT 2004 William Brack <wbrack@mmmm.com.hk>
60756075···62756275 include/libxml/xmlerror.h: cleanup to avoid 'error' identifier
62766276 in includes #137414
62776277 * parser.c SAX2.c debugXML.c include/libxml/parser.h:
62786278- first version of the inplementation of parsing within
62786278+ first version of the implementation of parsing within
62796279 the context of a node in the tree #142359, new function
62806280 xmlParseInNodeContext(), added support at the xmllint --shell
62816281 level as the "set" function
···6938693869396939Sun May 9 19:46:13 CEST 2004 Daniel Veillard <daniel@veillard.com>
6940694069416941- * xmlsave.c: apply fix for XHTML1 formating from Nick Wellnhofer
69416941+ * xmlsave.c: apply fix for XHTML1 formatting from Nick Wellnhofer
69426942 fixes bug #141266
69436943 * test/xhtmlcomp result//xhtmlcomp*: added the specific regression
69446944 test
···77537753 This is needed for XSLT to keep the stylesheet dictionary read-only
77547754 while being able to reuse the strings for the transformation
77557755 dictionary.
77567756- * xinclude.c: fixed a dictionary reference counting problem occuring
77567756+ * xinclude.c: fixed a dictionary reference counting problem occurring
77577757 when document parsing failed.
77587758 * testSAX.c: adding option --repeat for timing 100times the parsing
77597759 * doc/* : rebuilt all the docs
···89478947 * include/libxml/parserInternals.h HTMLparser.c HTMLtree.c
89488948 SAX2.c catalog.c debugXML.c entities.c parser.c relaxng.c
89498949 testSAX.c tree.c valid.c xmlschemas.c xmlschemastypes.c
89508950- xpath.c: Changed all (?) occurences where validation macros
89508950+ xpath.c: Changed all (?) occurrences where validation macros
89518951 (IS_xxx) had single-byte arguments to use IS_xxx_CH instead
89528952 (e.g. IS_BLANK changed to IS_BLANK_CH). This gets rid of
89538953 many warning messages on certain platforms, and also high-
···89728972 a new source, like the xmlReadxx and xmlCtxtReadxxx
89738973 * win32/libxml2.def.src doc/libxml2-api.xml doc/apibuild.py
89748974 doc/Makefile.am: regenerated the APIs
89758975- * doc/xml.html: applied a patch from Stefan Kost for namesapce docs
89758975+ * doc/xml.html: applied a patch from Stefan Kost for namespace docs
8976897689778977Sat Oct 18 12:46:02 HKT 2003 William Brack <wbrack@mmm.com.hk>
89788978···91799179 on Windows from Jesse Pelton
91809180 * parser.c: tiny safety patch for xmlStrPrintf() make sure the
91819181 return is always zero terminated. Should also help detecting
91829182- passing wrong buffer size easilly.
91829182+ passing wrong buffer size easily.
91839183 * result/VC/* result/valid/rss.xml.err result/valid/xlink.xml.err:
91849184 updated the results to follow the errors string generated by
91859185 last commit.
···91929192Tue Oct 7 13:30:39 CEST 2003 Daniel Veillard <daniel@veillard.com>
9193919391949194 * error.c relaxng.c include/libxml/xmlerror.h: switched Relax-NG
91959195- module to teh new error reporting. Better default report, adds
91959195+ module to the new error reporting. Better default report, adds
91969196 the element associated if found, context and node are included
91979197 in the xmlError
91989198 * python/tests/reader2.py: the error messages changed.
···10424104241042510425 * doc/Makefile.am doc/html/*: reverted back patch for #113521,
1042610426 due to #115104 and while fixing #115101 . HTML URLs must not
1042710427- be version dependant.
1042710427+ be version dependent.
10428104281042910429Fri Jun 13 12:03:30 CEST 2003 Daniel Veillard <daniel@veillard.com>
1043010430···10627106271062810628 * python/generator.py: fixed a problem in the generator where
1062910629 the way functions are remapped as methods on classes was
1063010630- not symetric and dependant on python internal hash order,
1063010630+ not symmetric and dependent on python internal hash order,
1063110631 as reported by Stéphane Bidoul
10632106321063310633Fri Apr 25 21:52:33 MDT 2003 John Fleck <jfleck@inkstain.net>
···1116211162Mon Mar 17 16:34:07 CET 2003 Daniel Veillard <daniel@veillard.com>
11163111631116411164 * relaxng.c: fixed the last core RelaxNG bug known #107083,
1116511165- shemas datatype ID/IDREF support still missing though.
1116511165+ schemas datatype ID/IDREF support still missing though.
1116611166 * xmlreader.c: fix a crashing bug with prefix raised by
1116711167 Merijn Broeren
1116811168 * test/relaxng/testsuite.xml: augmented the testsuite with
···11882118821188311883Fri Jan 10 00:16:49 CET 2003 Daniel Veillard <daniel@veillard.com>
11884118841188511885- * parser.c: one more IsEmptyElement crazyness, that time in
1188511885+ * parser.c: one more IsEmptyElement craziness, that time in
1188611886 external parsed entities if substitution is asked.
1188711887 * python/tests/reader3.py: added a specific test.
1188811888···1214512145Mon Dec 23 16:54:22 CET 2002 Daniel Veillard <daniel@veillard.com>
12146121461214712147 * xmlreader.c: Fixed the empty node detection to avoid reporting
1214812148- an inexistant close tag.
1214812148+ an nonexistent close tag.
12149121491215012150Mon Dec 23 15:42:24 CET 2002 Daniel Veillard <daniel@veillard.com>
1215112151···1248212482 * parser.c xpath.c: fixing #96925 wich was also dependent on the
1248312483 processing of parsed entities, and XPath computation on sustitued
1248412484 entities.
1248512485- * testXPath.c: make sure entities are substitued.
1248512485+ * testXPath.c: make sure entities are substituted.
12486124861248712487Fri Nov 15 16:22:54 CET 2002 Daniel Veillard <daniel@veillard.com>
1248812488···1267312673Mon Oct 21 09:57:10 CEST 2002 Daniel Veillard <daniel@veillard.com>
12674126741267512675 * parser.c: tried to fix bug #91500 where doc->children may
1267612676- be overriden by a call to xmlParseBalancedChunkMemory()
1267612676+ be overridden by a call to xmlParseBalancedChunkMemory()
12677126771267812678Mon Oct 21 09:04:32 CEST 2002 Daniel Veillard <daniel@veillard.com>
1267912679···12800128001280112801 * configure.in include/libxml/xmlwin32version.h: preparing release
1280212802 of 2.4.25
1280312803- * doc/*: updated and regenerated teh docs and web pages.
1280312803+ * doc/*: updated and regenerated the docs and web pages.
12804128041280512805Thu Sep 26 17:33:46 CEST 2002 Daniel Veillard <daniel@veillard.com>
1280612806···13026130261302713027Wed Sep 4 14:13:34 CEST 2002 Daniel Veillard <daniel@veillard.com>
13028130281302913029- * libxml.spec.in: fixes libary path for x86_64 AMD
1302913029+ * libxml.spec.in: fixes library path for x86_64 AMD
13030130301303113031Tue Sep 3 21:14:19 MDT 2002 John Fleck <jfleck@inkstain.net>
1303213032···1308513085Thu Aug 22 11:45:50 CEST 2002 Daniel Veillard <daniel@veillard.com>
13086130861308713087 * python/Makefile.am: typo in target name resulted in libxml2.py
1308813088- to not be rebuilt. fixed DESTDIR similary to the libxslt one.
1308813088+ to not be rebuilt. fixed DESTDIR similarly to the libxslt one.
13089130891309013090Thu Aug 22 09:15:00 CEST 2002 Daniel Veillard <daniel@veillard.com>
1309113091···1404414044Thu Mar 7 12:19:36 CET 2002 Daniel Veillard <daniel@veillard.com>
14045140451404614046 * configure.in xmllint.c: trying to fix #71457 for timing
1404714047- precision when gettimeofday() is not availble but ftime() is
1404714047+ precision when gettimeofday() is not available but ftime() is
14048140481404914049Thu Mar 7 11:24:02 CET 2002 Daniel Veillard <daniel@veillard.com>
1405014050···1420814208 when a document is standalone seems correctly handled. There
1420914209 is a couple of open issues left which need consideration especially
1421014210 PE93 on external unparsed entities and standalone status.
1421114211- Ran 1819 tests: 1817 suceeded, 2 failed and 0 generated an error in 8.26 s.
1421114211+ Ran 1819 tests: 1817 succeeded, 2 failed and 0 generated an error in 8.26 s.
1421214212 The 2 tests left failing are actually in error. Cleanup done.
14213142131421414214Tue Feb 19 15:17:02 CET 2002 Daniel Veillard <daniel@veillard.com>
···14225142251422614226 * parser.c valid.c: a couple of errors were reported but not
1422714227 saved back as such in the parsing context. Down to 1% failure rate
1422814228- Ran 1819 tests: 1801 suceeded, 18 failed and 0 generated an error
1422814228+ Ran 1819 tests: 1801 succeeded, 18 failed and 0 generated an error
14229142291423014230Mon Feb 18 20:16:15 CET 2002 Daniel Veillard <daniel@veillard.com>
1423114231···1426614266 * check-xml-test-suite.py: improved the behaviour a bit as
1426714267 well as the logs
1426814268 * parser.c valid.c SAX.c: fixed a few more bugs
1426914269- "Ran 1819 tests: 1778 suceeded, 41 failed, and 0 generated an error"
1426914269+ "Ran 1819 tests: 1778 succeeded, 41 failed, and 0 generated an error"
14270142701427114271Sun Feb 17 20:41:37 CET 2002 Daniel Veillard <daniel@veillard.com>
1427214272···1445314453 context, allow to switch on and check validity
1445414454 * python/tests/Makefile.am python/tests/error.py
1445514455 python/tests/invalid.xml python/tests/valid.xml
1445614456- python/tests/validate.py: attded more test and and added error.py
1445614456+ python/tests/validate.py: added more test and added error.py
1445714457 which I forgot to commit in the last step
14458144581445914459Sun Feb 3 16:03:55 CET 2002 Daniel Veillard <daniel@veillard.com>
···1457614576Wed Jan 23 15:14:22 CET 2002 Daniel Veillard <daniel@veillard.com>
14577145771457814578 * parserInternals.h: Greg Sjaardema suggested to use an
1457914579- eponential buffer groth policy in xmlParserAddNodeInfo()
1457914579+ exponential buffer growth policy in xmlParserAddNodeInfo()
14580145801458114581Wed Jan 23 13:32:40 CET 2002 Daniel Veillard <daniel@veillard.com>
1458214582···14660146601466114661Fri Jan 18 17:22:50 CET 2002 Daniel Veillard <daniel@veillard.com>
14662146621466314663- * globals.c xmlIO.c xmlcatalog.c: removed the last occurences
1466314663+ * globals.c xmlIO.c xmlcatalog.c: removed the last occurrences
1466414664 of strdup usage in the code
14665146651466614666Fri Jan 18 12:47:15 CET 2002 Daniel Veillard <daniel@veillard.com>
···1548815488Tue Sep 11 11:25:36 CEST 2001 Daniel Veillard <daniel@veillard.com>
15489154891549015490 * parser.c result/noent/wml.xml: fixed bug #59981 related
1549115491- to handling of '&' in attributes when entities are substitued
1549115491+ to handling of '&' in attributes when entities are substituted
15492154921549315493Mon Sep 10 22:14:42 CEST 2001 Daniel Veillard <daniel@veillard.com>
1549415494···16120161201612116121 * configure.in doc/xml.html include/libxml/xmlwin32version.h:
1612216122 release of 2.3.12
1612316123- * parser.c: make an error message if unknow entities in all cases
1612316123+ * parser.c: make an error message if unknown entities in all cases
16124161241612516125Tue Jun 26 09:46:29 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
1612616126···1694316943Wed Apr 18 15:06:30 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
16944169441694516945 * debugXML.c hash.c tree.h valid.c : some changes related to
1694616946- the validation suport to improve speed with DocBook
1694616946+ the validation support to improve speed with DocBook
1694716947 * result/VC/OneID2 result/VC/OneID3 : this slightly changes
1694816948 the way validation errors get reported
1694916949···1700317003 * xpath.c: trying to get 52979 solved
1700417004 * tree.c result/ result/noent/: trying to get 52712 solved, this
1700517005 also made me clean up the fact that XML output in general should
1700617006- not add formating blanks by default, this changed the output of
1700617006+ not add formatting blanks by default, this changed the output of
1700717007 a few tests
17008170081700917009Tue Apr 10 16:30:20 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
···17219172191722017220 * parser.c SAX.c: the new content parsing code raised an
1722117221 ugly bug in the characters() SAX callback. Found it
1722217222- just because of strangeness in XSLT XML Rec ouptut :-(
1722217222+ just because of strangeness in XSLT XML Rec output :-(
17223172231722417224Wed Mar 7 16:50:22 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
1722517225···17541175411754217542Mon Jan 22 11:43:21 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
17543175431754417544- * xpath.c: when copying a XSLT tree object teh tree need to be copied
1754417544+ * xpath.c: when copying a XSLT tree object the tree need to be copied
1754517545 too, and deallocation need to occur the same way.
17546175461754717547Mon Jan 22 10:35:40 CET 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
17548175481754917549 * xpathInternals.h xpath.[ch] debugXML.c: added the XPATH_XSLT_TREE
1755017550- type correponding to an XSLT result tree fragment. Share most
1755017550+ type corresponding to an XSLT result tree fragment. Share most
1755117551 of the data format with node set, as well as operators.
1755217552 * HTMLtree.c: added a newline at the end of the doctype output
1755317553 whe this one is not present initially.
···1790417904Sun Oct 15 16:21:27 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
17905179051790617906 * SAX.c: HTML attributes need normalization too (Bjorn Reese)
1790717907- * HTMLparser.[ch]: addded htmlIsScriptAttribute()
1790717907+ * HTMLparser.[ch]: added htmlIsScriptAttribute()
17908179081790917909Sun Oct 15 13:18:36 CEST 2000 Daniel Veillard <Daniel.Veillard@w3.org>
1791017910···1801018010 * include/Makefile.am include/win32config.h: new directory
1801118011 for includes
1801218012 * win32/Makefile.mingw win32/README.MSDev win32/libxml2/libxml2.dsp
1801318013- updated teh makefiles and instructions for WIN32
1801318013+ updated the makefiles and instructions for WIN32
1801418014 * xpath.c: small fixes
1801518015 * test/XPath/ results/XPath: updated the testcases and results
1801618016 * HTMLparser.c nanohttp.c testXPath.c: incorporated provided or
···1825518255 patches from Wayne Davison <wayned@users.sourceforge.net>,
1825618256 adding htmlEncodeEntities()
1825718257 * HTMLparser.c: fixed an ignorable white space detection bug
1825818258- occuring when parsing with SAX only
1825818258+ occurring when parsing with SAX only
1825918259 * result/HTML/*.sax: updated since the output is now HTML
1826018260 encoded...
1826118261···1842018420 when using Sun Pro cc compiler
1842118421 * xpath.c : cleanup memleaks
1842218422 * nanoftp.c : added a TESTING preprocessor flag for standalong
1842318423- compile so that people can report bugs more easilly
1842318423+ compile so that people can report bugs more easily
1842418424 * nanohttp.c : ditched socklen_t which was a portability mess
1842518425 and replaced it with unsigned int.
1842618426 * tree.[ch]: added xmlHasProp()
···1859418594 Makefile.am : added compile-time customization of libxml
1859518595 --with-ftp --with-http --with-html --with-xpath --with-debug
1859618596 --with-mem-debug
1859718597- * *.[ch] autoconf.sh : moved to an absolute adressing of includes :
1859718597+ * *.[ch] autoconf.sh : moved to an absolute addressing of includes :
1859818598 #include <libxml/xxx.h> I hope it won't break too much stuff
1859918599 and will be manageable in the future...
1860018600 * xmllint.c Makefile.am libxml.spec.in : renamed tester.c to xmllint.c
···1862518625 libxml default allocation function with another set (like gmalloc/
1862618626 gfree).
1862718627 * Makefile.am, uri.c, uri.h: added a set of functions to do
1862818628- exact (litteraly copied from the RFC 2396 productions) parsing
1862818628+ exact (literally copied from the RFC 2396 productions) parsing
1862918629 and handling of URI. Will be needed for XLink, one XML WFC,
1863018630 XML Base and reused in the nano[ftp/http] modules. Still work
1863118631 to be done.
···18688186881868918689 * nanoftp.c nanohttp.c tree.c HTMLtree.[ch] debugXML.c xpath.c: Fixed
1869018690 compilation warnings on various platforms.
1869118691- * parser.c: Fixed #5281 validity error callbacks are now desactived
1869118691+ * parser.c: Fixed #5281 validity error callbacks are now deactivated
1869218692 by default if not validating.
18693186931869418694Thu Feb 3 13:46:14 CET 2000 Daniel Veillard <Daniel.Veillard@w3.org>
···19125191251912619126 * parser.h: modified the parser context struct to regain 1.4.0
1912719127 binary compatibility
1912819128- * parser.c, xml-error.h: added errno ot teh context and defined
1912819128+ * parser.c, xml-error.h: added errno to the context and defined
1912919129 a set of errors values with update of errno
1913019130 * nanohttp.[ch]: minimalist HTTP front-end for fetching remote
1913119131 DTDs and entities
···19562195621956319563Sat Oct 24 14:23:51 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
19564195641956519565- * parser.c: Set up the fonctions comment block, boring but useful.
1956519565+ * parser.c: Set up the functions comment block, boring but useful.
1956619566 * parser.h, SAX.c, parser.c: now attributes are processed through
1956719567 the SAX interface. The problem is that my SAX interface diverged
1956819568 quite a bit from the original one, well this is not an official
···1957119571Tue Oct 20 02:11:21 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
19572195721957319573 * SAX.c, entities.c, tree.c, encoding.c, error.c: Set up the
1957419574- fonctions comment block, boring but useful.
1957419574+ functions comment block, boring but useful.
19575195751957619576Sun Oct 18 20:40:58 EDT 1998 Daniel Veillard <Daniel.Veillard@w3.org>
1957719577
+19-12
sdk/lib/3rdparty/libxml2/HTMLparser.c
···317317318318#define SKIP_BLANKS htmlSkipBlankChars(ctxt)
319319320320-/* Inported from XML */
320320+/* Imported from XML */
321321322322/* #define CUR (ctxt->token ? ctxt->token : (int) (*ctxt->input->cur)) */
323323#define CUR ((int) (*ctxt->input->cur))
···537537encoding_error:
538538 /*
539539 * If we detect an UTF8 error that probably mean that the
540540- * input encoding didn't get properly advertized in the
540540+ * input encoding didn't get properly advertised in the
541541 * declaration header. Report the error and switch the encoding
542542 * to ISO-Latin-1 (if you don't like this policy, just declare the
543543 * encoding !)
···602602 ************************************************************************/
603603604604/*
605605- * Start Tag: 1 means the start tag can be ommited
606606- * End Tag: 1 means the end tag can be ommited
605605+ * Start Tag: 1 means the start tag can be omitted
606606+ * End Tag: 1 means the end tag can be omitted
607607 * 2 means it's forbidden (empty elements)
608608 * 3 means the tag is stylistic and should be closed easily
609609 * Depr: this element is deprecated
···13421342 if (xmlStrEqual(newtag, ctxt->nameTab[i]))
13431343 break;
13441344 /*
13451345- * A missplaced endtag can only close elements with lower
13451345+ * A misplaced endtag can only close elements with lower
13461346 * or equal priority, so if we find an element with higher
13471347 * priority before we find an element with
13481348 * matching name, we just ignore this endtag
···21762176 * *
21772177 ************************************************************************/
2178217821792179+#ifdef LIBXML_PUSH_ENABLED
21792180/**
21802181 * htmlNewInputStream:
21812182 * @ctxt: an HTML parser context
···22072208 input->length = 0;
22082209 return(input);
22092210}
22112211+#endif
221022122211221322122214/************************************************************************
···22162218 ************************************************************************/
22172219/*
22182220 * all tags allowing pc data from the html 4.01 loose dtd
22192219- * NOTE: it might be more apropriate to integrate this information
22212221+ * NOTE: it might be more appropriate to integrate this information
22202222 * into the html40ElementTable array but I don't want to risk any
22212221- * binary incomptibility
22232223+ * binary incompatibility
22222224 */
22232225static const char *allowPCData[] = {
22242226 "a", "abbr", "acronym", "address", "applet", "b", "bdo", "big",
···29592961 }
29602962 COPY_BUF(l,buf,nbchar,cur);
29612963 if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
29642964+ buf[nbchar] = 0;
29622965 if (ctxt->sax->cdataBlock!= NULL) {
29632966 /*
29642967 * Insert as CDATA, which is the same as HTML_PRESERVE_NODE
···29832986 }
2984298729852988 if ((nbchar != 0) && (ctxt->sax != NULL) && (!ctxt->disableSAX)) {
29892989+ buf[nbchar] = 0;
29862990 if (ctxt->sax->cdataBlock!= NULL) {
29872991 /*
29882992 * Insert as CDATA, which is the same as HTML_PRESERVE_NODE
···30283032 COPY_BUF(l,buf,nbchar,cur);
30293033 }
30303034 if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) {
30353035+ buf[nbchar] = 0;
30363036+30313037 /*
30323038 * Ok the segment is to be consumed as chars.
30333039 */
···57625768 break;
57635769 }
57645770 case XML_PARSER_CONTENT: {
57715771+ xmlChar chr[2] = { 0, 0 };
57655772 long cons;
57735773+57665774 /*
57675775 * Handle preparsed entities and charRef
57685776 */
57695777 if (ctxt->token != 0) {
57705770- xmlChar chr[2] = { 0 , 0 } ;
57715771-57725778 chr[0] = (xmlChar) ctxt->token;
57735779 htmlCheckParagraph(ctxt);
57745780 if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL))
···57805786 cur = in->cur[0];
57815787 if ((cur != '<') && (cur != '&')) {
57825788 if (ctxt->sax != NULL) {
57895789+ chr[0] = cur;
57835790 if (IS_BLANK_CH(cur)) {
57845791 if (ctxt->keepBlanks) {
57855792 if (ctxt->sax->characters != NULL)
57865793 ctxt->sax->characters(
57875787- ctxt->userData, &in->cur[0], 1);
57945794+ ctxt->userData, chr, 1);
57885795 } else {
57895796 if (ctxt->sax->ignorableWhitespace != NULL)
57905797 ctxt->sax->ignorableWhitespace(
57915791- ctxt->userData, &in->cur[0], 1);
57985798+ ctxt->userData, chr, 1);
57925799 }
57935800 } else {
57945801 htmlCheckParagraph(ctxt);
57955802 if (ctxt->sax->characters != NULL)
57965803 ctxt->sax->characters(
57975797- ctxt->userData, &in->cur[0], 1);
58045804+ ctxt->userData, chr, 1);
57985805 }
57995806 }
58005807 ctxt->token = 0;
+1-1
sdk/lib/3rdparty/libxml2/HTMLtree.c
···10481048 * @cur: the document
10491049 * @encoding: the encoding string
10501050 *
10511051- * Dump an HTML document. Formating return/spaces are added.
10511051+ * Dump an HTML document. Formatting return/spaces are added.
10521052 */
10531053void
10541054htmlDocContentDumpOutput(xmlOutputBufferPtr buf, xmlDocPtr cur,
···8899To build on an Unixised setup:
1010 ./configure ; make ; make install
1111+ if the ./configure file does not exist, run ./autogen.sh instead.
1112To build on Windows:
1213 see instructions on win32/Readme.txt
1314
+12-10
sdk/lib/3rdparty/libxml2/SAX2.c
···4040 * TODO:
4141 *
4242 * macro to flag unimplemented blocks
4343- * XML_CATALOG_PREFER user env to select between system/public prefered
4343+ * XML_CATALOG_PREFER user env to select between system/public preferred
4444 * option. C.f. Richard Tobin <richard@cogsci.ed.ac.uk>
4545 *> Just FYI, I am using an environment variable XML_CATALOG_PREFER with
4646 *> values "system" and "public". I have made the default be "system" to
···15121512 attr = elemDecl->attributes;
15131513 while (attr != NULL) {
15141514 /*
15151515- * Make sure that attributes redefinition occuring in the
15161516- * internal subset are not overriden by definitions in the
15151515+ * Make sure that attributes redefinition occurring in the
15161516+ * internal subset are not overridden by definitions in the
15171517 * external subset.
15181518 */
15191519 if (attr->defaultValue != NULL) {
···16681668 if (nodePush(ctxt, ret) < 0) {
16691669 xmlUnlinkNode(ret);
16701670 xmlFreeNode(ret);
16711671+ if (prefix != NULL)
16721672+ xmlFree(prefix);
16711673 return;
16721674 }
16731675···17341736 }
1735173717361738 /*
17371737- * set the namespace node, making sure that if the default namspace
17381738- * is unbound on a parent we simply kee it NULL
17391739+ * set the namespace node, making sure that if the default namespace
17401740+ * is unbound on a parent we simply keep it NULL
17391741 */
17401742 if ((ns != NULL) && (ns->href != NULL) &&
17411743 ((ns->href[0] != 0) || (ns->prefix != NULL)))
···20102012 else
20112013 ret->name = xmlStrdup(localname);
2012201420132013- /* link at the end to preserv order, TODO speed up with a last */
20152015+ /* link at the end to preserve order, TODO speed up with a last */
20142016 if (ctxt->node->properties == NULL) {
20152017 ctxt->node->properties = ret;
20162018 } else {
···21022104 } else {
21032105 /*
21042106 * dup now contains a string of the flattened attribute
21052105- * content with entities substitued. Check if we need to
21072107+ * content with entities substituted. Check if we need to
21062108 * apply an extra layer of normalization.
21072109 * It need to be done twice ... it's an extra burden related
21082110 * to the ability to keep references in attributes
···21352137 }
21362138 } else {
21372139 /*
21382138- * if entities already have been substitued, then
21402140+ * if entities already have been substituted, then
21392141 * the attribute as passed is already normalized
21402142 */
21412143 dup = xmlStrndup(value, valueend - value);
···23982400 if (nb_attributes > 0) {
23992401 for (j = 0,i = 0;i < nb_attributes;i++,j+=5) {
24002402 /*
24012401- * Handle the rare case of an undefined atribute prefix
24032403+ * Handle the rare case of an undefined attribute prefix
24022404 */
24032405 if ((attributes[j+1] != NULL) && (attributes[j+2] == NULL)) {
24042406 if (ctxt->dictNames) {
···25842586 * The whole point of maintaining nodelen and nodemem,
25852587 * xmlTextConcat is too costly, i.e. compute length,
25862588 * reallocate a new buffer, move data, append ch. Here
25872587- * We try to minimaze realloc() uses and avoid copying
25892589+ * We try to minimize realloc() uses and avoid copying
25882590 * and recomputing length over and over.
25892591 */
25902592 if (lastChild->content == (xmlChar *)&(lastChild->properties)) {
+6-6
sdk/lib/3rdparty/libxml2/buf.c
···11/*
22 * buf.c: memory buffers for libxml2
33 *
44- * new buffer structures and entry points to simplify the maintainance
44+ * new buffer structures and entry points to simplify the maintenance
55 * of libxml2 and ensure we keep good control over memory allocations
66 * and stay 64 bits clean.
77 * The new entry point use the xmlBufPtr opaque structure and
···396396 ((buf->alloc == XML_BUFFER_ALLOC_IO) && (buf->contentIO != NULL))) {
397397 /*
398398 * we just move the content pointer, but also make sure
399399- * the perceived buffer size has shrinked accordingly
399399+ * the perceived buffer size has shrunk accordingly
400400 */
401401 buf->content += len;
402402 buf->size -= len;
···958958959959 if (start_buf > (unsigned int) len) {
960960 /*
961961- * We can add it in the space previously shrinked
961961+ * We can add it in the space previously shrunk
962962 */
963963 buf->content -= len;
964964 memmove(&buf->content[0], str, len);
···12041204xmlBufBackToBuffer(xmlBufPtr buf) {
12051205 xmlBufferPtr ret;
1206120612071207- if ((buf == NULL) || (buf->error))
12071207+ if (buf == NULL)
12081208 return(NULL);
12091209 CHECK_COMPAT(buf)
12101210- if (buf->buffer == NULL) {
12101210+ if ((buf->error) || (buf->buffer == NULL)) {
12111211 xmlBufFree(buf);
12121212 return(NULL);
12131213 }
···13071307 CHECK_COMPAT(buf)
13081308 base = input->base - buf->content;
13091309 /*
13101310- * We could do some pointer arythmetic checks but that's probably
13101310+ * We could do some pointer arithmetic checks but that's probably
13111311 * sufficient.
13121312 */
13131313 if (base > buf->size) {
+6-6
sdk/lib/3rdparty/libxml2/c14n.c
···43434444typedef struct _xmlC14NVisibleNsStack {
4545 int nsCurEnd; /* number of nodes in the set */
4646- int nsPrevStart; /* the begginning of the stack for previous visible node */
4646+ int nsPrevStart; /* the beginning of the stack for previous visible node */
4747 int nsPrevEnd; /* the end of the stack for previous visible node */
4848 int nsMax; /* size of the array as allocated */
4949 xmlNsPtr *nsTab; /* array of ns in no particular order */
···226226 * xmlC14NErr:
227227 * @ctxt: a C14N evaluation context
228228 * @node: the context node
229229- * @error: the erorr code
229229+ * @error: the error code
230230 * @msg: the message
231231 * @extra: extra informations
232232 *
···18271827 }
1828182818291829 /*
18301830- * Set "mode" flag and remember list of incluseve prefixes
18301830+ * Set "mode" flag and remember list of inclusive prefixes
18311831 * for exclusive c14n
18321832 */
18331833 ctx->mode = mode;
···20392039 (void) xmlOutputBufferClose(buf);
2040204020412041 if ((*doc_txt_ptr == NULL) && (ret > 0)) {
20422042- xmlC14NErrMemory("coping canonicanized document");
20422042+ xmlC14NErrMemory("coping canonicalized document");
20432043 return (-1);
20442044 }
20452045 return (ret);
···20572057 * canonicalization, ignored otherwise)
20582058 * @with_comments: include comments in the result (!=0) or not (==0)
20592059 * @filename: the filename to store canonical XML image
20602060- * @compression: the compression level (zlib requred):
20602060+ * @compression: the compression level (zlib required):
20612061 * -1 - libxml default,
20622062 * 0 - uncompressed,
20632063 * >0 - compression level
···21002100 ret = xmlC14NDocSaveTo(doc, nodes, mode, inclusive_ns_prefixes,
21012101 with_comments, buf);
21022102 if (ret < 0) {
21032103- xmlC14NErrInternal("cannicanize document to buffer");
21032103+ xmlC14NErrInternal("canonize document to buffer");
21042104 (void) xmlOutputBufferClose(buf);
21052105 return (-1);
21062106 }
+1-1
sdk/lib/3rdparty/libxml2/catalog.c
···5656 * TODO:
5757 *
5858 * macro to flag unimplemented blocks
5959- * XML_CATALOG_PREFER user env to select between system/public prefered
5959+ * XML_CATALOG_PREFER user env to select between system/public preferred
6060 * option. C.f. Richard Tobin <richard@cogsci.ed.ac.uk>
6161 *> Just FYI, I am using an environment variable XML_CATALOG_PREFER with
6262 *> values "system" and "public". I have made the default be "system" to
+8-14
sdk/lib/3rdparty/libxml2/debugXML.c
···289289 dict = doc->dict;
290290 if ((dict == NULL) && (ctxt->nodict == 0)) {
291291#if 0
292292- /* desactivated right now as it raises too many errors */
292292+ /* deactivated right now as it raises too many errors */
293293 if (doc->type == XML_DOCUMENT_NODE)
294294 xmlDebugErr(ctxt, XML_CHECK_NO_DICT,
295295 "Document has no dictionary\n");
···11681168 * @output: the FILE * for the output
11691169 * @doc: the document
11701170 *
11711171- * Dumps debug information cncerning the document, not recursive
11711171+ * Dumps debug information concerning the document, not recursive
11721172 */
11731173static void
11741174xmlCtxtDumpDocumentHead(xmlDebugCtxtPtr ctxt, xmlDocPtr doc)
···14981498 * @output: the FILE * for the output
14991499 * @doc: the document
15001500 *
15011501- * Dumps debug information cncerning the document, not recursive
15011501+ * Dumps debug information concerning the document, not recursive
15021502 */
15031503void
15041504xmlDebugDumpDocumentHead(FILE * output, xmlDocPtr doc)
···23632363 int ret;
2364236423652365 ctxt = xmlRelaxNGNewParserCtxt(schemas);
23662366- xmlRelaxNGSetParserErrors(ctxt,
23672367- (xmlRelaxNGValidityErrorFunc) fprintf,
23682368- (xmlRelaxNGValidityWarningFunc) fprintf,
23692369- stderr);
23662366+ xmlRelaxNGSetParserErrors(ctxt, xmlGenericError, xmlGenericError, NULL);
23702367 relaxngschemas = xmlRelaxNGParse(ctxt);
23712368 xmlRelaxNGFreeParserCtxt(ctxt);
23722369 if (relaxngschemas == NULL) {
···23752372 return(-1);
23762373 }
23772374 vctxt = xmlRelaxNGNewValidCtxt(relaxngschemas);
23782378- xmlRelaxNGSetValidErrors(vctxt,
23792379- (xmlRelaxNGValidityErrorFunc) fprintf,
23802380- (xmlRelaxNGValidityWarningFunc) fprintf,
23812381- stderr);
23752375+ xmlRelaxNGSetValidErrors(vctxt, xmlGenericError, xmlGenericError, NULL);
23822376 ret = xmlRelaxNGValidateDoc(vctxt, sctxt->doc);
23832377 if (ret == 0) {
23842378 fprintf(stderr, "%s validates\n", sctxt->filename);
···26472641 int res = -1;
2648264226492643 if ((ctxt == NULL) || (ctxt->doc == NULL)) return(-1);
26502650- vctxt.userData = stderr;
26512651- vctxt.error = (xmlValidityErrorFunc) fprintf;
26522652- vctxt.warning = (xmlValidityWarningFunc) fprintf;
26442644+ vctxt.userData = NULL;
26452645+ vctxt.error = xmlGenericError;
26462646+ vctxt.warning = xmlGenericError;
2653264726542648 if ((dtd == NULL) || (dtd[0] == 0)) {
26552649 res = xmlValidateDocument(&vctxt, ctxt->doc);
+10-3
sdk/lib/3rdparty/libxml2/dict.c
···3838 * list we will use the BigKey algo as soon as the hash size grows
3939 * over MIN_DICT_SIZE so this actually works
4040 */
4141-#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
4141+#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) && \
4242+ !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
4243#define DICT_RANDOMIZATION
4344#endif
4445···371372 * http://burtleburtle.net/bob/hash/doobs.html
372373 */
373374375375+#ifdef __clang__
376376+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
377377+#endif
374378static uint32_t
375379xmlDictComputeBigKey(const xmlChar* data, int namelen, int seed) {
376380 uint32_t hash;
···403407 *
404408 * Neither of the two strings must be NULL.
405409 */
410410+#ifdef __clang__
411411+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
412412+#endif
406413static unsigned long
407414xmlDictComputeBigQKey(const xmlChar *prefix, int plen,
408415 const xmlChar *name, int len, int seed)
···727734 dict->dict[key].next = entry;
728735 } else {
729736 /*
730730- * we don't have much ways to alert from herei
737737+ * we don't have much ways to alert from here
731738 * result is losing an entry and unicity guarantee
732739 */
733740 ret = -1;
···12021209 * @dict: the dictionary
12031210 * @str: the string
12041211 *
12051205- * check if a string is owned by the disctionary
12121212+ * check if a string is owned by the dictionary
12061213 *
12071214 * Returns 1 if true, 0 if false and -1 in case of error
12081215 * -1 in case of error
···11/*
22 * Summary: Internal Interfaces for encoding in libxml2
33 * Description: this module describes a few interfaces which were
44- * addded along with the API changes in 2.9.0
44+ * added along with the API changes in 2.9.0
55 * those are private routines at this point
66 *
77 * Copy: See Copyright for the status of this software.
+9-9
sdk/lib/3rdparty/libxml2/encoding.c
···17951795 *
17961796 * The value of @inlen after return is the number of octets consumed
17971797 * as the return value is positive, else unpredictable.
17981798- * The value of @outlen after return is the number of ocetes consumed.
17981798+ * The value of @outlen after return is the number of octets consumed.
17991799 */
18001800static int
18011801xmlIconvWrapper(iconv_t cd, unsigned char *out, int *outlen,
···18631863 *
18641864 * The value of @inlen after return is the number of octets consumed
18651865 * as the return value is positive, else unpredictable.
18661866- * The value of @outlen after return is the number of ocetes consumed.
18661866+ * The value of @outlen after return is the number of octets consumed.
18671867 */
18681868static int
18691869xmlUconvWrapper(uconv_t *cd, int toUnicode, unsigned char *out, int *outlen,
···1972197219731973/**
19741974 * xmlCharEncFirstLineInt:
19751975- * @handler: char enconding transformation data structure
19751975+ * @handler: char encoding transformation data structure
19761976 * @out: an xmlBuffer for the output.
19771977 * @in: an xmlBuffer for the input
19781978 * @len: number of bytes to convert for the first line, or -1
···2059205920602060/**
20612061 * xmlCharEncFirstLine:
20622062- * @handler: char enconding transformation data structure
20622062+ * @handler: char encoding transformation data structure
20632063 * @out: an xmlBuffer for the output.
20642064 * @in: an xmlBuffer for the input
20652065 *
···2546254625472547/**
25482548 * xmlCharEncOutFunc:
25492549- * @handler: char enconding transformation data structure
25492549+ * @handler: char encoding transformation data structure
25502550 * @out: an xmlBuffer for the output.
25512551 * @in: an xmlBuffer for the input
25522552 *
···2710271027112711/**
27122712 * xmlCharEncCloseFunc:
27132713- * @handler: char enconding transformation data structure
27132713+ * @handler: char encoding transformation data structure
27142714 *
27152715 * Generic front-end for encoding handler close function
27162716 *
···28112811 xmlCharEncodingHandler * handler = in->buf->encoder;
28122812 /*
28132813 * Encoding conversion, compute the number of unused original
28142814- * bytes from the input not consumed and substract that from
28142814+ * bytes from the input not consumed and subtract that from
28152815 * the raw consumed value, this is not a cheap operation
28162816 */
28172817 if (in->end - in->cur > 0) {
···28602860 * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise
28612861 * The value of @inlen after return is the number of octets consumed
28622862 * as the return value is positive, else unpredictable.
28632863- * The value of @outlen after return is the number of ocetes consumed.
28632863+ * The value of @outlen after return is the number of octets consumed.
28642864 */
28652865static int
28662866UTF8ToISO8859x(unsigned char* out, int *outlen,
···29762976 * block of chars out.
29772977 * Returns 0 if success, or -1 otherwise
29782978 * The value of @inlen after return is the number of octets consumed
29792979- * The value of @outlen after return is the number of ocetes produced.
29792979+ * The value of @outlen after return is the number of octets produced.
29802980 */
29812981static int
29822982ISO8859xToUTF8(unsigned char* out, int *outlen,
+3-3
sdk/lib/3rdparty/libxml2/entities.c
···148148/*
149149 * xmlCreateEntity:
150150 *
151151- * internal routine doing the entity node strutures allocations
151151+ * internal routine doing the entity node structures allocations
152152 */
153153static xmlEntityPtr
154154xmlCreateEntity(xmlDictPtr dict, const xmlChar *name, int type,
···398398 *
399399 * Create a new entity, this differs from xmlAddDocEntity() that if
400400 * the document is NULL or has no internal subset defined, then an
401401- * unlinked entity structure will be returned, it is then the responsability
401401+ * unlinked entity structure will be returned, it is then the responsibility
402402 * of the caller to link it to the document later or free it when not needed
403403 * anymore.
404404 *
···548548 * xmlEncodeEntitiesInternal:
549549 * @doc: the document containing the string
550550 * @input: A string to convert to XML.
551551- * @attr: are we handling an atrbute value
551551+ * @attr: are we handling an attribute value
552552 *
553553 * Do a global encoding of a string, replacing the predefined entities
554554 * and non ASCII values with their entities and CharRef counterparts.
+2-2
sdk/lib/3rdparty/libxml2/error.c
···238238 * @ctx: the parser context or NULL
239239 * @str: the formatted error message
240240 *
241241- * Report an erro with its context, replace the 4 old error/warning
241241+ * Report an error with its context, replace the 4 old error/warning
242242 * routines.
243243 */
244244static void
···631631 (channel == xmlParserValidityError) ||
632632 (channel == xmlParserValidityWarning))
633633 xmlReportError(to, ctxt, str, NULL, NULL);
634634- else if ((channel == (xmlGenericErrorFunc) fprintf) ||
634634+ else if (((void(*)(void)) channel == (void(*)(void)) fprintf) ||
635635 (channel == xmlGenericErrorDefaultFunc))
636636 xmlReportError(to, ctxt, str, channel, data);
637637 else
+3-3
sdk/lib/3rdparty/libxml2/globals.c
···107107 * @size: the size requested in bytes
108108 *
109109 * The variable holding the libxml malloc() implementation for atomic
110110- * data (i.e. blocks not containings pointers), useful when using a
110110+ * data (i.e. blocks not containing pointers), useful when using a
111111 * garbage collecting allocator.
112112 *
113113 * Returns a pointer to the newly allocated block or NULL in case of error
···260260 * Global setting, indicate that the parser should store the line number
261261 * in the content field of elements in the DOM tree.
262262 * Disabled by default since this may not be safe for old classes of
263263- * applicaton.
263263+ * application.
264264 */
265265int xmlLineNumbersDefaultValue = 0;
266266static int xmlLineNumbersDefaultValueThrDef = 0;
···361361 * xmlSaveNoEmptyTags:
362362 *
363363 * Global setting, asking the serializer to not output empty tags
364364- * as <empty/> but <empty></empty>. those two forms are undistinguishable
364364+ * as <empty/> but <empty></empty>. those two forms are indistinguishable
365365 * once parsed.
366366 * Disabled by default
367367 */
+8-1
sdk/lib/3rdparty/libxml2/hash.c
···3333 * it seems that having hash randomization might be a good idea
3434 * when using XML with untrusted data
3535 */
3636-#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME)
3636+#if defined(HAVE_RAND) && defined(HAVE_SRAND) && defined(HAVE_TIME) && \
3737+ !defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
3738#define HASH_RANDOMIZATION
3839#endif
3940···7879 * xmlHashComputeKey:
7980 * Calculate the hash key
8081 */
8282+#ifdef __clang__
8383+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
8484+#endif
8185static unsigned long
8286xmlHashComputeKey(xmlHashTablePtr table, const xmlChar *name,
8387 const xmlChar *name2, const xmlChar *name3) {
···108112 return (value % table->size);
109113}
110114115115+#ifdef __clang__
116116+ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow")
117117+#endif
111118static unsigned long
112119xmlHashComputeQKey(xmlHashTablePtr table,
113120 const xmlChar *prefix, const xmlChar *name,
+1-1
sdk/lib/3rdparty/libxml2/include/win32config.h
···3838#if defined(_MSC_VER) || defined(__BORLANDC__)
3939/* MS C-runtime has functions which can be used in order to determine if
4040 a given floating-point variable contains NaN, (+-)INF. These are
4141- preferred, because floating-point technology is considered propriatary
4141+ preferred, because floating-point technology is considered proprietary
4242 by MS and we can assume that their functions know more about their
4343 oddities than we do. */
4444#include <float.h>
+5
sdk/lib/3rdparty/libxml2/include/wsockcompat.h
···1111#include <errno.h>
1212#include <winsock2.h>
13131414+/* Fix for old MinGW. */
1515+#ifndef _WINSOCKAPI_
1616+#define _WINSOCKAPI_
1717+#endif
1818+1419/* the following is a workaround a problem for 'inline' keyword in said
1520 header when compiled with Borland C++ 6 */
1621#if defined(__BORLANDC__) && !defined(__cplusplus)
+10-3
sdk/lib/3rdparty/libxml2/libxml.h
···3434/*
3535 * Currently supported platforms use either autoconf or
3636 * copy to config.h own "preset" configuration file.
3737- * As result ifdef HAVE_CONFIG_H is omited here.
3737+ * As result ifdef HAVE_CONFIG_H is omitted here.
3838 */
3939#include "config.h"
4040#include <libxml/xmlversion.h>
···5353/**
5454 * TRIO_REPLACE_STDIO:
5555 *
5656- * This macro is defined if teh trio string formatting functions are to
5656+ * This macro is defined if the trio string formatting functions are to
5757 * be used instead of the default stdio ones.
5858 */
5959#define TRIO_REPLACE_STDIO
···7272#define XML_POP_WARNINGS
7373#endif
74747575+#if defined(__clang__) || \
7676+ (defined(__GNUC__) && (__GNUC__ >= 8))
7777+#define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg)))
7878+#else
7979+#define ATTRIBUTE_NO_SANITIZE(arg)
8080+#endif
8181+7582/*
7683 * Internal variable indicating if a callback has been registered for
7784 * node creation/destruction. It avoids spending a lot of time in locking
···7986 */
8087extern int __xmlRegisterCallbacks;
8188/*
8282- * internal error reporting routines, shared but not partof the API.
8989+ * internal error reporting routines, shared but not part of the API.
8390 */
8491void __xmlIOErr(int domain, int code, const char *extra);
8592void __xmlLoaderErr(void *ctx, const char *msg, const char *filename) LIBXML_ATTR_FORMAT(2,0);
+2-2
sdk/lib/3rdparty/libxml2/nanohttp.c
···1143114311441144 switch (h_errno) {
11451145 case HOST_NOT_FOUND:
11461146- h_err_txt = "Authoritive host not found";
11461146+ h_err_txt = "Authoritative host not found";
11471147 break;
1148114811491149 case TRY_AGAIN:
11501150 h_err_txt =
11511151- "Non-authoritive host not found or server failure.";
11511151+ "Non-authoritative host not found or server failure.";
11521152 break;
1153115311541154 case NO_RECOVERY:
+298-274
sdk/lib/3rdparty/libxml2/parser.c
···96969797static void xmlHaltParser(xmlParserCtxtPtr ctxt);
98989999+static int
100100+xmlParseElementStart(xmlParserCtxtPtr ctxt);
101101+102102+static void
103103+xmlParseElementEnd(xmlParserCtxtPtr ctxt);
104104+99105/************************************************************************
100106 * *
101107 * Arbitrary limits set in the parser. See XML_PARSE_HUGE *
···108114/*
109115 * XML_PARSER_NON_LINEAR is the threshold where the ratio of parsed entity
110116 * replacement over the size in byte of the input indicates that you have
111111- * and eponential behaviour. A value of 10 correspond to at least 3 entity
117117+ * and exponential behaviour. A value of 10 correspond to at least 3 entity
112118 * replacement per byte of input.
113119 */
114120#define XML_PARSER_NON_LINEAR 10
···140146 if ((ent != NULL) && (ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
141147 (ent->content != NULL) && (ent->checked == 0) &&
142148 (ctxt->errNo != XML_ERR_ENTITY_LOOP)) {
143143- unsigned long oldnbent = ctxt->nbentities;
149149+ unsigned long oldnbent = ctxt->nbentities, diff;
144150 xmlChar *rep;
145151146152 ent->checked = 1;
···153159 ent->content[0] = 0;
154160 }
155161156156- ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
162162+ diff = ctxt->nbentities - oldnbent + 1;
163163+ if (diff > INT_MAX / 2)
164164+ diff = INT_MAX / 2;
165165+ ent->checked = diff * 2;
157166 if (rep != NULL) {
158167 if (xmlStrchr(rep, '<'))
159168 ent->checked |= 1;
···10601069 * xmlDetectSAX2:
10611070 * @ctxt: an XML parser context
10621071 *
10631063- * Do the SAX2 detection and specific intialization
10721072+ * Do the SAX2 detection and specific initialization
10641073 */
10651074static void
10661075xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
···13921401 * [37] UserCode ::= ('x' | 'X') '-' ([a-z] | [A-Z])+
13931402 * [38] Subcode ::= ([a-z] | [A-Z])+
13941403 *
13951395- * The current REC reference the sucessors of RFC 1766, currently 5646
14041404+ * The current REC reference the successors of RFC 1766, currently 5646
13961405 *
13971406 * http://www.rfc-editor.org/rfc/rfc5646.txt
13981407 * langtag = language
···18191828 return (ret);
18201829}
1821183018221822-#ifdef LIBXML_PUSH_ENABLED
18231831/**
18241832 * nameNsPush:
18251833 * @ctxt: an XML parser context
···18551863 goto mem_error;
18561864 }
18571865 ctxt->pushTab = tmp2;
18661866+ } else if (ctxt->pushTab == NULL) {
18671867+ ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 *
18681868+ sizeof(ctxt->pushTab[0]));
18691869+ if (ctxt->pushTab == NULL)
18701870+ goto mem_error;
18581871 }
18591872 ctxt->nameTab[ctxt->nameNr] = value;
18601873 ctxt->name = value;
···18661879 xmlErrMemory(ctxt, NULL);
18671880 return (-1);
18681881}
18821882+#ifdef LIBXML_PUSH_ENABLED
18691883/**
18701884 * nameNsPop:
18711885 * @ctxt: an XML parser context
···20752089 xmlGROW (ctxt);
2076209020772091static void xmlGROW (xmlParserCtxtPtr ctxt) {
20782078- unsigned long curEnd = ctxt->input->end - ctxt->input->cur;
20792079- unsigned long curBase = ctxt->input->cur - ctxt->input->base;
20922092+ ptrdiff_t curEnd = ctxt->input->end - ctxt->input->cur;
20932093+ ptrdiff_t curBase = ctxt->input->cur - ctxt->input->base;
2080209420812081- if (((curEnd > (unsigned long) XML_MAX_LOOKUP_LIMIT) ||
20822082- (curBase > (unsigned long) XML_MAX_LOOKUP_LIMIT)) &&
20952095+ if (((curEnd > XML_MAX_LOOKUP_LIMIT) ||
20962096+ (curBase > XML_MAX_LOOKUP_LIMIT)) &&
20832097 ((ctxt->input->buf) &&
20842098 (ctxt->input->buf->readcallback != xmlInputReadCallbackNop)) &&
20852099 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
···22812295 */
22822296int
22832297xmlParseCharRef(xmlParserCtxtPtr ctxt) {
22842284- unsigned int val = 0;
22982298+ int val = 0;
22852299 int count = 0;
22862286- unsigned int outofrange = 0;
2287230022882301 /*
22892302 * Using RAW/CUR/NEXT is okay since we are working on ASCII range here
···23102323 val = 0;
23112324 break;
23122325 }
23132313- if (val > 0x10FFFF)
23142314- outofrange = val;
23262326+ if (val > 0x110000)
23272327+ val = 0x110000;
2315232823162329 NEXT;
23172330 count++;
···23392352 val = 0;
23402353 break;
23412354 }
23422342- if (val > 0x10FFFF)
23432343- outofrange = val;
23552355+ if (val > 0x110000)
23562356+ val = 0x110000;
2344235723452358 NEXT;
23462359 count++;
···23602373 * Characters referred to using character references must match the
23612374 * production for Char.
23622375 */
23632363- if ((IS_CHAR(val) && (outofrange == 0))) {
23762376+ if (val >= 0x110000) {
23772377+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
23782378+ "xmlParseCharRef: character reference out of bounds\n",
23792379+ val);
23802380+ } else if (IS_CHAR(val)) {
23642381 return(val);
23652382 } else {
23662383 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
···23922409xmlParseStringCharRef(xmlParserCtxtPtr ctxt, const xmlChar **str) {
23932410 const xmlChar *ptr;
23942411 xmlChar cur;
23952395- unsigned int val = 0;
23962396- unsigned int outofrange = 0;
24122412+ int val = 0;
2397241323982414 if ((str == NULL) || (*str == NULL)) return(0);
23992415 ptr = *str;
···24132429 val = 0;
24142430 break;
24152431 }
24162416- if (val > 0x10FFFF)
24172417- outofrange = val;
24322432+ if (val > 0x110000)
24332433+ val = 0x110000;
2418243424192435 ptr++;
24202436 cur = *ptr;
···24322448 val = 0;
24332449 break;
24342450 }
24352435- if (val > 0x10FFFF)
24362436- outofrange = val;
24512451+ if (val > 0x110000)
24522452+ val = 0x110000;
2437245324382454 ptr++;
24392455 cur = *ptr;
···24512467 * Characters referred to using character references must match the
24522468 * production for Char.
24532469 */
24542454- if ((IS_CHAR(val) && (outofrange == 0))) {
24702470+ if (val >= 0x110000) {
24712471+ xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
24722472+ "xmlParseStringCharRef: character reference out of bounds\n",
24732473+ val);
24742474+ } else if (IS_CHAR(val)) {
24552475 return(val);
24562476 } else {
24572477 xmlFatalErrMsgInt(ctxt, XML_ERR_INVALID_CHAR,
···27022722 /*
27032723 * Note: external parsed entities will not be loaded,
27042724 * it is not required for a non-validating parser to
27052705- * complete external PEreferences coming from the
27252725+ * complete external PEReferences coming from the
27062726 * internal subset
27072727 */
27082728 if (((ctxt->options & XML_PARSE_NOENT) != 0) ||
···33663386 /*
33673387 * when shrinking to extend the buffer we really need to preserve
33683388 * the part of the name we already parsed. Hence rolling back
33693369- * by current lenght.
33893389+ * by current length.
33703390 */
33713391 ctxt->input->cur -= l;
33723392 GROW;
···38353855 * xmlParseAttValueComplex:
38363856 * @ctxt: an XML parser context
38373857 * @len: the resulting attribute len
38383838- * @normalize: wether to apply the inner normalization
38583858+ * @normalize: whether to apply the inner normalization
38393859 *
38403860 * parse a value for an attribute, this is the fallback function
38413861 * of xmlParseAttValue() when the attribute parsing requires handling
···39844004 */
39854005 if ((ent->etype != XML_INTERNAL_PREDEFINED_ENTITY) &&
39864006 (ent->content != NULL) && (ent->checked == 0)) {
39873987- unsigned long oldnbent = ctxt->nbentities;
40074007+ unsigned long oldnbent = ctxt->nbentities, diff;
3988400839894009 ++ctxt->depth;
39904010 rep = xmlStringDecodeEntities(ctxt, ent->content,
39914011 XML_SUBSTITUTE_REF, 0, 0, 0);
39924012 --ctxt->depth;
3993401339943994- ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
40144014+ diff = ctxt->nbentities - oldnbent + 1;
40154015+ if (diff > INT_MAX / 2)
40164016+ diff = INT_MAX / 2;
40174017+ ent->checked = diff * 2;
39954018 if (rep != NULL) {
39964019 if (xmlStrchr(rep, '<'))
39974020 ent->checked |= 1;
···4059408240604083 /*
40614084 * There we potentially risk an overflow, don't allow attribute value of
40624062- * length more than INT_MAX it is a very reasonnable assumption !
40854085+ * length more than INT_MAX it is a very reasonable assumption !
40634086 */
40644087 if (len >= INT_MAX) {
40654088 xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
···46644687 * xmlParseCommentComplex:
46654688 * @ctxt: an XML parser context
46664689 * @buf: the already parsed part of the buffer
46674667- * @len: number of bytes filles in the buffer
46904690+ * @len: number of bytes in the buffer
46684691 * @size: allocated size of the buffer
46694692 *
46704693 * Skip an XML (SGML) comment <!-- .... -->
···49554978 } else
49564979 xmlFatalErrMsgStr(ctxt, XML_ERR_HYPHEN_IN_COMMENT,
49574980 "Double hyphen within comment\n", NULL);
49814981+ if (ctxt->instate == XML_PARSER_EOF) {
49824982+ xmlFree(buf);
49834983+ return;
49844984+ }
49584985 in++;
49594986 ctxt->input->col++;
49604987 }
···50855112 *
50865113 * [16] PI ::= '<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'
50875114 *
50885088- * The processing is transfered to SAX once parsed.
51155115+ * The processing is transferred to SAX once parsed.
50895116 */
5090511750915118void
···55015528 literal, URI, NULL);
55025529 /*
55035530 * For expat compatibility in SAX mode.
55045504- * assuming the entity repalcement was asked for
55315531+ * assuming the entity replacement was asked for
55055532 */
55065533 if ((ctxt->replaceEntities != 0) &&
55075534 ((ctxt->myDoc == NULL) ||
···6611663866126639static void
66136640xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
66146614- int id = ctxt->input->id;
66416641+ int *inputIds = NULL;
66426642+ size_t inputIdsSize = 0;
66436643+ size_t depth = 0;
6615664466166616- SKIP(3);
66176617- SKIP_BLANKS;
66186618- if (CMP7(CUR_PTR, 'I', 'N', 'C', 'L', 'U', 'D', 'E')) {
66196619- SKIP(7);
66206620- SKIP_BLANKS;
66216621- if (RAW != '[') {
66226622- xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
66236623- xmlHaltParser(ctxt);
66246624- return;
66256625- } else {
66266626- if (ctxt->input->id != id) {
66276627- xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
66286628- "All markup of the conditional section is not"
66296629- " in the same entity\n");
66306630- }
66316631- NEXT;
66326632- }
66336633- if (xmlParserDebugEntities) {
66346634- if ((ctxt->input != NULL) && (ctxt->input->filename))
66356635- xmlGenericError(xmlGenericErrorContext,
66366636- "%s(%d): ", ctxt->input->filename,
66376637- ctxt->input->line);
66386638- xmlGenericError(xmlGenericErrorContext,
66396639- "Entering INCLUDE Conditional Section\n");
66406640- }
66456645+ while (ctxt->instate != XML_PARSER_EOF) {
66466646+ if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
66476647+ int id = ctxt->input->id;
6641664866426642- SKIP_BLANKS;
66436643- GROW;
66446644- while (((RAW != 0) && ((RAW != ']') || (NXT(1) != ']') ||
66456645- (NXT(2) != '>'))) && (ctxt->instate != XML_PARSER_EOF)) {
66466646- const xmlChar *check = CUR_PTR;
66476647- unsigned int cons = ctxt->input->consumed;
66496649+ SKIP(3);
66506650+ SKIP_BLANKS;
6648665166496649- if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
66506650- xmlParseConditionalSections(ctxt);
66516651- } else
66526652- xmlParseMarkupDecl(ctxt);
66526652+ if (CMP7(CUR_PTR, 'I', 'N', 'C', 'L', 'U', 'D', 'E')) {
66536653+ SKIP(7);
66546654+ SKIP_BLANKS;
66556655+ if (RAW != '[') {
66566656+ xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
66576657+ xmlHaltParser(ctxt);
66586658+ goto error;
66596659+ }
66606660+ if (ctxt->input->id != id) {
66616661+ xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
66626662+ "All markup of the conditional section is"
66636663+ " not in the same entity\n");
66646664+ }
66656665+ NEXT;
6653666666546654- SKIP_BLANKS;
66556655- GROW;
66676667+ if (inputIdsSize <= depth) {
66686668+ int *tmp;
6656666966576657- if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
66586658- xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
66596659- xmlHaltParser(ctxt);
66606660- break;
66616661- }
66626662- }
66636663- if (xmlParserDebugEntities) {
66646664- if ((ctxt->input != NULL) && (ctxt->input->filename))
66656665- xmlGenericError(xmlGenericErrorContext,
66666666- "%s(%d): ", ctxt->input->filename,
66676667- ctxt->input->line);
66686668- xmlGenericError(xmlGenericErrorContext,
66696669- "Leaving INCLUDE Conditional Section\n");
66706670- }
66706670+ inputIdsSize = (inputIdsSize == 0 ? 4 : inputIdsSize * 2);
66716671+ tmp = (int *) xmlRealloc(inputIds,
66726672+ inputIdsSize * sizeof(int));
66736673+ if (tmp == NULL) {
66746674+ xmlErrMemory(ctxt, NULL);
66756675+ goto error;
66766676+ }
66776677+ inputIds = tmp;
66786678+ }
66796679+ inputIds[depth] = id;
66806680+ depth++;
66816681+ } else if (CMP6(CUR_PTR, 'I', 'G', 'N', 'O', 'R', 'E')) {
66826682+ int state;
66836683+ xmlParserInputState instate;
66846684+ size_t ignoreDepth = 0;
6671668566726672- } else if (CMP6(CUR_PTR, 'I', 'G', 'N', 'O', 'R', 'E')) {
66736673- int state;
66746674- xmlParserInputState instate;
66756675- int depth = 0;
66866686+ SKIP(6);
66876687+ SKIP_BLANKS;
66886688+ if (RAW != '[') {
66896689+ xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
66906690+ xmlHaltParser(ctxt);
66916691+ goto error;
66926692+ }
66936693+ if (ctxt->input->id != id) {
66946694+ xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
66956695+ "All markup of the conditional section is"
66966696+ " not in the same entity\n");
66976697+ }
66986698+ NEXT;
6676669966776677- SKIP(6);
66786678- SKIP_BLANKS;
66796679- if (RAW != '[') {
66806680- xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID, NULL);
66816681- xmlHaltParser(ctxt);
66826682- return;
66836683- } else {
66846684- if (ctxt->input->id != id) {
66856685- xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
66866686- "All markup of the conditional section is not"
66876687- " in the same entity\n");
66886688- }
66896689- NEXT;
66906690- }
66916691- if (xmlParserDebugEntities) {
66926692- if ((ctxt->input != NULL) && (ctxt->input->filename))
66936693- xmlGenericError(xmlGenericErrorContext,
66946694- "%s(%d): ", ctxt->input->filename,
66956695- ctxt->input->line);
66966696- xmlGenericError(xmlGenericErrorContext,
66976697- "Entering IGNORE Conditional Section\n");
66986698- }
67006700+ /*
67016701+ * Parse up to the end of the conditional section but disable
67026702+ * SAX event generating DTD building in the meantime
67036703+ */
67046704+ state = ctxt->disableSAX;
67056705+ instate = ctxt->instate;
67066706+ if (ctxt->recovery == 0) ctxt->disableSAX = 1;
67076707+ ctxt->instate = XML_PARSER_IGNORE;
6699670867006700- /*
67016701- * Parse up to the end of the conditional section
67026702- * But disable SAX event generating DTD building in the meantime
67036703- */
67046704- state = ctxt->disableSAX;
67056705- instate = ctxt->instate;
67066706- if (ctxt->recovery == 0) ctxt->disableSAX = 1;
67076707- ctxt->instate = XML_PARSER_IGNORE;
67096709+ while (RAW != 0) {
67106710+ if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
67116711+ SKIP(3);
67126712+ ignoreDepth++;
67136713+ /* Check for integer overflow */
67146714+ if (ignoreDepth == 0) {
67156715+ xmlErrMemory(ctxt, NULL);
67166716+ goto error;
67176717+ }
67186718+ } else if ((RAW == ']') && (NXT(1) == ']') &&
67196719+ (NXT(2) == '>')) {
67206720+ if (ignoreDepth == 0)
67216721+ break;
67226722+ SKIP(3);
67236723+ ignoreDepth--;
67246724+ } else {
67256725+ NEXT;
67266726+ }
67276727+ }
6708672867096709- while (((depth >= 0) && (RAW != 0)) &&
67106710- (ctxt->instate != XML_PARSER_EOF)) {
67116711- if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
67126712- depth++;
67136713- SKIP(3);
67146714- continue;
67156715- }
67166716- if ((RAW == ']') && (NXT(1) == ']') && (NXT(2) == '>')) {
67176717- if (--depth >= 0) SKIP(3);
67186718- continue;
67196719- }
67206720- NEXT;
67216721- continue;
67226722- }
67296729+ ctxt->disableSAX = state;
67306730+ ctxt->instate = instate;
6723673167246724- ctxt->disableSAX = state;
67256725- ctxt->instate = instate;
67326732+ if (RAW == 0) {
67336733+ xmlFatalErr(ctxt, XML_ERR_CONDSEC_NOT_FINISHED, NULL);
67346734+ goto error;
67356735+ }
67366736+ if (ctxt->input->id != id) {
67376737+ xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
67386738+ "All markup of the conditional section is"
67396739+ " not in the same entity\n");
67406740+ }
67416741+ SKIP(3);
67426742+ } else {
67436743+ xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
67446744+ xmlHaltParser(ctxt);
67456745+ goto error;
67466746+ }
67476747+ } else if ((depth > 0) &&
67486748+ (RAW == ']') && (NXT(1) == ']') && (NXT(2) == '>')) {
67496749+ depth--;
67506750+ if (ctxt->input->id != inputIds[depth]) {
67516751+ xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
67526752+ "All markup of the conditional section is not"
67536753+ " in the same entity\n");
67546754+ }
67556755+ SKIP(3);
67566756+ } else {
67576757+ const xmlChar *check = CUR_PTR;
67586758+ unsigned int cons = ctxt->input->consumed;
6726675967276727- if (xmlParserDebugEntities) {
67286728- if ((ctxt->input != NULL) && (ctxt->input->filename))
67296729- xmlGenericError(xmlGenericErrorContext,
67306730- "%s(%d): ", ctxt->input->filename,
67316731- ctxt->input->line);
67326732- xmlGenericError(xmlGenericErrorContext,
67336733- "Leaving IGNORE Conditional Section\n");
67346734- }
67606760+ xmlParseMarkupDecl(ctxt);
6735676167366736- } else {
67376737- xmlFatalErr(ctxt, XML_ERR_CONDSEC_INVALID_KEYWORD, NULL);
67386738- xmlHaltParser(ctxt);
67396739- return;
67406740- }
67626762+ if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
67636763+ xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
67646764+ xmlHaltParser(ctxt);
67656765+ goto error;
67666766+ }
67676767+ }
6741676867426742- if (RAW == 0)
67436743- SHRINK;
67696769+ if (depth == 0)
67706770+ break;
6744677167456745- if (RAW == 0) {
67466746- xmlFatalErr(ctxt, XML_ERR_CONDSEC_NOT_FINISHED, NULL);
67476747- } else {
67486748- if (ctxt->input->id != id) {
67496749- xmlFatalErrMsg(ctxt, XML_ERR_ENTITY_BOUNDARY,
67506750- "All markup of the conditional section is not in"
67516751- " the same entity\n");
67526752- }
67536753- if ((ctxt-> instate != XML_PARSER_EOF) &&
67546754- ((ctxt->input->cur + 3) <= ctxt->input->end))
67556755- SKIP(3);
67726772+ SKIP_BLANKS;
67736773+ GROW;
67566774 }
67756775+67766776+error:
67776777+ xmlFree(inputIds);
67576778}
6758677967596780/**
···6810683168116832 /*
68126833 * detect requirement to exit there and act accordingly
68136813- * and avoid having instate overriden later on
68346834+ * and avoid having instate overridden later on
68146835 */
68156836 if (ctxt->instate == XML_PARSER_EOF)
68166837 return;
68176817-68186818- /*
68196819- * Conditional sections are allowed from entities included
68206820- * by PE References in the internal subset.
68216821- */
68226822- if ((ctxt->external == 0) && (ctxt->inputNr > 1)) {
68236823- if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
68246824- xmlParseConditionalSections(ctxt);
68256825- }
68266826- }
6827683868286839 ctxt->instate = XML_PARSER_DTD;
68296840}
···70097020 */
70107021 if (NXT(1) == '#') {
70117022 int i = 0;
70127012- xmlChar out[10];
70237023+ xmlChar out[16];
70137024 int hex = NXT(2);
70147025 int value = xmlParseCharRef(ctxt);
70157026···70867097 ((ent->children == NULL) && (ctxt->options & XML_PARSE_NOENT))) &&
70877098 ((ent->etype != XML_EXTERNAL_GENERAL_PARSED_ENTITY) ||
70887099 (ctxt->options & (XML_PARSE_NOENT | XML_PARSE_DTDVALID)))) {
70897089- unsigned long oldnbent = ctxt->nbentities;
71007100+ unsigned long oldnbent = ctxt->nbentities, diff;
7090710170917102 /*
70927103 * This is a bit hackish but this seems the best
···71277138 * Store the number of entities needing parsing for this entity
71287139 * content and do checkings
71297140 */
71307130- ent->checked = (ctxt->nbentities - oldnbent + 1) * 2;
71417141+ diff = ctxt->nbentities - oldnbent + 1;
71427142+ if (diff > INT_MAX / 2)
71437143+ diff = INT_MAX / 2;
71447144+ ent->checked = diff * 2;
71317145 if ((ent->content != NULL) && (xmlStrchr(ent->content, '<')))
71327146 ent->checked |= 1;
71337147 if (ret == XML_ERR_ENTITY_LOOP) {
···76757689 }
7676769076777691 /*
76787678- * Increate the number of entity references parsed
76927692+ * Increase the number of entity references parsed
76797693 */
76807694 ctxt->nbentities++;
76817695···78517865 NEXT;
7852786678537867 /*
78547854- * Increate the number of entity references parsed
78687868+ * Increase the number of entity references parsed
78557869 */
78567870 ctxt->nbentities++;
78577871···81178131 ptr++;
8118813281198133 /*
81208120- * Increate the number of entity references parsed
81348134+ * Increase the number of entity references parsed
81218135 */
81228136 ctxt->nbentities++;
81238137···82858299 xmlParseMarkupDecl(ctxt);
82868300 xmlParsePEReference(ctxt);
8287830183028302+ /*
83038303+ * Conditional sections are allowed from external entities included
83048304+ * by PE References in the internal subset.
83058305+ */
83068306+ if ((ctxt->inputNr > 1) && (ctxt->input->filename != NULL) &&
83078307+ (RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
83088308+ xmlParseConditionalSections(ctxt);
83098309+ }
83108310+82888311 if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
82898312 xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
82908313 "xmlParseInternalSubset: error detected in Markup declaration\n");
···87138736 if (l == NULL) {
87148737 xmlChar *tmp;
8715873887398739+ if (ctxt->instate == XML_PARSER_EOF)
87408740+ return(NULL);
87168741 xmlNsErr(ctxt, XML_NS_ERR_QNAME,
87178742 "Failed to parse QName '%s:'\n", p, NULL, NULL);
87188743 l = xmlParseNmtoken(ctxt);
87198719- if (l == NULL)
87448744+ if (l == NULL) {
87458745+ if (ctxt->instate == XML_PARSER_EOF)
87468746+ return(NULL);
87208747 tmp = xmlBuildQName(BAD_CAST "", p, NULL, 0);
87218721- else {
87488748+ } else {
87228749 tmp = xmlBuildQName(l, p, NULL, 0);
87238750 xmlFree((char *)l);
87248751 }
···87418768 *prefix = p;
87428769 return(l);
87438770 }
87718771+ if (ctxt->instate == XML_PARSER_EOF)
87728772+ return(NULL);
87448773 tmp = xmlBuildQName(BAD_CAST "", l, NULL, 0);
87458774 l = xmlDictLookup(ctxt->dict, tmp, -1);
87468775 if (tmp != NULL) xmlFree(tmp);
···88408869 * caller if it was copied, this can be detected by val[*len] == 0.
88418870 */
8842887188728872+#define GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end) \
88738873+ const xmlChar *oldbase = ctxt->input->base;\
88748874+ GROW;\
88758875+ if (ctxt->instate == XML_PARSER_EOF)\
88768876+ return(NULL);\
88778877+ if (oldbase != ctxt->input->base) {\
88788878+ ptrdiff_t delta = ctxt->input->base - oldbase;\
88798879+ start = start + delta;\
88808880+ in = in + delta;\
88818881+ }\
88828882+ end = ctxt->input->end;
88838883+88438884static xmlChar *
88448885xmlParseAttValueInternal(xmlParserCtxtPtr ctxt, int *len, int *alloc,
88458886 int normalize)
···88698910 end = ctxt->input->end;
88708911 start = in;
88718912 if (in >= end) {
88728872- const xmlChar *oldbase = ctxt->input->base;
88738873- GROW;
88748874- if (oldbase != ctxt->input->base) {
88758875- long delta = ctxt->input->base - oldbase;
88768876- start = start + delta;
88778877- in = in + delta;
88788878- }
88798879- end = ctxt->input->end;
89138913+ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
88808914 }
88818915 if (normalize) {
88828916 /*
···88938927 in++;
88948928 start = in;
88958929 if (in >= end) {
88968896- const xmlChar *oldbase = ctxt->input->base;
88978897- GROW;
88988898- if (ctxt->instate == XML_PARSER_EOF)
88998899- return(NULL);
89008900- if (oldbase != ctxt->input->base) {
89018901- long delta = ctxt->input->base - oldbase;
89028902- start = start + delta;
89038903- in = in + delta;
89048904- }
89058905- end = ctxt->input->end;
89308930+ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
89068931 if (((in - start) > XML_MAX_TEXT_LENGTH) &&
89078932 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
89088933 xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
···89168941 col++;
89178942 if ((*in++ == 0x20) && (*in == 0x20)) break;
89188943 if (in >= end) {
89198919- const xmlChar *oldbase = ctxt->input->base;
89208920- GROW;
89218921- if (ctxt->instate == XML_PARSER_EOF)
89228922- return(NULL);
89238923- if (oldbase != ctxt->input->base) {
89248924- long delta = ctxt->input->base - oldbase;
89258925- start = start + delta;
89268926- in = in + delta;
89278927- }
89288928- end = ctxt->input->end;
89448944+ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
89298945 if (((in - start) > XML_MAX_TEXT_LENGTH) &&
89308946 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
89318947 xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
···89548970 if (ctxt->instate == XML_PARSER_EOF)
89558971 return(NULL);
89568972 if (oldbase != ctxt->input->base) {
89578957- long delta = ctxt->input->base - oldbase;
89738973+ ptrdiff_t delta = ctxt->input->base - oldbase;
89588974 start = start + delta;
89598975 in = in + delta;
89608976 last = last + delta;
···89818997 in++;
89828998 col++;
89838999 if (in >= end) {
89848984- const xmlChar *oldbase = ctxt->input->base;
89858985- GROW;
89868986- if (ctxt->instate == XML_PARSER_EOF)
89878987- return(NULL);
89888988- if (oldbase != ctxt->input->base) {
89898989- long delta = ctxt->input->base - oldbase;
89908990- start = start + delta;
89918991- in = in + delta;
89928992- }
89938993- end = ctxt->input->end;
90009000+ GROW_PARSE_ATT_VALUE_INTERNAL(ctxt, in, start, end)
89949001 if (((in - start) > XML_MAX_TEXT_LENGTH) &&
89959002 ((ctxt->options & XML_PARSE_HUGE) == 0)) {
89969003 xmlFatalErrMsg(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED,
···90849091 if (normalize) {
90859092 /*
90869093 * Sometimes a second normalisation pass for spaces is needed
90879087- * but that only happens if charrefs or entities refernces
90949094+ * but that only happens if charrefs or entities references
90889095 * have been used in the attribute value, i.e. the attribute
90899096 * value have been extracted in an allocated string already.
90909097 */
···92479254 xmlErrMemory(ctxt, "dictionary allocation failure");
92489255 if ((attvalue != NULL) && (alloc != 0))
92499256 xmlFree(attvalue);
92509250- return(NULL);
92579257+ localname = NULL;
92589258+ goto done;
92519259 }
92529260 if (*URL != 0) {
92539261 uri = xmlParseURI((const char *) URL);
···9497950594989506 if ((atts == NULL) || (nbatts + 5 > maxatts)) {
94999507 if (xmlCtxtGrowAttrs(ctxt, nbatts + 5) < 0) {
95009500- return(NULL);
95089508+ localname = NULL;
95099509+ goto done;
95019510 }
95029511 maxatts = ctxt->maxatts;
95039512 atts = ctxt->atts;
···9807981698089817void
98099818xmlParseContent(xmlParserCtxtPtr ctxt) {
98199819+ int nameNr = ctxt->nameNr;
98209820+98109821 GROW;
98119822 while ((RAW != 0) &&
98129812- ((RAW != '<') || (NXT(1) != '/')) &&
98139823 (ctxt->instate != XML_PARSER_EOF)) {
98149824 const xmlChar *test = CUR_PTR;
98159825 unsigned int cons = ctxt->input->consumed;
···98439853 * Fourth case : a sub-element.
98449854 */
98459855 else if (*cur == '<') {
98469846- xmlParseElement(ctxt);
98569856+ if (NXT(1) == '/') {
98579857+ if (ctxt->nameNr <= nameNr)
98589858+ break;
98599859+ xmlParseElementEnd(ctxt);
98609860+ } else {
98619861+ xmlParseElementStart(ctxt);
98629862+ }
98479863 }
9848986498499865 /*
···98789894 * xmlParseElement:
98799895 * @ctxt: an XML parser context
98809896 *
98819881- * parse an XML element, this is highly recursive
98979897+ * parse an XML element
98829898 *
98839899 * [39] element ::= EmptyElemTag | STag content ETag
98849900 *
···9890990698919907void
98929908xmlParseElement(xmlParserCtxtPtr ctxt) {
99099909+ if (xmlParseElementStart(ctxt) != 0)
99109910+ return;
99119911+ xmlParseContent(ctxt);
99129912+ if (ctxt->instate == XML_PARSER_EOF)
99139913+ return;
99149914+ xmlParseElementEnd(ctxt);
99159915+}
99169916+99179917+/**
99189918+ * xmlParseElementStart:
99199919+ * @ctxt: an XML parser context
99209920+ *
99219921+ * Parse the start of an XML element. Returns -1 in case of error, 0 if an
99229922+ * opening tag was parsed, 1 if an empty element was parsed.
99239923+ */
99249924+static int
99259925+xmlParseElementStart(xmlParserCtxtPtr ctxt) {
98939926 const xmlChar *name;
98949927 const xmlChar *prefix = NULL;
98959928 const xmlChar *URI = NULL;
···99049937 "Excessive depth in document: %d use XML_PARSE_HUGE option\n",
99059938 xmlParserMaxDepth);
99069939 xmlHaltParser(ctxt);
99079907- return;
99409940+ return(-1);
99089941 }
9909994299109943 /* Capture start position */
···99319964 name = xmlParseStartTag(ctxt);
99329965#endif /* LIBXML_SAX1_ENABLED */
99339966 if (ctxt->instate == XML_PARSER_EOF)
99349934- return;
99679967+ return(-1);
99359968 if (name == NULL) {
99369969 spacePop(ctxt);
99379937- return;
99709970+ return(-1);
99389971 }
99399939- namePush(ctxt, name);
99729972+ if (ctxt->sax2)
99739973+ nameNsPush(ctxt, name, prefix, URI, ctxt->nsNr - nsNr);
99749974+#ifdef LIBXML_SAX1_ENABLED
99759975+ else
99769976+ namePush(ctxt, name);
99779977+#endif /* LIBXML_SAX1_ENABLED */
99409978 ret = ctxt->node;
9941997999429980#ifdef LIBXML_VALID_ENABLED
···997710015 node_info.node = ret;
997810016 xmlParserAddNodeInfo(ctxt, &node_info);
997910017 }
99809980- return;
1001810018+ return(1);
998110019 }
998210020 if (RAW == '>') {
998310021 NEXT1;
···1000510043 node_info.node = ret;
1000610044 xmlParserAddNodeInfo(ctxt, &node_info);
1000710045 }
1000810008- return;
1004610046+ return(-1);
1000910047 }
10010100481001110011- /*
1001210012- * Parse the content of the element:
1001310013- */
1001410014- xmlParseContent(ctxt);
1001510015- if (ctxt->instate == XML_PARSER_EOF)
1001610016- return;
1001710017- if (!IS_BYTE_CHAR(RAW)) {
1001810018- xmlFatalErrMsgStrIntStr(ctxt, XML_ERR_TAG_NOT_FINISHED,
1001910019- "Premature end of data in tag %s line %d\n",
1002010020- name, line, NULL);
1004910049+ return(0);
1005010050+}
10021100511002210022- /*
1002310023- * end of parsing of this node.
1002410024- */
1002510025- nodePop(ctxt);
1002610026- namePop(ctxt);
1002710027- spacePop(ctxt);
1002810028- if (nsNr != ctxt->nsNr)
1002910029- nsPop(ctxt, ctxt->nsNr - nsNr);
1003010030- return;
1003110031- }
1005210052+/**
1005310053+ * xmlParseElementEnd:
1005410054+ * @ctxt: an XML parser context
1005510055+ *
1005610056+ * Parse the end of an XML element.
1005710057+ */
1005810058+static void
1005910059+xmlParseElementEnd(xmlParserCtxtPtr ctxt) {
1006010060+ xmlParserNodeInfo node_info;
1006110061+ xmlNodePtr ret = ctxt->node;
1006210062+1006310063+ if (ctxt->nameNr <= 0)
1006410064+ return;
10032100651003310066 /*
1003410067 * parse the end of tag: '</' should be here.
1003510068 */
1003610069 if (ctxt->sax2) {
1003710037- xmlParseEndTag2(ctxt, prefix, URI, line, ctxt->nsNr - nsNr, tlen);
1007010070+ const xmlChar *prefix = ctxt->pushTab[ctxt->nameNr * 3 - 3];
1007110071+ const xmlChar *URI = ctxt->pushTab[ctxt->nameNr * 3 - 2];
1007210072+ int nsNr = (ptrdiff_t) ctxt->pushTab[ctxt->nameNr * 3 - 1];
1007310073+ xmlParseEndTag2(ctxt, prefix, URI, 0, nsNr, 0);
1003810074 namePop(ctxt);
1003910075 }
1004010076#ifdef LIBXML_SAX1_ENABLED
1004110041- else
1004210042- xmlParseEndTag1(ctxt, line);
1007710077+ else
1007810078+ xmlParseEndTag1(ctxt, 0);
1004310079#endif /* LIBXML_SAX1_ENABLED */
10044100801004510081 /*
···1028110317 }
10282103181028310319 /*
1028410284- * UTF-16 encoding stwich has already taken place at this stage,
1032010320+ * UTF-16 encoding switch has already taken place at this stage,
1028510321 * more over the little-endian/big-endian selection is already done
1028610322 */
1028710323 if ((encoding != NULL) &&
···1116411200 else {
1116511201 /*
1116611202 * If we are operating on converted input, try to flush
1116711167- * remainng chars to avoid them stalling in the non-converted
1120311203+ * remaining chars to avoid them stalling in the non-converted
1116811204 * buffer. But do not do this in document start where
1116911205 * encoding="..." may not have been read and we work on a
1117011206 * guessed encoding.
···1235612392 return(NULL);
1235712393 }
1235812394 ctxt->dictNames = 1;
1235912359- ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 * sizeof(xmlChar *));
1236012360- if (ctxt->pushTab == NULL) {
1236112361- xmlErrMemory(ctxt, NULL);
1236212362- xmlFreeParserInputBuffer(buf);
1236312363- xmlFreeParserCtxt(ctxt);
1236412364- return(NULL);
1236512365- }
1236612395 if (sax != NULL) {
1236712396#ifdef LIBXML_SAX1_ENABLED
1236812397 if (ctxt->sax != (xmlSAXHandlerPtr) &xmlDefaultSAXHandler)
···1389813927 xmlFreeParserCtxt(ctxt);
1389913928 newDoc->intSubset = NULL;
1390013929 newDoc->extSubset = NULL;
1390113901- newDoc->oldNs = NULL;
1393013930+ if(doc != NULL)
1393113931+ newDoc->oldNs = NULL;
1390213932 xmlFreeDoc(newDoc);
13903139331390413934 return(ret);
···1400614036 */
1400714037 ctxt->input_id = pctx->input_id + 1;
1400814038 }
1403914039+1404014040+ /* Don't read from stdin. */
1404114041+ if (xmlStrcmp(URL, BAD_CAST "-") == 0)
1404214042+ URL = BAD_CAST "./-";
14009140431401014044 uri = xmlBuildURI(URL, base);
1401114045···1493814972 }
14939149731494014974 xmlCtxtReset(ctxt);
1494114941-1494214942- if (ctxt->pushTab == NULL) {
1494314943- ctxt->pushTab = (void **) xmlMalloc(ctxt->nameMax * 3 *
1494414944- sizeof(xmlChar *));
1494514945- if (ctxt->pushTab == NULL) {
1494614946- xmlErrMemory(ctxt, NULL);
1494714947- xmlFreeParserInputBuffer(buf);
1494814948- return(1);
1494914949- }
1495014950- }
14951149751495214976 if (filename == NULL) {
1495314977 ctxt->directory = NULL;
+4-4
sdk/lib/3rdparty/libxml2/parserInternals.c
···703703 /*
704704 * An encoding problem may arise from a truncated input buffer
705705 * splitting a character in the middle. In that case do not raise
706706- * an error but return 0 to endicate an end of stream problem
706706+ * an error but return 0 to indicate an end of stream problem
707707 */
708708 if (ctxt->input->end - ctxt->input->cur < 4) {
709709 *len = 0;
···816816 /*
817817 * An encoding problem may arise from a truncated input buffer
818818 * splitting a character in the middle. In that case do not raise
819819- * an error but return 0 to endicate an end of stream problem
819819+ * an error but return 0 to indicate an end of stream problem
820820 */
821821 if ((ctxt == NULL) || (ctxt->input == NULL) ||
822822 (ctxt->input->end - ctxt->input->cur < 4)) {
···10931093 }
10941094 }
10951095 /*
10961096- * TODO: We could recover from errors in external entites if we
10961096+ * TODO: We could recover from errors in external entities if we
10971097 * didn't stop the parser. But most callers of this function don't
10981098 * check the return value.
10991099 */
···11381138 if (input->buf != NULL) {
11391139 if (input->buf->encoder != NULL) {
11401140 /*
11411141- * Check in case the auto encoding detetection triggered
11411141+ * Check in case the auto encoding detection triggered
11421142 * in already.
11431143 */
11441144 if (input->buf->encoder == handler)
+10-7
sdk/lib/3rdparty/libxml2/pattern.c
···11/*
22- * pattern.c: Implemetation of selectors for nodes
22+ * pattern.c: Implementation of selectors for nodes
33 *
44 * Reference:
55 * http://www.w3.org/TR/2001/REC-xmlschema-1-20010502/
···5555/*
5656* NOTE: Those private flags (XML_STREAM_xxx) are used
5757* in _xmlStreamCtxt->flag. They extend the public
5858-* xmlPatternFlags, so be carefull not to interfere with the
5858+* xmlPatternFlags, so be careful not to interfere with the
5959* reserved values for xmlPatternFlags.
6060*/
6161#define XML_STREAM_FINAL_IS_ANY_NODE 1<<14
···229229 */
230230void
231231xmlFreePattern(xmlPatternPtr comp) {
232232+ xmlFreePatternList(comp);
233233+}
234234+235235+static void
236236+xmlFreePatternInternal(xmlPatternPtr comp) {
232237 xmlStepOpPtr op;
233238 int i;
234239235240 if (comp == NULL)
236241 return;
237237- if (comp->next != NULL)
238238- xmlFreePattern(comp->next);
239242 if (comp->stream != NULL)
240243 xmlFreeStreamComp(comp->stream);
241244 if (comp->pattern != NULL)
···273276 cur = comp;
274277 comp = comp->next;
275278 cur->next = NULL;
276276- xmlFreePattern(cur);
279279+ xmlFreePatternInternal(cur);
277280 }
278281}
279282···742745 * xmlPatScanLiteral:
743746 * @ctxt: the XPath Parser context
744747 *
745745- * Parse an XPath Litteral:
748748+ * Parse an XPath Literal:
746749 *
747750 * [29] Literal ::= '"' [^"]* '"'
748751 * | "'" [^']* "'"
···19731976 } else {
19741977 /*
19751978 * If there are "//", then we need to process every "//"
19761976- * occuring in the states, plus any other state for this
19791979+ * occurring in the states, plus any other state for this
19771980 * level.
19781981 */
19791982 stepNr = stream->states[2 * i];
+53-37
sdk/lib/3rdparty/libxml2/relaxng.c
···125125 XML_RELAXNG_EXCEPT, /* except present in nameclass defs */
126126 XML_RELAXNG_TEXT, /* textual content */
127127 XML_RELAXNG_ELEMENT, /* an element */
128128- XML_RELAXNG_DATATYPE, /* extenal data type definition */
129129- XML_RELAXNG_PARAM, /* extenal data type parameter */
130130- XML_RELAXNG_VALUE, /* value from an extenal data type definition */
128128+ XML_RELAXNG_DATATYPE, /* external data type definition */
129129+ XML_RELAXNG_PARAM, /* external data type parameter */
130130+ XML_RELAXNG_VALUE, /* value from an external data type definition */
131131 XML_RELAXNG_LIST, /* a list of patterns */
132132- XML_RELAXNG_ATTRIBUTE, /* an attrbute following a pattern */
132132+ XML_RELAXNG_ATTRIBUTE, /* an attribute following a pattern */
133133 XML_RELAXNG_DEF, /* a definition */
134134 XML_RELAXNG_REF, /* reference to a definition */
135135 XML_RELAXNG_EXTERNALREF, /* reference to an external def */
···228228 xmlDocPtr document;
229229230230 int defNr; /* number of defines used */
231231- int defMax; /* number of defines aloocated */
231231+ int defMax; /* number of defines allocated */
232232 xmlRelaxNGDefinePtr *defTab; /* pointer to the allocated definitions */
233233234234 const char *buffer;
···11281128/**
11291129 * xmlRelaxNGFreeStates:
11301130 * @ctxt: a Relax-NG validation context
11311131- * @states: teh container
11311131+ * @states: the container
11321132 *
11331133 * Free a RelaxNG validation state container
11341134 */
···13401340 *
13411341 * Compare the validation states for equality
13421342 *
13431343- * Returns 1 if equald, 0 otherwise
13431343+ * Returns 1 if equal, 0 otherwise
13441344 */
13451345static int
13461346xmlRelaxNGEqualValidState(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
···28152815/**
28162816 * xmlRelaxNGInitTypes:
28172817 *
28182818- * Initilize the default type libraries.
28182818+ * Initialize the default type libraries.
28192819 *
28202820 * Returns 0 in case of success and -1 in case of error.
28212821 */
···28782878 xmlRelaxNGDefinePtr def);
2879287928802880/**
28812881- * xmlRelaxNGIsCompileable:
28812881+ * xmlRelaxNGIsCompilable:
28822882 * @define: the definition to check
28832883 *
28842884 * Check if a definition is nullable.
···28862886 * Returns 1 if yes, 0 if no and -1 in case of error
28872887 */
28882888static int
28892889-xmlRelaxNGIsCompileable(xmlRelaxNGDefinePtr def)
28892889+xmlRelaxNGIsCompilable(xmlRelaxNGDefinePtr def)
28902890{
28912891 int ret = -1;
28922892···29012901 return (0);
29022902 switch (def->type) {
29032903 case XML_RELAXNG_NOOP:
29042904- ret = xmlRelaxNGIsCompileable(def->content);
29042904+ ret = xmlRelaxNGIsCompilable(def->content);
29052905 break;
29062906 case XML_RELAXNG_TEXT:
29072907 case XML_RELAXNG_EMPTY:
···29092909 break;
29102910 case XML_RELAXNG_ELEMENT:
29112911 /*
29122912- * Check if the element content is compileable
29122912+ * Check if the element content is compilable
29132913 */
29142914 if (((def->dflags & IS_NOT_COMPILABLE) == 0) &&
29152915 ((def->dflags & IS_COMPILABLE) == 0)) {
···2917291729182918 list = def->content;
29192919 while (list != NULL) {
29202920- ret = xmlRelaxNGIsCompileable(list);
29202920+ ret = xmlRelaxNGIsCompilable(list);
29212921 if (ret != 1)
29222922 break;
29232923 list = list->next;
···29432943 def->name);
29442944 } else {
29452945 xmlGenericError(xmlGenericErrorContext,
29462946- "Problem in RelaxNGIsCompileable for element %s\n",
29462946+ "Problem in RelaxNGIsCompilable for element %s\n",
29472947 def->name);
29482948 }
29492949#endif
29502950 }
29512951 /*
29522952- * All elements return a compileable status unless they
29522952+ * All elements return a compilable status unless they
29532953 * are generic like anyName
29542954 */
29552955 if ((def->nameClass != NULL) || (def->name == NULL))
···29682968 def->depth = -20;
29692969 list = def->content;
29702970 while (list != NULL) {
29712971- ret = xmlRelaxNGIsCompileable(list);
29712971+ ret = xmlRelaxNGIsCompilable(list);
29722972 if (ret != 1)
29732973 break;
29742974 list = list->next;
···2986298629872987 list = def->content;
29882988 while (list != NULL) {
29892989- ret = xmlRelaxNGIsCompileable(list);
29892989+ ret = xmlRelaxNGIsCompilable(list);
29902990 if (ret != 1)
29912991 break;
29922992 list = list->next;
···30113011#ifdef DEBUG_COMPILE
30123012 if (ret == 1) {
30133013 xmlGenericError(xmlGenericErrorContext,
30143014- "RelaxNGIsCompileable %s : true\n",
30143014+ "RelaxNGIsCompilable %s : true\n",
30153015 xmlRelaxNGDefName(def));
30163016 } else if (ret == 0) {
30173017 xmlGenericError(xmlGenericErrorContext,
30183018- "RelaxNGIsCompileable %s : false\n",
30183018+ "RelaxNGIsCompilable %s : false\n",
30193019 xmlRelaxNGDefName(def));
30203020 } else {
30213021 xmlGenericError(xmlGenericErrorContext,
30223022- "Problem in RelaxNGIsCompileable %s\n",
30223022+ "Problem in RelaxNGIsCompilable %s\n",
30233023 xmlRelaxNGDefName(def));
30243024 }
30253025#endif
···3047304730483048 switch (def->type) {
30493049 case XML_RELAXNG_START:
30503050- if ((xmlRelaxNGIsCompileable(def) == 1) && (def->depth != -25)) {
30503050+ if ((xmlRelaxNGIsCompilable(def) == 1) && (def->depth != -25)) {
30513051 xmlAutomataPtr oldam = ctxt->am;
30523052 xmlAutomataStatePtr oldstate = ctxt->state;
30533053···3273327332743274 if ((def->type == XML_RELAXNG_START) ||
32753275 (def->type == XML_RELAXNG_ELEMENT)) {
32763276- ret = xmlRelaxNGIsCompileable(def);
32763276+ ret = xmlRelaxNGIsCompilable(def);
32773277 if ((def->dflags & IS_COMPILABLE) && (def->depth != -25)) {
32783278 ctxt->am = NULL;
32793279 ret = xmlRelaxNGCompile(ctxt, def);
···34783478 *
34793479 * Applies algorithm from 4.3. datatypeLibrary attribute
34803480 *
34813481- * Returns the datatypeLibary value or NULL if not found
34813481+ * Returns the datatypeLibrary value or NULL if not found
34823482 */
34833483static xmlChar *
34843484xmlRelaxNGGetDataTypeLibrary(xmlRelaxNGParserCtxtPtr ctxt ATTRIBUTE_UNUSED,
···37883788 * that if both lists do not accept the same QNames, it returns 1
37893789 * If the 2 lists can accept the same QName the comparison returns 0
37903790 *
37913791- * Returns 1 disttinct, 0 if equal
37913791+ * Returns 1 distinct, 0 if equal
37923792 */
37933793static int
37943794xmlRelaxNGCompareNameClasses(xmlRelaxNGDefinePtr def1,
···38893889 * is that if both lists do not accept the same QNames, it returns 1
38903890 * If the 2 lists can accept the same QName the comparison returns 0
38913891 *
38923892- * Returns 1 disttinct, 0 if equal
38923892+ * Returns 1 distinct, 0 if equal
38933893 */
38943894static int
38953895xmlRelaxNGCompareElemDefLists(xmlRelaxNGParserCtxtPtr ctxt
···47434743/**
47444744 * xmlRelaxNGProcessExternalRef:
47454745 * @ctxt: the parser context
47464746- * @node: the externlRef node
47464746+ * @node: the externalRef node
47474747 *
47484748- * Process and compile an externlRef node
47484748+ * Process and compile an externalRef node
47494749 *
47504750 * Returns the xmlRelaxNGDefinePtr or NULL in case of error
47514751 */
···55485548 while (nodes != NULL) {
55495549 if (IS_RELAXNG(nodes, "element")) {
55505550 cur = xmlRelaxNGParseElement(ctxt, nodes);
55515551+ if (cur == NULL)
55525552+ return (NULL);
55515553 if (def == NULL) {
55525554 def = last = cur;
55535555 } else {
55545556 if ((group == 1) && (def->type == XML_RELAXNG_ELEMENT) &&
55555557 (def == last)) {
55565558 def = xmlRelaxNGNewDefine(ctxt, nodes);
55595559+ if (def == NULL)
55605560+ return (NULL);
55575561 def->type = XML_RELAXNG_GROUP;
55585562 def->content = last;
55595563 }
···60126016 * @parent: the parent definition
60136017 * @prev: the previous sibling definition
60146018 *
60156015- * Try to unlink a definition. If not possble make it a NOOP
60196019+ * Try to unlink a definition. If not possible make it a NOOP
60166020 *
60176021 * Returns the new prev definition
60186022 */
···63956399 NULL, NULL);
63966400 }
63976401 if ((!(flags & XML_RELAXNG_IN_ONEORMORE))
63986398- && (cur->name == NULL)) {
64026402+ && cur->name == NULL
64036403+ /* following is checking alternative name class readiness
64046404+ in case it went the "choice" route */
64056405+ && cur->nameClass == NULL) {
63996406 if (cur->ns == NULL) {
64006407 xmlRngPErr(ctxt, cur->node, XML_RNGP_ANYNAME_ATTR_ANCESTOR,
64016408 "Found anyName attribute without oneOrMore ancestor\n",
···66596666 * @node: the root node of the RelaxNG schema
66606667 *
66616668 * parse a Relax-NG definition resource and build an internal
66626662- * xmlRelaxNG struture which can be used to validate instances.
66696669+ * xmlRelaxNG structure which can be used to validate instances.
66636670 *
66646671 * Returns the internal XML RelaxNG structure built or
66656672 * NULL in case of error
···74907497 * @ctxt: a Relax-NG parser context
74917498 *
74927499 * parse a schema definition resource and build an internal
74937493- * XML Shema struture which can be used to validate instances.
75007500+ * XML Schema structure which can be used to validate instances.
74947501 *
74957502 * Returns the internal XML RelaxNG structure built from the resource or
74967503 * NULL in case of error
···86038610 * @type: the datatype definition
86048611 * @node: the node
86058612 *
86068606- * Validate the given value against the dataype
86138613+ * Validate the given value against the datatype
86078614 *
86088615 * Returns 0 if the validation succeeded or an error code.
86098616 */
···94769483 xmlRelaxNGFreeValidState(ctxt, oldstate);
94779484 oldstate = ctxt->state;
94789485 ctxt->state = NULL;
94799479- if (cur != NULL) {
94869486+ if (cur != NULL
94879487+ /* there's a nasty violation of context-free unambiguities,
94889488+ since in open-name-class context, interleave in the
94899489+ production shall finish without caring about anything
94909490+ else that is OK to follow in that case -- it would
94919491+ otherwise get marked as "extra content" and would
94929492+ hence fail the validation, hence this perhaps
94939493+ dirty attempt to rectify such a situation */
94949494+ && (define->parent->type != XML_RELAXNG_DEF
94959495+ || !xmlStrEqual(define->parent->name,
94969496+ (const xmlChar *) "open-name-class"))) {
94809497 VALID_ERR2(XML_RELAXNG_ERR_INTEREXTRA, cur->name);
94819498 ret = -1;
94829499 ctxt->state = oldstate;
···97499766 * Find the "best" state in the ctxt->states list of states to report
97509767 * errors about. I.e. a state with no element left in the child list
97519768 * or the one with the less attributes left.
97529752- * This is called only if a falidation error was detected
97699769+ * This is called only if a validation error was detected
97539770 *
97549771 * Returns the index of the "best" state or -1 in case of error
97559772 */
···98919908 ctxt->depth++;
98929909 switch (define->type) {
98939910 case XML_RELAXNG_EMPTY:
98949894- xmlRelaxNGSkipIgnored(ctxt, node);
98959911 ret = 0;
98969912 break;
98979913 case XML_RELAXNG_NOT_ALLOWED:
···10357103731035810374 /*
1035910375 * Something we can optimize cleanly there is only one
1036010360- * possble branch out !
1037610376+ * possible branch out !
1036110377 */
1036210378 if ((node->type == XML_TEXT_NODE) ||
1036310379 (node->type == XML_CDATA_SECTION_NODE)) {
···1061010626 if (define->name != NULL)
1061110627 xmlGenericError(xmlGenericErrorContext, "%s ", define->name);
1061210628 if (ret == 0)
1061310613- xmlGenericError(xmlGenericErrorContext, "suceeded\n");
1062910629+ xmlGenericError(xmlGenericErrorContext, "succeeded\n");
1061410630 else
1061510631 xmlGenericError(xmlGenericErrorContext, "failed\n");
1061610632#endif
+3-2
sdk/lib/3rdparty/libxml2/save.h
···11/*
22 * Summary: Internal Interfaces for saving in libxml2
33 * Description: this module describes a few interfaces which were
44- * addded along with the API changes in 2.9.0
44+ * added along with the API changes in 2.9.0
55 * those are private routines at this point
66 *
77 * Copy: See Copyright for the status of this software.
···2525void xmlBufDumpElementDecl(xmlBufPtr buf, xmlElementPtr elem);
2626void xmlBufDumpAttributeDecl(xmlBufPtr buf, xmlAttributePtr attr);
2727void xmlBufDumpEntityDecl(xmlBufPtr buf, xmlEntityPtr ent);
2828+#endif
2929+2830xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input);
2929-#endif
30313132#ifdef __cplusplus
3233}
+4-4
sdk/lib/3rdparty/libxml2/schematron.c
···10681068 * @ctxt: a schema validation context
10691069 *
10701070 * parse a schema definition resource and build an internal
10711071- * XML Shema struture which can be used to validate instances.
10711071+ * XML Schema structure which can be used to validate instances.
10721072 *
10731073 * Returns the internal XML Schematron structure built from the resource or
10741074 * NULL in case of error
···12871287 * Build the string being reported to the user.
12881288 *
12891289 * Returns a report string or NULL in case of error. The string needs
12901290- * to be deallocated by teh caller
12901290+ * to be deallocated by the caller
12911291 */
12921292static xmlChar *
12931293xmlSchematronFormatReport(xmlSchematronValidCtxtPtr ctxt,
···15911591 * xmlSchematronRunTest:
15921592 * @ctxt: the schema validation context
15931593 * @test: the current test
15941594- * @instance: the document instace tree
15941594+ * @instance: the document instance tree
15951595 * @cur: the current node in the instance
15961596 *
15971597 * Validate a rule against a tree instance at a given position
···16551655/**
16561656 * xmlSchematronValidateDoc:
16571657 * @ctxt: the schema validation context
16581658- * @instance: the document instace tree
16581658+ * @instance: the document instance tree
16591659 *
16601660 * Validate a tree instance against the schematron
16611661 *
+4-4
sdk/lib/3rdparty/libxml2/threads.c
···2727#ifdef HAVE_PTHREAD_H
2828#include <pthread.h>
2929#elif defined HAVE_WIN32_THREADS
3030-//#define WIN32_LEAN_AND_MEAN
3131-//#include <windows.h>
3030+#define WIN32_LEAN_AND_MEAN
3131+#include <windows.h>
3232#ifndef HAVE_COMPILER_TLS
3333#include <process.h>
3434#endif
···82828383/*
8484 * TODO: this module still uses malloc/free and not xmlMalloc/xmlFree
8585- * to avoid some crazyness since xmlMalloc/xmlFree may actually
8585+ * to avoid some craziness since xmlMalloc/xmlFree may actually
8686 * be hosted on allocated blocks needing them for the allocation ...
8787 */
8888···239239 if (acquire_sem(tok->sem) != B_NO_ERROR) {
240240#ifdef DEBUG_THREADS
241241 xmlGenericError(xmlGenericErrorContext,
242242- "xmlMutexLock():BeOS:Couldn't aquire semaphore\n");
242242+ "xmlMutexLock():BeOS:Couldn't acquire semaphore\n");
243243#endif
244244 }
245245 tok->tid = find_thread(NULL);
+4-3
sdk/lib/3rdparty/libxml2/timsort.h
···5959#define SORT_SWAP(x,y) {SORT_TYPE __SORT_SWAP_t = (x); (x) = (y); (y) = __SORT_SWAP_t;}
606061616262-/* Common, type-agnosting functions and constants that we don't want to declare twice. */
6262+/* Common, type-agnostic functions and constants that we don't want to declare twice. */
6363#ifndef SORT_COMMON_H
6464#define SORT_COMMON_H
6565···7474static int compute_minrun(const uint64_t);
75757676#ifndef CLZ
7777-#ifdef __GNUC__
7777+#if defined(__GNUC__) && ((__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ > 3))
7878#define CLZ __builtin_clzll
7979#else
8080···404404 j = curr + A;
405405 k = curr + A + B;
406406407407- while (k-- > curr) {
407407+ while (k > curr) {
408408+ k--;
408409 if ((i > 0) && (j > curr)) {
409410 if (SORT_CMP(dst[j - 1], storage[i - 1]) > 0) {
410411 dst[k] = dst[--j];
+53-37
sdk/lib/3rdparty/libxml2/tree.c
···5959 ************************************************************************/
60606161static xmlNsPtr
6262-xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
6262+xmlNewReconciledNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns);
63636464static xmlChar* xmlGetPropNodeValueInternal(const xmlAttr *prop);
6565···181181 * @dtd: A pointer to the DTD to search
182182 * @name: The entity name
183183 *
184184- * Do an entity lookup in the DTD pararmeter entity hash table and
184184+ * Do an entity lookup in the DTD parameter entity hash table and
185185 * return the corresponding entity, if found.
186186 *
187187 * Returns A pointer to the entity structure or NULL if not found.
···29502950 * Add a new attribute after @prev using @cur as base attribute.
29512951 * When inserting before @cur, @prev is passed as @cur->prev.
29522952 * When inserting after @cur, @prev is passed as @cur.
29532953- * If an existing attribute is found it is detroyed prior to adding @prop.
29532953+ * If an existing attribute is found it is destroyed prior to adding @prop.
29542954 *
29552955 * Returns the attribute being inserted or NULL in case of error.
29562956 */
···36643664void
36653665xmlFreeNodeList(xmlNodePtr cur) {
36663666 xmlNodePtr next;
36673667+ xmlNodePtr parent;
36673668 xmlDictPtr dict = NULL;
36693669+ size_t depth = 0;
3668367036693671 if (cur == NULL) return;
36703672 if (cur->type == XML_NAMESPACE_DECL) {
···36803682 return;
36813683 }
36823684 if (cur->doc != NULL) dict = cur->doc->dict;
36833683- while (cur != NULL) {
36853685+ while (1) {
36863686+ while ((cur->children != NULL) &&
36873687+ (cur->type != XML_DTD_NODE) &&
36883688+ (cur->type != XML_ENTITY_REF_NODE)) {
36893689+ cur = cur->children;
36903690+ depth += 1;
36913691+ }
36923692+36843693 next = cur->next;
36943694+ parent = cur->parent;
36853695 if (cur->type != XML_DTD_NODE) {
3686369636873697 if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
36883698 xmlDeregisterNodeDefaultValue(cur);
3689369936903690- if ((cur->children != NULL) &&
36913691- (cur->type != XML_ENTITY_REF_NODE))
36923692- xmlFreeNodeList(cur->children);
36933700 if (((cur->type == XML_ELEMENT_NODE) ||
36943701 (cur->type == XML_XINCLUDE_START) ||
36953702 (cur->type == XML_XINCLUDE_END)) &&
···37203727 DICT_FREE(cur->name)
37213728 xmlFree(cur);
37223729 }
37233723- cur = next;
37303730+37313731+ if (next != NULL) {
37323732+ cur = next;
37333733+ } else {
37343734+ if ((depth == 0) || (parent == NULL))
37353735+ break;
37363736+ depth -= 1;
37373737+ cur = parent;
37383738+ cur->children = NULL;
37393739+ }
37243740 }
37253741}
37263742···40504066 } else {
40514067 /*
40524068 * we have to find something appropriate here since
40534053- * we cant be sure, that the namespce we found is identified
40694069+ * we cant be sure, that the namespace we found is identified
40544070 * by the prefix
40554071 */
40564072 if (xmlStrEqual(ns->href, cur->ns->href)) {
···40584074 ret->ns = ns;
40594075 } else {
40604076 /*
40614061- * we are in trouble: we need a new reconcilied namespace.
40774077+ * we are in trouble: we need a new reconciled namespace.
40624078 * This is expensive
40634079 */
40644064- ret->ns = xmlNewReconciliedNs(target->doc, target, cur->ns);
40804080+ ret->ns = xmlNewReconciledNs(target->doc, target, cur->ns);
40654081 }
40664082 }
40674083···41544170 * say RPM:Copyright without changing the namespace pointer to
41554171 * something else can produce stale links. One way to do it is
41564172 * to keep a reference counter but this doesn't work as soon
41574157- * as one move the element or the subtree out of the scope of
41584158- * the existing namespace. The actual solution seems to add
41734173+ * as one moves the element or the subtree out of the scope of
41744174+ * the existing namespace. The actual solution seems to be to add
41594175 * a copy of the namespace at the top of the copied tree if
41604176 * not available in the subtree.
41614177 * Hence two functions, the public front-end call the inner ones
···42804296 while (root->parent != NULL) root = root->parent;
42814297 ret->ns = xmlNewNs(root, ns->href, ns->prefix);
42824298 } else {
42834283- ret->ns = xmlNewReconciliedNs(doc, ret, node->ns);
42994299+ ret->ns = xmlNewReconciledNs(doc, ret, node->ns);
42844300 }
42854301 } else {
42864302 /*
···4719473547204736 /*
47214737 * Thumbler index computation
47224722- * TODO: the ocurence test seems bogus for namespaced names
47384738+ * TODO: the occurrence test seems bogus for namespaced names
47234739 */
47244740 tmp = cur->prev;
47254741 while (tmp != NULL) {
···62146230}
6215623162166232/**
62176217- * xmlNewReconciliedNs:
62336233+ * xmlNewReconciledNs:
62186234 * @doc: the document
62196235 * @tree: a node expected to hold the new namespace
62206236 * @ns: the original namespace
···62276243 * Returns the (new) namespace definition or NULL in case of error
62286244 */
62296245static xmlNsPtr
62306230-xmlNewReconciliedNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
62466246+xmlNewReconciledNs(xmlDocPtr doc, xmlNodePtr tree, xmlNsPtr ns) {
62316247 xmlNsPtr def;
62326248 xmlChar prefix[50];
62336249 int counter = 1;
···62356251 if ((tree == NULL) || (tree->type != XML_ELEMENT_NODE)) {
62366252#ifdef DEBUG_TREE
62376253 xmlGenericError(xmlGenericErrorContext,
62386238- "xmlNewReconciliedNs : tree == NULL\n");
62546254+ "xmlNewReconciledNs : tree == NULL\n");
62396255#endif
62406256 return(NULL);
62416257 }
62426258 if ((ns == NULL) || (ns->type != XML_NAMESPACE_DECL)) {
62436259#ifdef DEBUG_TREE
62446260 xmlGenericError(xmlGenericErrorContext,
62456245- "xmlNewReconciliedNs : ns == NULL\n");
62616261+ "xmlNewReconciledNs : ns == NULL\n");
62466262#endif
62476263 return(NULL);
62486264 }
···63446360 /*
63456361 * OK we need to recreate a new namespace definition
63466362 */
63476347- n = xmlNewReconciliedNs(doc, tree, node->ns);
63636363+ n = xmlNewReconciledNs(doc, tree, node->ns);
63486364 if (n != NULL) { /* :-( what if else ??? */
63496365 /*
63506366 * check if we need to grow the cache buffers.
···63736389 }
63746390 }
63756391 /*
63766376- * now check for namespace hold by attributes on the node.
63926392+ * now check for namespace held by attributes on the node.
63776393 */
63786394 if (node->type == XML_ELEMENT_NODE) {
63796395 attr = node->properties;
···64086424 /*
64096425 * OK we need to recreate a new namespace definition
64106426 */
64116411- n = xmlNewReconciliedNs(doc, tree, attr->ns);
64276427+ n = xmlNewReconciledNs(doc, tree, attr->ns);
64126428 if (n != NULL) { /* :-( what if else ??? */
64136429 /*
64146430 * check if we need to grow the cache buffers.
···79617977* Creates or reuses an xmlNs struct on doc->oldNs with
79627978* the given prefix and namespace name.
79637979*
79647964-* Returns the aquired ns struct or NULL in case of an API
79807980+* Returns the acquired ns struct or NULL in case of an API
79657981* or internal error.
79667982*/
79677983static xmlNsPtr
···85758591}
8576859285778593/*
85788578-* xmlDOMWrapNSNormAquireNormalizedNs:
85948594+* xmlDOMWrapNSNormAcquireNormalizedNs:
85798595* @doc: the doc
85808596* @elem: the element-node to declare namespaces on
85818597* @ns: the ns-struct to use for the search
···85948610* Returns 0 if succeeded, -1 otherwise and on API/internal errors.
85958611*/
85968612static int
85978597-xmlDOMWrapNSNormAquireNormalizedNs(xmlDocPtr doc,
86138613+xmlDOMWrapNSNormAcquireNormalizedNs(xmlDocPtr doc,
85988614 xmlNodePtr elem,
85998615 xmlNsPtr ns,
86008616 xmlNsPtr *retNs,
···88938909 }
88948910 }
88958911 /*
88968896- * Aquire a normalized ns-decl and add it to the map.
89128912+ * Acquire a normalized ns-decl and add it to the map.
88978913 */
88988898- if (xmlDOMWrapNSNormAquireNormalizedNs(doc, curElem,
89148914+ if (xmlDOMWrapNSNormAcquireNormalizedNs(doc, curElem,
88998915 cur->ns, &ns,
89008916 &nsMap, depth,
89018917 ancestorsOnly,
···90339049 nsMap = (xmlNsMapPtr) ctxt->namespaceMap;
90349050 /*
90359051 * Disable search for ns-decls in the parent-axis of the
90369036- * desination element, if:
90529052+ * destination element, if:
90379053 * 1) there's no destination parent
90389054 * 2) custom ns-reference handling is used
90399055 */
···91789194 cur->ns = ns;
91799195 } else {
91809196 /*
91819181- * Aquire a normalized ns-decl and add it to the map.
91979197+ * Acquire a normalized ns-decl and add it to the map.
91829198 */
91839183- if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
91999199+ if (xmlDOMWrapNSNormAcquireNormalizedNs(destDoc,
91849200 /* ns-decls on curElem or on destDoc->oldNs */
91859201 destParent ? curElem : NULL,
91869202 cur->ns, &ns,
···92349250 goto leave_node;
92359251 case XML_ENTITY_REF_NODE:
92369252 /*
92379237- * Remove reference to the entitity-node.
92539253+ * Remove reference to the entity-node.
92389254 */
92399255 cur->content = NULL;
92409256 cur->children = NULL;
···94689484 }
94699485 memset(clone, 0, sizeof(xmlNode));
94709486 /*
94719471- * Set hierachical links.
94879487+ * Set hierarchical links.
94729488 */
94739489 if (resultClone != NULL) {
94749490 clone->parent = parentClone;
···94929508 }
94939509 memset(clone, 0, sizeof(xmlAttr));
94949510 /*
94959495- * Set hierachical links.
95119511+ * Set hierarchical links.
94969512 * TODO: Change this to add to the end of attributes.
94979513 */
94989514 if (resultClone != NULL) {
···97209736 clone->ns = ns;
97219737 } else {
97229738 /*
97239723- * Aquire a normalized ns-decl and add it to the map.
97399739+ * Acquire a normalized ns-decl and add it to the map.
97249740 */
97259725- if (xmlDOMWrapNSNormAquireNormalizedNs(destDoc,
97419741+ if (xmlDOMWrapNSNormAcquireNormalizedNs(destDoc,
97269742 /* ns-decls on curElem or on destDoc->oldNs */
97279743 destParent ? curElem : NULL,
97289744 cur->ns, &ns,
···99599975 break;
99609976 case XML_ENTITY_REF_NODE:
99619977 /*
99629962- * Remove reference to the entitity-node.
99789978+ * Remove reference to the entity-node.
99639979 */
99649980 cur->content = NULL;
99659981 cur->children = NULL;
···1009710113 break;
1009810114 case XML_ENTITY_REF_NODE:
1009910115 /*
1010010100- * Remove reference to the entitity-node.
1011610116+ * Remove reference to the entity-node.
1010110117 */
1010210118 node->content = NULL;
1010310119 node->children = NULL;
+2-2
sdk/lib/3rdparty/libxml2/trio.c
···26102610 *
26112611 * The accuracy [...] is implementation defined, as is the accuracy
26122612 * of the conversion between floating-point internal representations
26132613- * and string representations performed by the libray routine in
26132613+ * and string representations performed by the library routine in
26142614 * <stdio.h>"
26152615 */
26162616/* FIXME: handle all instances of constant long-double number (L)
···58995899 }
59005900 if (trio_equal(doubleString, NAN_UPPER))
59015901 {
59025902- /* NaN must not have a preceeding + nor - */
59025902+ /* NaN must not have a preceding + nor - */
59035903 if (flags & FLAGS_LONGDOUBLE)
59045904 {
59055905 *((trio_long_double_t *)target) = trio_nan();
+2-2
sdk/lib/3rdparty/libxml2/trionan.c
···92929393/*
9494 * In ANSI/IEEE 754-1985 64-bits double format numbers have the
9595- * following properties (amoungst others)
9595+ * following properties (amongst others)
9696 *
9797 * o FLT_RADIX == 2: binary encoding
9898 * o DBL_MAX_EXP == 1024: 11 bits exponent, where one bit is used
···327327328328 if (result == 0.0) {
329329330330-#if defined(TRIO_COMPILER_SUPPORTS_C99) && !defined(__clang__)
330330+#if defined(TRIO_COMPILER_SUPPORTS_C99) && (!defined(__REACTOS__) || !defined(__clang__))
331331 result = nan("");
332332333333#elif defined(NAN) && defined(__STDC_IEC_559__)
+11-9
sdk/lib/3rdparty/libxml2/uri.c
···2222 * MAX_URI_LENGTH:
2323 *
2424 * The definition of the URI regexp in the above RFC has no size limit
2525- * In practice they are usually relativey short except for the
2525+ * In practice they are usually relatively short except for the
2626 * data URI scheme as defined in RFC 2397. Even for data URI the usual
2727 * maximum size before hitting random practical limits is around 64 KB
2828 * and 4KB is usually a maximum admitted limit for proper operations.
···325325xmlParse3986Port(xmlURIPtr uri, const char **str)
326326{
327327 const char *cur = *str;
328328- unsigned port = 0; /* unsigned for defined overflow behavior */
328328+ int port = 0;
329329330330 if (ISA_DIGIT(cur)) {
331331 while (ISA_DIGIT(cur)) {
332332 port = port * 10 + (*cur - '0');
333333+ if (port > 99999999)
334334+ port = 99999999;
333335334336 cur++;
335337 }
336338 if (uri != NULL)
337337- uri->port = port & INT_MAX; /* port value modulo INT_MAX+1 */
339339+ uri->port = port;
338340 *str = cur;
339341 return(0);
340342 }
···436438437439 host = cur;
438440 /*
439439- * IPv6 and future adressing scheme are enclosed between brackets
441441+ * IPv6 and future addressing scheme are enclosed between brackets
440442 */
441443 if (*cur == '[') {
442444 cur++;
···14561458 goto done_cd;
14571459 (out++)[0] = (cur++)[0];
14581460 }
14591459- /* nomalize // */
14611461+ /* normalize // */
14601462 while ((cur[0] == '/') && (cur[1] == '/'))
14611463 cur++;
14621464···21502152 * http://site1.com/docs/pic1.gif http://site1.com/docs/pic1.gif
21512153 *
21522154 *
21532153- * Note: if the URI reference is really wierd or complicated, it may be
21552155+ * Note: if the URI reference is really weird or complicated, it may be
21542156 * worthwhile to first convert it into a "nice" one by calling
21552157 * xmlBuildURI (using 'base') before calling this routine,
21562158 * since this routine (for reasonable efficiency) assumes URI has
···24612463 /* allocate space for leading '/' + path + string terminator */
24622464 uri->path = xmlMallocAtomic(len + 2);
24632465 if (uri->path == NULL) {
24642464- xmlFreeURI(uri); /* Guard agains 'out of memory' */
24662466+ xmlFreeURI(uri); /* Guard against 'out of memory' */
24652467 return(NULL);
24662468 }
24672469 /* Put in leading '/' plus path */
···24762478 }
24772479 p = uri->path;
24782480 }
24792479- /* Now change all occurences of '\' to '/' */
24812481+ /* Now change all occurrences of '\' to '/' */
24802482 while (*p != '\0') {
24812483 if (*p == '\\')
24822484 *p = '/';
···25262528 return(NULL);
25272529#if defined(_WIN32) && !defined(__CYGWIN__)
25282530 /* xmlCanonicPath can return an URI on Windows (is that the intended behaviour?)
25292529- If 'cal' is a valid URI allready then we are done here, as continuing would make
25312531+ If 'cal' is a valid URI already then we are done here, as continuing would make
25302532 it invalid. */
25312533 if ((uri = xmlParseURI((const char *) cal)) != NULL) {
25322534 xmlFreeURI(uri);
+118-75
sdk/lib/3rdparty/libxml2/valid.c
···10991099 */
11001100void
11011101xmlFreeDocElementContent(xmlDocPtr doc, xmlElementContentPtr cur) {
11021102- xmlElementContentPtr next;
11031102 xmlDictPtr dict = NULL;
11031103+ size_t depth = 0;
1104110411051105+ if (cur == NULL)
11061106+ return;
11051107 if (doc != NULL)
11061108 dict = doc->dict;
1107110911081108- while (cur != NULL) {
11091109- next = cur->c2;
11101110+ while (1) {
11111111+ xmlElementContentPtr parent;
11121112+11131113+ while ((cur->c1 != NULL) || (cur->c2 != NULL)) {
11141114+ cur = (cur->c1 != NULL) ? cur->c1 : cur->c2;
11151115+ depth += 1;
11161116+ }
11171117+11101118 switch (cur->type) {
11111119 case XML_ELEMENT_CONTENT_PCDATA:
11121120 case XML_ELEMENT_CONTENT_ELEMENT:
···11191127 NULL);
11201128 return;
11211129 }
11221122- if (cur->c1 != NULL) xmlFreeDocElementContent(doc, cur->c1);
11231130 if (dict) {
11241131 if ((cur->name != NULL) && (!xmlDictOwns(dict, cur->name)))
11251132 xmlFree((xmlChar *) cur->name);
···11291136 if (cur->name != NULL) xmlFree((xmlChar *) cur->name);
11301137 if (cur->prefix != NULL) xmlFree((xmlChar *) cur->prefix);
11311138 }
11391139+ parent = cur->parent;
11401140+ if ((depth == 0) || (parent == NULL)) {
11411141+ xmlFree(cur);
11421142+ break;
11431143+ }
11441144+ if (cur == parent->c1)
11451145+ parent->c1 = NULL;
11461146+ else
11471147+ parent->c2 = NULL;
11321148 xmlFree(cur);
11331133- cur = next;
11491149+11501150+ if (parent->c2 != NULL) {
11511151+ cur = parent->c2;
11521152+ } else {
11531153+ depth -= 1;
11541154+ cur = parent;
11551155+ }
11341156 }
11351157}
11361158···1148117011491171#ifdef LIBXML_OUTPUT_ENABLED
11501172/**
11731173+ * xmlDumpElementOccur:
11741174+ * @buf: An XML buffer
11751175+ * @cur: An element table
11761176+ *
11771177+ * Dump the occurence operator of an element.
11781178+ */
11791179+static void
11801180+xmlDumpElementOccur(xmlBufferPtr buf, xmlElementContentPtr cur) {
11811181+ switch (cur->ocur) {
11821182+ case XML_ELEMENT_CONTENT_ONCE:
11831183+ break;
11841184+ case XML_ELEMENT_CONTENT_OPT:
11851185+ xmlBufferWriteChar(buf, "?");
11861186+ break;
11871187+ case XML_ELEMENT_CONTENT_MULT:
11881188+ xmlBufferWriteChar(buf, "*");
11891189+ break;
11901190+ case XML_ELEMENT_CONTENT_PLUS:
11911191+ xmlBufferWriteChar(buf, "+");
11921192+ break;
11931193+ }
11941194+}
11951195+11961196+/**
11511197 * xmlDumpElementContent:
11521198 * @buf: An XML buffer
11531199 * @content: An element table
11541154- * @glob: 1 if one must print the englobing parenthesis, 0 otherwise
11551200 *
11561201 * This will dump the content of the element table as an XML DTD definition
11571202 */
11581203static void
11591159-xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content, int glob) {
12041204+xmlDumpElementContent(xmlBufferPtr buf, xmlElementContentPtr content) {
12051205+ xmlElementContentPtr cur;
12061206+11601207 if (content == NULL) return;
1161120811621162- if (glob) xmlBufferWriteChar(buf, "(");
11631163- switch (content->type) {
11641164- case XML_ELEMENT_CONTENT_PCDATA:
11651165- xmlBufferWriteChar(buf, "#PCDATA");
11661166- break;
11671167- case XML_ELEMENT_CONTENT_ELEMENT:
11681168- if (content->prefix != NULL) {
11691169- xmlBufferWriteCHAR(buf, content->prefix);
11701170- xmlBufferWriteChar(buf, ":");
11711171- }
11721172- xmlBufferWriteCHAR(buf, content->name);
11731173- break;
11741174- case XML_ELEMENT_CONTENT_SEQ:
11751175- if ((content->c1 != NULL) &&
11761176- ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
11771177- (content->c1->type == XML_ELEMENT_CONTENT_SEQ)))
11781178- xmlDumpElementContent(buf, content->c1, 1);
11791179- else
11801180- xmlDumpElementContent(buf, content->c1, 0);
11811181- xmlBufferWriteChar(buf, " , ");
11821182- if ((content->c2 != NULL) &&
11831183- ((content->c2->type == XML_ELEMENT_CONTENT_OR) ||
11841184- ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) &&
11851185- (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE))))
11861186- xmlDumpElementContent(buf, content->c2, 1);
11871187- else
11881188- xmlDumpElementContent(buf, content->c2, 0);
11891189- break;
11901190- case XML_ELEMENT_CONTENT_OR:
11911191- if ((content->c1 != NULL) &&
11921192- ((content->c1->type == XML_ELEMENT_CONTENT_OR) ||
11931193- (content->c1->type == XML_ELEMENT_CONTENT_SEQ)))
11941194- xmlDumpElementContent(buf, content->c1, 1);
11951195- else
11961196- xmlDumpElementContent(buf, content->c1, 0);
11971197- xmlBufferWriteChar(buf, " | ");
11981198- if ((content->c2 != NULL) &&
11991199- ((content->c2->type == XML_ELEMENT_CONTENT_SEQ) ||
12001200- ((content->c2->type == XML_ELEMENT_CONTENT_OR) &&
12011201- (content->c2->ocur != XML_ELEMENT_CONTENT_ONCE))))
12021202- xmlDumpElementContent(buf, content->c2, 1);
12031203- else
12041204- xmlDumpElementContent(buf, content->c2, 0);
12051205- break;
12061206- default:
12071207- xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
12081208- "Internal: ELEMENT content corrupted invalid type\n",
12091209- NULL);
12101210- }
12111211- if (glob)
12121212- xmlBufferWriteChar(buf, ")");
12131213- switch (content->ocur) {
12141214- case XML_ELEMENT_CONTENT_ONCE:
12151215- break;
12161216- case XML_ELEMENT_CONTENT_OPT:
12171217- xmlBufferWriteChar(buf, "?");
12181218- break;
12191219- case XML_ELEMENT_CONTENT_MULT:
12201220- xmlBufferWriteChar(buf, "*");
12211221- break;
12221222- case XML_ELEMENT_CONTENT_PLUS:
12231223- xmlBufferWriteChar(buf, "+");
12241224- break;
12251225- }
12091209+ xmlBufferWriteChar(buf, "(");
12101210+ cur = content;
12111211+12121212+ do {
12131213+ if (cur == NULL) return;
12141214+12151215+ switch (cur->type) {
12161216+ case XML_ELEMENT_CONTENT_PCDATA:
12171217+ xmlBufferWriteChar(buf, "#PCDATA");
12181218+ break;
12191219+ case XML_ELEMENT_CONTENT_ELEMENT:
12201220+ if (cur->prefix != NULL) {
12211221+ xmlBufferWriteCHAR(buf, cur->prefix);
12221222+ xmlBufferWriteChar(buf, ":");
12231223+ }
12241224+ xmlBufferWriteCHAR(buf, cur->name);
12251225+ break;
12261226+ case XML_ELEMENT_CONTENT_SEQ:
12271227+ case XML_ELEMENT_CONTENT_OR:
12281228+ if ((cur != content) &&
12291229+ (cur->parent != NULL) &&
12301230+ ((cur->type != cur->parent->type) ||
12311231+ (cur->ocur != XML_ELEMENT_CONTENT_ONCE)))
12321232+ xmlBufferWriteChar(buf, "(");
12331233+ cur = cur->c1;
12341234+ continue;
12351235+ default:
12361236+ xmlErrValid(NULL, XML_ERR_INTERNAL_ERROR,
12371237+ "Internal: ELEMENT cur corrupted invalid type\n",
12381238+ NULL);
12391239+ }
12401240+12411241+ while (cur != content) {
12421242+ xmlElementContentPtr parent = cur->parent;
12431243+12441244+ if (parent == NULL) return;
12451245+12461246+ if (((cur->type == XML_ELEMENT_CONTENT_OR) ||
12471247+ (cur->type == XML_ELEMENT_CONTENT_SEQ)) &&
12481248+ ((cur->type != parent->type) ||
12491249+ (cur->ocur != XML_ELEMENT_CONTENT_ONCE)))
12501250+ xmlBufferWriteChar(buf, ")");
12511251+ xmlDumpElementOccur(buf, cur);
12521252+12531253+ if (cur == parent->c1) {
12541254+ if (parent->type == XML_ELEMENT_CONTENT_SEQ)
12551255+ xmlBufferWriteChar(buf, " , ");
12561256+ else if (parent->type == XML_ELEMENT_CONTENT_OR)
12571257+ xmlBufferWriteChar(buf, " | ");
12581258+12591259+ cur = parent->c2;
12601260+ break;
12611261+ }
12621262+12631263+ cur = parent;
12641264+ }
12651265+ } while (cur != content);
12661266+12671267+ xmlBufferWriteChar(buf, ")");
12681268+ xmlDumpElementOccur(buf, content);
12261269}
1227127012281271/**
···17031746 }
17041747 xmlBufferWriteCHAR(buf, elem->name);
17051748 xmlBufferWriteChar(buf, " ");
17061706- xmlDumpElementContent(buf, elem->content, 1);
17491749+ xmlDumpElementContent(buf, elem->content);
17071750 xmlBufferWriteChar(buf, ">\n");
17081751 break;
17091752 case XML_ELEMENT_TYPE_ELEMENT:
···17141757 }
17151758 xmlBufferWriteCHAR(buf, elem->name);
17161759 xmlBufferWriteChar(buf, " ");
17171717- xmlDumpElementContent(buf, elem->content, 1);
17601760+ xmlDumpElementContent(buf, elem->content);
17181761 xmlBufferWriteChar(buf, ">\n");
17191762 break;
17201763 default:
···26402683 ret->doc = doc;
26412684 if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
26422685 /*
26432643- * Operating in streaming mode, attr is gonna disapear
26862686+ * Operating in streaming mode, attr is gonna disappear
26442687 */
26452688 if (doc->dict != NULL)
26462689 ret->name = xmlDictLookup(doc->dict, attr->name, -1);
···29683011 ret->value = xmlStrdup(value);
29693012 if ((ctxt != NULL) && (ctxt->vstateNr != 0)) {
29703013 /*
29712971- * Operating in streaming mode, attr is gonna disapear
30143014+ * Operating in streaming mode, attr is gonna disappear
29723015 */
29733016 ret->name = xmlStrdup(attr->name);
29743017 ret->attr = NULL;
+18-8
sdk/lib/3rdparty/libxml2/xinclude.c
···449449450450 xmlCtxtUseOptions(pctxt, ctxt->parseFlags | XML_PARSE_DTDLOAD);
451451452452+ /* Don't read from stdin. */
453453+ if ((URL != NULL) && (strcmp(URL, "-") == 0))
454454+ URL = "./-";
455455+452456 inputStream = xmlLoadExternalEntity(URL, NULL, pctxt);
453457 if (inputStream == NULL) {
454458 xmlFreeParserCtxt(pctxt);
···667671 int i;
668672669673 /*
670670- * Avoid recursion in already substitued resources
674674+ * Avoid recursion in already substituted resources
671675 for (i = 0;i < ctxt->urlNr;i++) {
672676 if (xmlStrEqual(doc->URL, ctxt->urlTab[i]))
673677 return;
···752756 * @txt: the new text node
753757 * @url: the associated URL
754758 *
755755- * Add a new txtument to the list
759759+ * Add a new text node to the list
756760 */
757761static void
758762xmlXIncludeAddTxt(xmlXIncludeCtxtPtr ctxt, xmlNodePtr txt, const xmlURL url) {
···12581262 * @doc: the including doc
12591263 * @nr: the entity name
12601264 *
12611261- * Inplements the merge of one entity
12651265+ * Implements the merge of one entity
12621266 */
12631267static void
12641268xmlXIncludeMergeEntity(void *payload, void *vdata,
···13351339 * @doc: the including doc
13361340 * @from: the included doc
13371341 *
13381338- * Inplements the entity merge
13421342+ * Implements the entity merge
13391343 *
13401344 * Returns 0 if merge succeeded, -1 if some processing failed
13411345 */
···18061810 xmlParserInputPtr inputStream;
18071811 int xinclude_multibyte_fallback_used = 0;
1808181218131813+ /* Don't read from stdin. */
18141814+ if (xmlStrcmp(url, BAD_CAST "-") == 0)
18151815+ url = BAD_CAST "./-";
18161816+18091817 /*
18101818 * Check the URL and remove any fragment identifier
18111819 */
···1914192219151923 cur = xmlStringCurrentChar(NULL, &content[i], &l);
19161924 if (!IS_CHAR(cur)) {
19171917- /* Handle splitted multibyte char at buffer boundary */
19251925+ /* Handle split multibyte char at buffer boundary */
19181926 if (((len - i) < 4) && (!xinclude_multibyte_fallback_used)) {
19191927 xinclude_multibyte_fallback_used = 1;
19201928 xmlBufShrink(buf->buffer, i);
···19231931 xmlXIncludeErr(ctxt, ctxt->incTab[nr]->ref,
19241932 XML_XINCLUDE_INVALID_CHAR,
19251933 "%s contains invalid char\n", URL);
19341934+ xmlFreeParserCtxt(pctxt);
19261935 xmlFreeParserInputBuffer(buf);
19271936 xmlFree(URL);
19281937 return(-1);
···19631972xmlXIncludeLoadFallback(xmlXIncludeCtxtPtr ctxt, xmlNodePtr fallback, int nr) {
19641973 xmlXIncludeCtxtPtr newctxt;
19651974 int ret = 0;
19751975+ int oldNbErrors = ctxt->nbErrors;
1966197619671977 if ((fallback == NULL) || (fallback->type == XML_NAMESPACE_DECL) ||
19681978 (ctxt == NULL))
···19791989 newctxt->base = xmlStrdup(ctxt->base); /* Inherit the base from the existing context */
19801990 xmlXIncludeSetFlags(newctxt, ctxt->parseFlags);
19811991 ret = xmlXIncludeDoProcess(newctxt, ctxt->doc, fallback->children);
19821982- if (ctxt->nbErrors > 0)
19921992+ if (ctxt->nbErrors > oldNbErrors)
19831993 ret = -1;
19841994 else if (ret > 0)
19851995 ret = 0; /* xmlXIncludeDoProcess can return +ve number */
···21332143 xmlNodePtr children;
2134214421352145 /*
21362136- * Time to try a fallback if availble
21462146+ * Time to try a fallback if available
21372147 */
21382148#ifdef DEBUG_XINCLUDE
21392149 xmlGenericError(xmlGenericErrorContext, "error looking for fallback\n");
···21782188 * @ctxt: an XInclude context
21792189 * @nr: the node number
21802190 *
21812181- * Inplement the infoset replacement for the given node
21912191+ * Implement the infoset replacement for the given node
21822192 *
21832193 * Returns 0 if substitution succeeded, -1 if some processing failed
21842194 */
+41-18
sdk/lib/3rdparty/libxml2/xmlIO.c
···189189 "already connected", /* EISCONN */
190190 "connection refused", /* ECONNREFUSED */
191191 "unreachable network", /* ENETUNREACH */
192192- "adddress in use", /* EADDRINUSE */
192192+ "address in use", /* EADDRINUSE */
193193 "already in use", /* EALREADY */
194194- "unknown address familly", /* EAFNOSUPPORT */
194194+ "unknown address family", /* EAFNOSUPPORT */
195195};
196196197197#if defined(_WIN32) || defined (__DJGPP__) && !defined (__CYGWIN__)
···23872387 if (encoder != NULL) {
23882388 ret->conv = xmlBufCreateSize(4000);
23892389 if (ret->conv == NULL) {
23902390+ xmlBufFree(ret->buffer);
23902391 xmlFree(ret);
23912392 return(NULL);
23922393 }
···24392440 if (encoder != NULL) {
24402441 ret->conv = xmlBufCreateSize(4000);
24412442 if (ret->conv == NULL) {
24432443+ xmlBufFree(ret->buffer);
24422444 xmlFree(ret);
24432445 return(NULL);
24442446 }
···33393341 int nbchars = 0; /* number of chars to output to I/O */
33403342 int ret; /* return from function call */
33413343 int written = 0; /* number of char written to I/O so far */
33423342- int chunk; /* number of byte curreent processed from buf */
33443344+ int chunk; /* number of byte current processed from buf */
3343334533443346 if ((out == NULL) || (out->error)) return(-1);
33453347 if (len < 0) return(0);
···33763378 out->error = XML_IO_ENCODER;
33773379 return(-1);
33783380 }
33793379- nbchars = xmlBufUse(out->conv);
33813381+ if (out->writecallback)
33823382+ nbchars = xmlBufUse(out->conv);
33833383+ else
33843384+ nbchars = ret;
33803385 } else {
33813386 ret = xmlBufAdd(out->buffer, (const xmlChar *) buf, chunk);
33823387 if (ret != 0)
33833388 return(-1);
33843384- nbchars = xmlBufUse(out->buffer);
33893389+ if (out->writecallback)
33903390+ nbchars = xmlBufUse(out->buffer);
33913391+ else
33923392+ nbchars = chunk;
33853393 }
33863394 buf += chunk;
33873395 len -= chunk;
3388339633893389- if ((nbchars < MINLEN) && (len <= 0))
33903390- goto done;
33973397+ if (out->writecallback) {
33983398+ if ((nbchars < MINLEN) && (len <= 0))
33993399+ goto done;
3391340033923392- if (out->writecallback) {
33933401 /*
33943402 * second write the stuff to the I/O channel
33953403 */
···34093417 out->error = XML_IO_WRITE;
34103418 return(ret);
34113419 }
34123412- out->written += ret;
34203420+ if (out->written > INT_MAX - ret)
34213421+ out->written = INT_MAX;
34223422+ else
34233423+ out->written += ret;
34133424 }
34143425 written += nbchars;
34153426 } while (len > 0);
···34893500 * @escaping: an optional escaping function (or NULL)
34903501 *
34913502 * Write the content of the string in the output I/O buffer
34923492- * This routine escapes the caracters and then handle the I18N
35033503+ * This routine escapes the characters and then handle the I18N
34933504 * transcoding from internal UTF-8
34943505 * The buffer is lossless, i.e. will store in case of partial
34953506 * or delayed writes.
···35653576 out->error = XML_IO_ENCODER;
35663577 return(-1);
35673578 }
35683568- nbchars = xmlBufUse(out->conv);
35793579+ if (out->writecallback)
35803580+ nbchars = xmlBufUse(out->conv);
35813581+ else
35823582+ nbchars = ret;
35693583 } else {
35703584 ret = escaping(xmlBufEnd(out->buffer), &chunk, str, &cons);
35713585 if ((ret < 0) || (chunk == 0)) /* chunk==0 => nothing done */
35723586 return(-1);
35733587 xmlBufAddLen(out->buffer, chunk);
35743574- nbchars = xmlBufUse(out->buffer);
35883588+ if (out->writecallback)
35893589+ nbchars = xmlBufUse(out->buffer);
35903590+ else
35913591+ nbchars = chunk;
35753592 }
35763593 str += cons;
35773594 len -= cons;
3578359535793579- if ((nbchars < MINLEN) && (len <= 0))
35803580- goto done;
35963596+ if (out->writecallback) {
35973597+ if ((nbchars < MINLEN) && (len <= 0))
35983598+ goto done;
3581359935823582- if (out->writecallback) {
35833600 /*
35843601 * second write the stuff to the I/O channel
35853602 */
···35993616 out->error = XML_IO_WRITE;
36003617 return(ret);
36013618 }
36023602- out->written += ret;
36193619+ if (out->written > INT_MAX - ret)
36203620+ out->written = INT_MAX;
36213621+ else
36223622+ out->written += ret;
36033623 } else if (xmlBufAvail(out->buffer) < MINLEN) {
36043624 xmlBufGrow(out->buffer, MINLEN);
36053625 }
···36933713 out->error = XML_IO_FLUSH;
36943714 return(ret);
36953715 }
36963696- out->written += ret;
37163716+ if (out->written > INT_MAX - ret)
37173717+ out->written = INT_MAX;
37183718+ else
37193719+ out->written += ret;
3697372036983721#ifdef DEBUG_INPUT
36993722 xmlGenericError(xmlGenericErrorContext,
···39413964 * @ID: the System ID for the entity to load
39423965 * @ctxt: the context in which the entity is called or NULL
39433966 *
39443944- * By default we don't load external entitites, yet.
39673967+ * By default we don't load external entities, yet.
39453968 *
39463969 * Returns a new allocated xmlParserInputPtr, or NULL.
39473970 */
···6767 *
6868 * Opens a module/shared library given its name or path
6969 * NOTE: that due to portability issues, behaviour can only be
7070- * guaranteed with @name using ASCII. We canot guarantee that
7070+ * guaranteed with @name using ASCII. We cannot guarantee that
7171 * an UTF-8 string would work, which is why name is a const char *
7272 * and not a const xmlChar * .
7373 * TODO: options are not yet implemented.
···109109 *
110110 * Lookup for a symbol address in the given module
111111 * NOTE: that due to portability issues, behaviour can only be
112112- * guaranteed with @name using ASCII. We canot guarantee that
112112+ * guaranteed with @name using ASCII. We cannot guarantee that
113113 * an UTF-8 string would work, which is why name is a const char *
114114 * and not a const xmlChar * .
115115 *
+54-33
sdk/lib/3rdparty/libxml2/xmlreader.c
···238238239239 if (id->value != NULL)
240240 DICT_FREE(id->value)
241241+ if (id->name != NULL)
242242+ DICT_FREE(id->name)
241243 xmlFree(id);
242244}
243245···271273 return(-1);
272274 }
273275 id->name = attr->name;
276276+ attr->name = NULL;
274277 id->attr = NULL;
275278 return(0);
276279}
···345348static void
346349xmlTextReaderFreeNodeList(xmlTextReaderPtr reader, xmlNodePtr cur) {
347350 xmlNodePtr next;
351351+ xmlNodePtr parent;
348352 xmlDictPtr dict;
353353+ size_t depth = 0;
349354350355 if ((reader != NULL) && (reader->ctxt != NULL))
351356 dict = reader->ctxt->dict;
···361366 xmlFreeDoc((xmlDocPtr) cur);
362367 return;
363368 }
364364- while (cur != NULL) {
369369+ while (1) {
370370+ while ((cur->type != XML_DTD_NODE) &&
371371+ (cur->type != XML_ENTITY_REF_NODE) &&
372372+ (cur->children != NULL) &&
373373+ (cur->children->parent == cur)) {
374374+ cur = cur->children;
375375+ depth += 1;
376376+ }
377377+365378 next = cur->next;
379379+ parent = cur->parent;
380380+366381 /* unroll to speed up freeing the document */
367382 if (cur->type != XML_DTD_NODE) {
368383369369- if ((cur->children != NULL) &&
370370- (cur->type != XML_ENTITY_REF_NODE)) {
371371- if (cur->children->parent == cur)
372372- xmlTextReaderFreeNodeList(reader, cur->children);
373373- cur->children = NULL;
374374- }
375375-376384 if ((__xmlRegisterCallbacks) && (xmlDeregisterNodeDefaultValue))
377385 xmlDeregisterNodeDefaultValue(cur);
378386···411419 xmlFree(cur);
412420 }
413421 }
414414- cur = next;
422422+423423+ if (next != NULL) {
424424+ cur = next;
425425+ } else {
426426+ if ((depth == 0) || (parent == NULL))
427427+ break;
428428+ depth -= 1;
429429+ cur = parent;
430430+ cur->children = NULL;
431431+ }
415432 }
416433}
417434···9831000 */
9841001 node = xmlTextReaderExpand(reader);
9851002 if (node == NULL) {
986986-printf("Expand failed !\n");
9871003 ret = -1;
9881004 } else {
9891005 ret = xmlRelaxNGValidateFullElement(reader->rngValidCtxt,
···10951111 do {
10961112 if (node->type == XML_ENTITY_REF_NODE) {
10971113 /*
10981098- * Case where the underlying tree is not availble, lookup the entity
11141114+ * Case where the underlying tree is not available, lookup the entity
10991115 * and walk it.
11001116 */
11011117 if ((node->children == NULL) && (ctxt->sax != NULL) &&
···11121128 continue;
11131129 } else {
11141130 /*
11151115- * The error has probably be raised already.
11311131+ * The error has probably been raised already.
11161132 */
11171133 if (node == oldnode)
11181134 break;
11191119- node = node->next;
11351135+ goto skip_children;
11201136 }
11211137#ifdef LIBXML_REGEXP_ENABLED
11221138 } else if (node->type == XML_ELEMENT_NODE) {
···11381154 } else if (node->type == XML_ELEMENT_NODE) {
11391155 xmlTextReaderValidatePop(reader);
11401156 }
11571157+skip_children:
11411158 if (node->next != NULL) {
11421159 node = node->next;
11431160 continue;
···1357137413581375 /*
13591376 * If we are not backtracking on ancestors or examined nodes,
13601360- * that the parser didn't finished or that we arent at the end
13771377+ * that the parser didn't finished or that we aren't at the end
13611378 * of stream, continue processing.
13621379 */
13631380 while ((reader->node != NULL) && (reader->node->next == NULL) &&
···15481565 (reader->node->type == XML_ENTITY_REF_NODE) &&
15491566 (reader->ctxt != NULL) && (reader->ctxt->replaceEntities == 1)) {
15501567 /*
15511551- * Case where the underlying tree is not availble, lookup the entity
15681568+ * Case where the underlying tree is not available, lookup the entity
15521569 * and walk it.
15531570 */
15541571 if ((reader->node->children == NULL) && (reader->ctxt->sax != NULL) &&
···17131730 }
17141731 doc = reader->node->doc;
17151732 buff = xmlBufferCreate();
17331733+ if (buff == NULL)
17341734+ return NULL;
17161735 for (cur_node = reader->node->children; cur_node != NULL;
17171736 cur_node = cur_node->next) {
17181737 /* XXX: Why is the node copied? */
···17551774 xmlBufferPtr buff;
17561775 xmlDocPtr doc;
1757177617581758- node = reader->node;
17591759- doc = node->doc;
17601777 if (xmlTextReaderExpand(reader) == NULL) {
17611778 return NULL;
17621779 }
17801780+ node = reader->node;
17811781+ doc = node->doc;
17631782 /* XXX: Why is the node copied? */
17641783 if (node->type == XML_DTD_NODE) {
17651784 node = (xmlNodePtr) xmlCopyDtd((xmlDtdPtr) node);
···22622281 if (reader->ctxt != NULL) {
22632282 if (reader->dict == reader->ctxt->dict)
22642283 reader->dict = NULL;
22652265- if (reader->ctxt->myDoc != NULL) {
22662266- if (reader->preserve == 0)
22672267- xmlTextReaderFreeDoc(reader, reader->ctxt->myDoc);
22682268- reader->ctxt->myDoc = NULL;
22692269- }
22702284 if ((reader->ctxt->vctxt.vstateTab != NULL) &&
22712285 (reader->ctxt->vctxt.vstateMax > 0)){
22862286+ while (reader->ctxt->vctxt.vstateNr > 0)
22872287+ xmlValidatePopElement(&reader->ctxt->vctxt, NULL, NULL, NULL);
22722288 xmlFree(reader->ctxt->vctxt.vstateTab);
22732289 reader->ctxt->vctxt.vstateTab = NULL;
22742290 reader->ctxt->vctxt.vstateMax = 0;
22912291+ }
22922292+ if (reader->ctxt->myDoc != NULL) {
22932293+ if (reader->preserve == 0)
22942294+ xmlTextReaderFreeDoc(reader, reader->ctxt->myDoc);
22952295+ reader->ctxt->myDoc = NULL;
22752296 }
22762297 if (reader->allocs & XML_TEXTREADER_CTXT)
22772298 xmlFreeParserCtxt(reader->ctxt);
···25002521 * parser, set its state to End Of File and return the input stream with
25012522 * what is left that the parser did not use.
25022523 *
25032503- * The implementation is not good, the parser certainly procgressed past
25242524+ * The implementation is not good, the parser certainly progressed past
25042525 * what's left in reader->input, and there is an allocation problem. Best
25052526 * would be to rewrite it differently.
25062527 *
···28822903 *
28832904 * Parses an attribute value into one or more Text and EntityReference nodes.
28842905 *
28852885- * Returns 1 in case of success, 0 if the reader was not positionned on an
28862886- * ttribute node or all the attribute values have been read, or -1
29062906+ * Returns 1 in case of success, 0 if the reader was not positioned on an
29072907+ * attribute node or all the attribute values have been read, or -1
28872908 * in case of error.
28882909 */
28892910int
···39203941 * xmlTextReaderCurrentNode:
39213942 * @reader: the xmlTextReaderPtr used
39223943 *
39233923- * Hacking interface allowing to get the xmlNodePtr correponding to the
39443944+ * Hacking interface allowing to get the xmlNodePtr corresponding to the
39243945 * current node being accessed by the xmlTextReader. This is dangerous
39253946 * because the underlying node may be destroyed on the next Reads.
39263947 *
···40324053 * xmlTextReaderCurrentDoc:
40334054 * @reader: the xmlTextReaderPtr used
40344055 *
40354035- * Hacking interface allowing to get the xmlDocPtr correponding to the
40564056+ * Hacking interface allowing to get the xmlDocPtr corresponding to the
40364057 * current document being accessed by the xmlTextReader.
40374058 * NOTE: as a result of this call, the reader will not destroy the
40384059 * associated XML document and calling xmlFreeDoc() on the result
···41354156 *
41364157 * Use RelaxNG to validate the document as it is processed.
41374158 * Activation is only possible before the first Read().
41384138- * if @schema is NULL, then RelaxNG validation is desactivated.
41594159+ * if @schema is NULL, then RelaxNG validation is deactivated.
41394160 @ The @schema should not be freed until the reader is deallocated
41404161 * or its use has been deactivated.
41414162 *
41424142- * Returns 0 in case the RelaxNG validation could be (des)activated and
41634163+ * Returns 0 in case the RelaxNG validation could be (de)activated and
41434164 * -1 in case of error.
41444165 */
41454166int
···41994220 *
42004221 * Internal locator function for the readers
42014222 *
42024202- * Returns 0 in case the Schema validation could be (des)activated and
42234223+ * Returns 0 in case the Schema validation could be (de)activated and
42034224 * -1 in case of error.
42044225 */
42054226static int
···42524273 *
42534274 * Use XSD Schema to validate the document as it is processed.
42544275 * Activation is only possible before the first Read().
42554255- * if @schema is NULL, then Schema validation is desactivated.
42564256- @ The @schema should not be freed until the reader is deallocated
42764276+ * if @schema is NULL, then Schema validation is deactivated.
42774277+ * The @schema should not be freed until the reader is deallocated
42574278 * or its use has been deactivated.
42584279 *
42594259- * Returns 0 in case the Schema validation could be (des)activated and
42804280+ * Returns 0 in case the Schema validation could be (de)activated and
42604281 * -1 in case of error.
42614282 */
42624283int
+56-43
sdk/lib/3rdparty/libxml2/xmlregexp.c
···22 * regexp.c: generic and extensible Regular Expression engine
33 *
44 * Basically designed with the purpose of compiling regexps for
55- * the variety of validation/shemas mechanisms now available in
55+ * the variety of validation/schemas mechanisms now available in
66 * XML related specifications these include:
77 * - XML-1.0 DTD validation
88 * - XML Schemas structure part 1
···228228 int maxTrans;
229229 int nbTrans;
230230 xmlRegTrans *trans;
231231- /* knowing states ponting to us can speed things up */
231231+ /* knowing states pointing to us can speed things up */
232232 int maxTransTo;
233233 int nbTransTo;
234234 int *transTo;
···545545 if (transitions == NULL) {
546546 xmlFree(stateRemap);
547547 xmlFree(stringRemap);
548548+ for (i = 0;i < nbatoms;i++)
549549+ xmlFree(stringMap[i]);
548550 xmlFree(stringMap);
549551 xmlFree(ret);
550552 return(NULL);
···588590 targetno = stateRemap[trans->to];
589591 /*
590592 * if the same atom can generate transitions to 2 different
591591- * states then it means the automata is not determinist and
593593+ * states then it means the automata is not deterministic and
592594 * the compact form can't be used !
593595 */
594596 prev = transitions[stateno * (nbatoms + 1) + atomno + 1];
···829831/**
830832 * xmlRegCopyAtom:
831833 * @ctxt: the regexp parser context
832832- * @atom: the oiginal atom
834834+ * @atom: the original atom
833835 *
834836 * Allocate a new regexp range
835837 *
···15471549 int nullable = 0;
1548155015491551 if (atom == NULL) {
15501550- ERROR("genrate transition: atom == NULL");
15521552+ ERROR("generate transition: atom == NULL");
15511553 return(-1);
15521554 }
15531555 if (atom->type == XML_REGEXP_SUBREG) {
···16221624 xmlRegAtomPtr copy;
16231625 /*
16241626 * duplicate a transition based on atom to count next
16251625- * occurences after 1. We cannot loop to atom->start
16271627+ * occurrences after 1. We cannot loop to atom->start
16261628 * directly because we need an epsilon transition to
16271629 * newstate.
16281630 */
···16551657 } else {
16561658 /*
16571659 * either we need the atom at least once or there
16581658- * is an atom->start0 allowing to easilly plug the
16601660+ * is an atom->start0 allowing to easily plug the
16591661 * epsilon transition.
16601662 */
16611663 counter = xmlRegGetCounter(ctxt);
···19551957 * Build the completed transitions bypassing the epsilons
19561958 * Use a marking algorithm to avoid loops
19571959 * Mark sink states too.
19581958- * Process from the latests states backward to the start when
19601960+ * Process from the latest states backward to the start when
19591961 * there is long cascading epsilon chains this minimize the
19601962 * recursions and transition compares when adding the new ones
19611963 */
···21432145 } else {
21442146 /*
21452147 * comparing a block range with anything else is way
21462146- * too costly, and maintining the table is like too much
21482148+ * too costly, and maintaining the table is like too much
21472149 * memory too, so let's force the automata to save state
21482150 * here.
21492151 */
···22772279 }
22782280 switch (type1) {
22792281 case XML_REGEXP_ANYSPACE: /* \s */
22802280- /* can't be a letter, number, mark, pontuation, symbol */
22822282+ /* can't be a letter, number, mark, punctuation, symbol */
22812283 if ((type2 == XML_REGEXP_NOTSPACE) ||
22822284 ((type2 >= XML_REGEXP_LETTER) &&
22832285 (type2 <= XML_REGEXP_LETTER_OTHERS)) ||
···22942296 case XML_REGEXP_NOTSPACE: /* \S */
22952297 break;
22962298 case XML_REGEXP_INITNAME: /* \l */
22972297- /* can't be a number, mark, separator, pontuation, symbol or other */
22992299+ /* can't be a number, mark, separator, punctuation, symbol or other */
22982300 if ((type2 == XML_REGEXP_NOTINITNAME) ||
22992301 ((type2 >= XML_REGEXP_NUMBER) &&
23002302 (type2 <= XML_REGEXP_NUMBER_OTHERS)) ||
···23132315 case XML_REGEXP_NOTINITNAME: /* \L */
23142316 break;
23152317 case XML_REGEXP_NAMECHAR: /* \c */
23162316- /* can't be a mark, separator, pontuation, symbol or other */
23182318+ /* can't be a mark, separator, punctuation, symbol or other */
23172319 if ((type2 == XML_REGEXP_NOTNAMECHAR) ||
23182320 ((type2 >= XML_REGEXP_MARK) &&
23192321 (type2 <= XML_REGEXP_MARK_ENCLOSING)) ||
···23302332 case XML_REGEXP_NOTNAMECHAR: /* \C */
23312333 break;
23322334 case XML_REGEXP_DECIMAL: /* \d */
23332333- /* can't be a letter, mark, separator, pontuation, symbol or other */
23352335+ /* can't be a letter, mark, separator, punctuation, symbol or other */
23342336 if ((type2 == XML_REGEXP_NOTDECIMAL) ||
23352337 (type2 == XML_REGEXP_REALCHAR) ||
23362338 ((type2 >= XML_REGEXP_LETTER) &&
···23502352 case XML_REGEXP_NOTDECIMAL: /* \D */
23512353 break;
23522354 case XML_REGEXP_REALCHAR: /* \w */
23532353- /* can't be a mark, separator, pontuation, symbol or other */
23552355+ /* can't be a mark, separator, punctuation, symbol or other */
23542356 if ((type2 == XML_REGEXP_NOTDECIMAL) ||
23552357 ((type2 >= XML_REGEXP_MARK) &&
23562358 (type2 <= XML_REGEXP_MARK_ENCLOSING)) ||
···25262528 case XML_REGEXP_STRING:
25272529 if (!deep)
25282530 ret = (atom1->valuep != atom2->valuep);
25292529- else
25302530- ret = xmlRegStrEqualWildcard((xmlChar *)atom1->valuep,
25312531- (xmlChar *)atom2->valuep);
25312531+ else {
25322532+ xmlChar *val1 = (xmlChar *)atom1->valuep;
25332533+ xmlChar *val2 = (xmlChar *)atom2->valuep;
25342534+ int compound1 = (xmlStrchr(val1, '|') != NULL);
25352535+ int compound2 = (xmlStrchr(val2, '|') != NULL);
25362536+25372537+ /* Ignore negative match flag for ##other namespaces */
25382538+ if (compound1 != compound2)
25392539+ return(0);
25402540+25412541+ ret = xmlRegStrEqualWildcard(val1, val2);
25422542+ }
25322543 break;
25332544 case XML_REGEXP_EPSILON:
25342545 goto not_determinist;
···3564357535653576/**
35663577 * xmlRegFreeExecCtxt:
35673567- * @exec: a regular expression evaulation context
35783578+ * @exec: a regular expression evaluation context
35683579 *
35693569- * Free the structures associated to a regular expression evaulation context.
35803580+ * Free the structures associated to a regular expression evaluation context.
35703581 */
35713582void
35723583xmlRegFreeExecCtxt(xmlRegExecCtxtPtr exec) {
···36403651 * @valStr: the validation string
36413652 *
36423653 * Checks if both strings are equal or have the same content. "*"
36433643- * can be used as a wildcard in @valStr; "|" is used as a seperator of
36543654+ * can be used as a wildcard in @valStr; "|" is used as a separator of
36443655 * substrings in both @expStr and @valStr.
36453656 *
36463657 * Returns 1 if the comparison is satisfied and the number of substrings
···5347535853485359 previous = ctxt->state;
53495360 ret = xmlFAParsePiece(ctxt);
53505350- if (ret != 0) {
53615361+ if (ret == 0) {
53625362+ /* Empty branch */
53635363+ xmlFAGenerateEpsilonTransition(ctxt, previous, to);
53645364+ } else {
53515365 if (xmlFAGenerateTransitions(ctxt, previous,
53525352- (CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
53665366+ (CUR=='|' || CUR==')' || CUR==0) ? to : NULL, ctxt->atom) < 0)
53535367 return(-1);
53545368 previous = ctxt->state;
53555369 ctxt->atom = NULL;
···53585372 ret = xmlFAParsePiece(ctxt);
53595373 if (ret != 0) {
53605374 if (xmlFAGenerateTransitions(ctxt, previous,
53615361- (CUR=='|' || CUR==')') ? to : NULL, ctxt->atom) < 0)
53755375+ (CUR=='|' || CUR==')' || CUR==0) ? to : NULL,
53765376+ ctxt->atom) < 0)
53625377 return(-1);
53635378 previous = ctxt->state;
53645379 ctxt->atom = NULL;
···53955410 end = ctxt->state;
53965411 while ((CUR == '|') && (ctxt->error == 0)) {
53975412 NEXT;
53985398- if (CUR == 0) {
53995399- ERROR("expecting a branch after |")
54005400- return;
54015401- }
54025413 ctxt->state = start;
54035414 ctxt->end = NULL;
54045415 xmlFAParseBranch(ctxt, end);
···55375548 return(comp->determinist);
5538554955395550 am = xmlNewAutomata();
55515551+ if (am == NULL)
55525552+ return(-1);
55405553 if (am->states != NULL) {
55415554 int i;
55425555···58645877 * @to: the target point of the transition or NULL
58655878 * @token: the input string associated to that transition
58665879 * @token2: the second input string associated to that transition
58675867- * @min: the minimum successive occurences of token
58685868- * @max: the maximum successive occurences of token
58805880+ * @min: the minimum successive occurrences of token
58815881+ * @max: the maximum successive occurrences of token
58695882 * @data: data associated to the transition
58705883 *
58715884 * If @to is NULL, this creates first a new target state in the automata
···59515964 * @from: the starting point of the transition
59525965 * @to: the target point of the transition or NULL
59535966 * @token: the input string associated to that transition
59545954- * @min: the minimum successive occurences of token
59555955- * @max: the maximum successive occurences of token
59675967+ * @min: the minimum successive occurrences of token
59685968+ * @max: the maximum successive occurrences of token
59565969 * @data: data associated to the transition
59575970 *
59585971 * If @to is NULL, this creates first a new target state in the automata
···60186031 * @to: the target point of the transition or NULL
60196032 * @token: the input string associated to that transition
60206033 * @token2: the second input string associated to that transition
60216021- * @min: the minimum successive occurences of token
60226022- * @max: the maximum successive occurences of token
60346034+ * @min: the minimum successive occurrences of token
60356035+ * @max: the maximum successive occurrences of token
60236036 * @data: data associated to the transition
60246037 *
60256038 * If @to is NULL, this creates first a new target state in the automata
···60986111 * @from: the starting point of the transition
60996112 * @to: the target point of the transition or NULL
61006113 * @token: the input string associated to that transition
61016101- * @min: the minimum successive occurences of token
61026102- * @max: the maximum successive occurences of token
61146114+ * @min: the minimum successive occurrences of token
61156115+ * @max: the maximum successive occurrences of token
61036116 * @data: data associated to the transition
61046117 *
61056118 * If @to is NULL, this creates first a new target state in the automata
···66166629 /* OR reduction rule 1 */
66176630 /* a | a reduced to a */
66186631 if (left == right) {
66196619- left->ref--;
66326632+ xmlExpFree(ctxt, right);
66206633 return(left);
66216634 }
66226635 /* OR canonicalization rule 1 */
···70757088 * xmlExpIsNillable:
70767089 * @exp: the expression
70777090 *
70787078- * Finds if the expression is nillable, i.e. if it accepts the empty sequqnce
70917091+ * Finds if the expression is nillable, i.e. if it accepts the empty sequence
70797092 *
70807093 * Returns 1 if nillable, 0 if not and -1 in case of error
70817094 */
···72587271 * so that sub{n} subsume exp
72597272 *
72607273 * Returns the multiple value if successful, 0 if it is not a multiple
72617261- * and -1 in case of internel error.
72747274+ * and -1 in case of internal error.
72627275 */
7263727672647277static int
···74267439 return(forbiddenExp);
74277440 }
74287441#ifdef DEBUG_DERIV
74297429- printf("Compex exp vs Atom -> Forbid\n");
74427442+ printf("Complex exp vs Atom -> Forbid\n");
74307443#endif
74317444 return(forbiddenExp);
74327445 case XML_EXP_SEQ:
···77707783 *
77717784 * Evaluates the expression resulting from @exp consuming a sub expression @sub
77727785 * Based on algebraic derivation and sometimes direct Brzozowski derivation
77737773- * it usually tatkes less than linear time and can handle expressions generating
77867786+ * it usually takes less than linear time and can handle expressions generating
77747787 * infinite languages.
77757788 *
77767789 * Returns the resulting expression or NULL in case of internal error, the
···77927805 }
77937806 if (xmlExpCheckCard(exp, sub) == 0) {
77947807#ifdef DEBUG_DERIV
77957795- printf("sub generate longuer sequances than exp : can't subsume\n");
78087808+ printf("sub generate longer sequences than exp : can't subsume\n");
77967809#endif
77977810 return(forbiddenExp);
77987811 }
···78057818 * @exp: the englobing expression
78067819 * @sub: the subexpression
78077820 *
78087808- * Check whether @exp accepts all the languages accexpted by @sub
78217821+ * Check whether @exp accepts all the languages accepted by @sub
78097822 * the input being a subexpression.
78107823 *
78117824 * Returns 1 if true 0 if false and -1 in case of failure.
···78327845 }
78337846 if (xmlExpCheckCard(exp, sub) == 0) {
78347847#ifdef DEBUG_DERIV
78357835- printf("sub generate longuer sequances than exp : can't subsume\n");
78487848+ printf("sub generate longer sequences than exp : can't subsume\n");
78367849#endif
78377850 return(0);
78387851 }
+6-17
sdk/lib/3rdparty/libxml2/xmlsave.c
···11/*
22- * xmlsave.c: Implemetation of the document serializer
22+ * xmlsave.c: Implementation of the document serializer
33 *
44 * See Copyright for the status of this software.
55 *
···8383 const xmlChar *encoding;
8484 xmlCharEncodingHandlerPtr handler;
8585 xmlOutputBufferPtr buf;
8686- xmlDocPtr doc;
8786 int options;
8887 int level;
8988 int format;
···356355/**
357356 * xmlFreeSaveCtxt:
358357 *
359359- * Free a saving context, destroying the ouptut in any remaining buffer
358358+ * Free a saving context, destroying the output in any remaining buffer
360359 */
361360static void
362361xmlFreeSaveCtxt(xmlSaveCtxtPtr ctxt)
···707706xmlDtdDumpOutput(xmlSaveCtxtPtr ctxt, xmlDtdPtr dtd) {
708707 xmlOutputBufferPtr buf;
709708 int format, level;
710710- xmlDocPtr doc;
711709712710 if (dtd == NULL) return;
713711 if ((ctxt == NULL) || (ctxt->buf == NULL))
···742740 }
743741 format = ctxt->format;
744742 level = ctxt->level;
745745- doc = ctxt->doc;
746743 ctxt->format = 0;
747744 ctxt->level = -1;
748748- ctxt->doc = dtd->doc;
749745 xmlNodeListDumpOutput(ctxt, dtd->children);
750746 ctxt->format = format;
751747 ctxt->level = level;
752752- ctxt->doc = doc;
753748 xmlOutputBufferWrite(buf, 2, "]>");
754749}
755750···21912186 *
21922187 * Dump an XML node, recursive behaviour,children are printed too.
21932188 * Note that @format = 1 provide node indenting only if xmlIndentTreeOutput = 1
21942194- * or xmlKeepBlanksDefault(0) was called
21892189+ * or xmlKeepBlanksDefault(0) was called.
21952190 * Since this is using xmlBuffer structures it is limited to 2GB and somehow
21962196- * deprecated, use xmlBufNodeDump() instead.
21912191+ * deprecated, use xmlNodeDumpOutput() instead.
21972192 *
21982193 * Returns the number of bytes written to the buffer or -1 in case of error
21992194 */
···23602355 encoding = "UTF-8";
2361235623622357 memset(&ctxt, 0, sizeof(ctxt));
23632363- ctxt.doc = doc;
23642358 ctxt.buf = buf;
23652359 ctxt.level = level;
23662360 ctxt.format = format ? 1 : 0;
···24462440 }
2447244124482442 memset(&ctxt, 0, sizeof(ctxt));
24492449- ctxt.doc = out_doc;
24502443 ctxt.buf = out_buff;
24512444 ctxt.level = 0;
24522445 ctxt.format = format ? 1 : 0;
···25652558 buf = xmlOutputBufferCreateFile(f, handler);
25662559 if (buf == NULL) return(-1);
25672560 memset(&ctxt, 0, sizeof(ctxt));
25682568- ctxt.doc = cur;
25692561 ctxt.buf = buf;
25702562 ctxt.level = 0;
25712563 ctxt.format = format ? 1 : 0;
···25962588 * xmlSaveFileTo:
25972589 * @buf: an output I/O buffer
25982590 * @cur: the document
25992599- * @encoding: the encoding if any assuming the I/O layer handles the trancoding
25912591+ * @encoding: the encoding if any assuming the I/O layer handles the transcoding
26002592 *
26012593 * Dump an XML document to an I/O buffer.
26022594 * Warning ! This call xmlOutputBufferClose() on buf which is not available
···26152607 return(-1);
26162608 }
26172609 memset(&ctxt, 0, sizeof(ctxt));
26182618- ctxt.doc = cur;
26192610 ctxt.buf = buf;
26202611 ctxt.level = 0;
26212612 ctxt.format = 0;
···26312622 * xmlSaveFormatFileTo:
26322623 * @buf: an output I/O buffer
26332624 * @cur: the document
26342634- * @encoding: the encoding if any assuming the I/O layer handles the trancoding
26252625+ * @encoding: the encoding if any assuming the I/O layer handles the transcoding
26352626 * @format: should formatting spaces been added
26362627 *
26372628 * Dump an XML document to an I/O buffer.
···26552646 return(-1);
26562647 }
26572648 memset(&ctxt, 0, sizeof(ctxt));
26582658- ctxt.doc = cur;
26592649 ctxt.buf = buf;
26602650 ctxt.level = 0;
26612651 ctxt.format = format ? 1 : 0;
···27102700 buf = xmlOutputBufferCreateFilename(filename, handler, cur->compression);
27112701 if (buf == NULL) return(-1);
27122702 memset(&ctxt, 0, sizeof(ctxt));
27132713- ctxt.doc = cur;
27142703 ctxt.buf = buf;
27152704 ctxt.level = 0;
27162705 ctxt.format = format ? 1 : 0;
+86-102
sdk/lib/3rdparty/libxml2/xmlschemas.c
···2222 * acquisition episode (xmlSchemaAugmentIDC).
2323 *
2424 * NOTES:
2525- * - Elimated item creation for: <restriction>, <extension>,
2525+ * - Eliminated item creation for: <restriction>, <extension>,
2626 * <simpleContent>, <complexContent>, <list>, <union>
2727 *
2828 * PROBLEMS:
···27802780/**
27812781 * xmlSchemaPMissingAttrErr:
27822782 * @ctxt: the schema validation context
27832783- * @ownerDes: the designation of the owner
27842784- * @ownerName: the name of the owner
27852783 * @ownerItem: the owner as a schema object
27862784 * @ownerElem: the owner as an element node
27872785 * @node: the parent element node of the missing attribute node
···28152813 * xmlSchemaPResCompAttrErr:
28162814 * @ctxt: the schema validation context
28172815 * @error: the error code
28182818- * @ownerDes: the designation of the owner
28192816 * @ownerItem: the owner as a schema object
28202817 * @ownerElem: the owner as an element node
28212818 * @name: the name of the attribute holding the QName
···28972894 * xmlSchemaPIllegalAttrErr:
28982895 * @ctxt: the schema parser context
28992896 * @error: the error code
29002900- * @ownerDes: the designation of the attribute's owner
29012897 * @ownerItem: the attribute's owner item
29022898 * @attr: the illegal attribute node
29032899 *
···31093105 * @ctxt: the schema validation context
31103106 * @error: the error code
31113107 * @type: the type specifier
31123112- * @ownerDes: the designation of the owner
31133108 * @ownerItem: the schema object if existent
31143109 * @node: the validated node
31153110 * @value: the validated value
···32023197 * xmlSchemaPContentErr:
32033198 * @ctxt: the schema parser context
32043199 * @error: the error code
32053205- * @onwerDes: the designation of the holder of the content
32063200 * @ownerItem: the owner item of the holder of the content
32073201 * @ownerElem: the node of the holder of the content
32083202 * @child: the invalid child node
···43074301 * xmlSchemaContentModelDump:
43084302 * @particle: the schema particle
43094303 * @output: the file output
43104310- * @depth: the depth used for intentation
43044304+ * @depth: the depth used for indentation
43114305 *
43124306 * Dump a SchemaType structure
43134307 */
···51555149 * Add an XML schema annotation declaration
51565150 * *WARNING* this interface is highly subject to change
51575151 *
51585158- * Returns the new struture or NULL in case of error
51525152+ * Returns the new structure or NULL in case of error
51595153 */
51605154static xmlSchemaNotationPtr
51615155xmlSchemaAddNotation(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
···51895183 * @name: the item name
51905184 * @namespace: the namespace
51915185 *
51925192- * Add an XML schema Attrribute declaration
51865186+ * Add an XML schema Attribute declaration
51935187 * *WARNING* this interface is highly subject to change
51945188 *
51955195- * Returns the new struture or NULL in case of error
51895189+ * Returns the new structure or NULL in case of error
51965190 */
51975191static xmlSchemaAttributePtr
51985192xmlSchemaAddAttribute(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
···52305224 * @name: the item name
52315225 * @namespace: the namespace
52325226 *
52335233- * Add an XML schema Attrribute declaration
52275227+ * Add an XML schema Attribute declaration
52345228 * *WARNING* this interface is highly subject to change
52355229 *
52365236- * Returns the new struture or NULL in case of error
52305230+ * Returns the new structure or NULL in case of error
52375231 */
52385232static xmlSchemaAttributeUsePtr
52395233xmlSchemaAddAttributeUse(xmlSchemaParserCtxtPtr pctxt,
···53015295 * @nsName: the target namespace
53025296 * @node: the corresponding node
53035297 *
53045304- * Add an XML schema Attrribute Group definition.
52985298+ * Add an XML schema Attribute Group definition.
53055299 *
53065306- * Returns the new struture or NULL in case of error
53005300+ * Returns the new structure or NULL in case of error
53075301 */
53085302static xmlSchemaAttributeGroupPtr
53095303xmlSchemaAddAttributeGroupDefinition(xmlSchemaParserCtxtPtr pctxt,
···53555349 * Add an XML schema Element declaration
53565350 * *WARNING* this interface is highly subject to change
53575351 *
53585358- * Returns the new struture or NULL in case of error
53525352+ * Returns the new structure or NULL in case of error
53595353 */
53605354static xmlSchemaElementPtr
53615355xmlSchemaAddElement(xmlSchemaParserCtxtPtr ctxt,
···53965390 * Add an XML schema item
53975391 * *WARNING* this interface is highly subject to change
53985392 *
53995399- * Returns the new struture or NULL in case of error
53935393+ * Returns the new structure or NULL in case of error
54005394 */
54015395static xmlSchemaTypePtr
54025396xmlSchemaAddType(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
···54935487 * Adds a schema model group
54945488 * *WARNING* this interface is highly subject to change
54955489 *
54965496- * Returns the new struture or NULL in case of error
54905490+ * Returns the new structure or NULL in case of error
54975491 */
54985492static xmlSchemaModelGroupPtr
54995493xmlSchemaAddModelGroup(xmlSchemaParserCtxtPtr ctxt,
···55355529 * Adds an XML schema particle component.
55365530 * *WARNING* this interface is highly subject to change
55375531 *
55385538- * Returns the new struture or NULL in case of error
55325532+ * Returns the new structure or NULL in case of error
55395533 */
55405534static xmlSchemaParticlePtr
55415535xmlSchemaAddParticle(xmlSchemaParserCtxtPtr ctxt,
···55815575 *
55825576 * Add an XML schema Group definition
55835577 *
55845584- * Returns the new struture or NULL in case of error
55785578+ * Returns the new structure or NULL in case of error
55855579 */
55865580static xmlSchemaModelGroupDefPtr
55875581xmlSchemaAddModelGroupDefinition(xmlSchemaParserCtxtPtr ctxt,
···56275621 *
56285622 * Creates a new wildcard namespace constraint.
56295623 *
56305630- * Returns the new struture or NULL in case of error
56245624+ * Returns the new structure or NULL in case of error
56315625 */
56325626static xmlSchemaWildcardNsPtr
56335627xmlSchemaNewWildcardNsConstraint(xmlSchemaParserCtxtPtr ctxt)
···56855679 * Adds a wildcard.
56865680 * It corresponds to a xsd:anyAttribute and xsd:any.
56875681 *
56885688- * Returns the new struture or NULL in case of error
56825682+ * Returns the new structure or NULL in case of error
56895683 */
56905684static xmlSchemaWildcardPtr
56915685xmlSchemaAddWildcard(xmlSchemaParserCtxtPtr ctxt, xmlSchemaPtr schema,
···58135807 * xmlSchemaPValAttrNodeQNameValue:
58145808 * @ctxt: a schema parser context
58155809 * @schema: the schema context
58165816- * @ownerDes: the designation of the parent element
58175810 * @ownerItem: the parent as a schema object
58185811 * @value: the QName value
58125812+ * @uri: the resulting namespace URI if found
58195813 * @local: the resulting local part if found, the attribute value otherwise
58205820- * @uri: the resulting namespace URI if found
58215814 *
58225815 * Extracts the local name and the URI of a QName value and validates it.
58235816 * This one is intended to be used on attribute values that
···58945887 * xmlSchemaPValAttrNodeQName:
58955888 * @ctxt: a schema parser context
58965889 * @schema: the schema context
58975897- * @ownerDes: the designation of the owner element
58985890 * @ownerItem: the owner as a schema object
58995891 * @attr: the attribute node
58925892+ * @uri: the resulting namespace URI if found
59005893 * @local: the resulting local part if found, the attribute value otherwise
59015901- * @uri: the resulting namespace URI if found
59025894 *
59035895 * Extracts and validates the QName of an attribute value.
59045896 * This one is intended to be used on attribute values that
···59265918 * xmlSchemaPValAttrQName:
59275919 * @ctxt: a schema parser context
59285920 * @schema: the schema context
59295929- * @ownerDes: the designation of the parent element
59305921 * @ownerItem: the owner as a schema object
59315922 * @ownerElem: the parent node of the attribute
59325923 * @name: the name of the attribute
59335933- * @local: the resulting local part if found, the attribute value otherwise
59345924 * @uri: the resulting namespace URI if found
59255925+ * @local: the resulting local part if found, the attribute value otherwise
59355926 *
59365927 * Extracts and validates the QName of an attribute value.
59375928 *
···59625953/**
59635954 * xmlSchemaPValAttrID:
59645955 * @ctxt: a schema parser context
59655965- * @schema: the schema context
59665966- * @ownerDes: the designation of the parent element
59675967- * @ownerItem: the owner as a schema object
59685968- * @ownerElem: the parent node of the attribute
59695969- * @name: the name of the attribute
59705956 *
59715957 * Extracts and validates the ID of an attribute value.
59725958 *
···61626148/**
61636149 * xmlSchemaPGetBoolNodeValue:
61646150 * @ctxt: a schema validation context
61656165- * @ownerDes: owner designation
61666151 * @ownerItem: the owner as a schema item
61676152 * @node: the node holding the value
61686153 *
···6253623862546239/************************************************************************
62556240 * *
62566256- * Shema extraction from an Infoset *
62416241+ * Schema extraction from an Infoset *
62576242 * *
62586243 ************************************************************************/
62596244static xmlSchemaTypePtr xmlSchemaParseSimpleType(xmlSchemaParserCtxtPtr
···62866271/**
62876272 * xmlSchemaPValAttrNodeValue:
62886273 *
62896289- * @ctxt: a schema parser context
62906290- * @ownerDes: the designation of the parent element
62746274+ * @pctxt: a schema parser context
62916275 * @ownerItem: the schema object owner if existent
62926276 * @attr: the schema attribute node being validated
62936277 * @value: the value
···63606344 * xmlSchemaPValAttrNode:
63616345 *
63626346 * @ctxt: a schema parser context
63636363- * @ownerDes: the designation of the parent element
63646347 * @ownerItem: the schema object owner if existent
63656348 * @attr: the schema attribute node being validated
63666349 * @type: the built-in type to be validated against
···63986381 *
63996382 * @ctxt: a schema parser context
64006383 * @node: the element node of the attribute
64016401- * @ownerDes: the designation of the parent element
64026384 * @ownerItem: the schema object owner if existent
64036385 * @ownerElem: the owner element node
64046386 * @name: the name of the schema attribute node
···65436525 * @schema: the schema being built
65446526 * @node: a subtree containing XML Schema informations
65456527 *
65466546- * parse a XML schema Attrribute declaration
65286528+ * parse a XML schema Attribute declaration
65476529 * *WARNING* this interface is highly subject to change
65486530 *
65496531 * Returns -1 in case of error, 0 if the declaration is improper and
···68406822 dictnsItem = xmlDictLookup(ctxt->dict, nsItem, -1);
68416823 }
68426824 /*
68436843- * Avoid dublicate namespaces.
68256825+ * Avoid duplicate namespaces.
68446826 */
68456827 tmp = wildc->nsSet;
68466828 while (tmp != NULL) {
···70637045 * @schema: the schema being built
70647046 * @node: a subtree containing XML Schema informations
70657047 *
70667066- * parse a XML schema AnyAttrribute declaration
70487048+ * parse a XML schema AnyAttribute declaration
70677049 * *WARNING* this interface is highly subject to change
70687050 *
70697051 * Returns a wildcard or NULL.
···71337115 * @schema: the schema being built
71347116 * @node: a subtree containing XML Schema informations
71357117 *
71367136- * parse a XML schema Attrribute declaration
71187118+ * parse a XML schema Attribute declaration
71377119 * *WARNING* this interface is highly subject to change
71387120 *
71397121 * Returns the attribute declaration.
···79537935 int ret = 0;
7954793679557937 /*
79567956- * TODO: This does not check for dublicate entries.
79387938+ * TODO: This does not check for duplicate entries.
79577939 */
79587940 if ((flags == NULL) || (value == NULL))
79597941 return (-1);
···81458127 *
81468128 * Adds the annotation to the given schema component.
81478129 *
81488148- * Returns the given annotaion.
81308130+ * Returns the given annotation.
81498131 */
81508132static xmlSchemaAnnotPtr
81518133xmlSchemaAddAnnotation(xmlSchemaAnnotItemPtr annItem,
···82408222 * @schema: the schema being built
82418223 * @node: a subtree containing XML Schema informations
82428224 *
82438243- * Parses a XML Schema identity-contraint definition's
82258225+ * Parses a XML Schema identity-constraint definition's
82448226 * <selector> and <field> elements.
82458227 *
82468228 * Returns the parsed identity-constraint definition.
···83388320 * @schema: the schema being built
83398321 * @node: a subtree containing XML Schema informations
83408322 *
83418341- * Parses a XML Schema identity-contraint definition.
83238323+ * Parses a XML Schema identity-constraint definition.
83428324 *
83438325 * Returns the parsed identity-constraint definition.
83448326 */
···94779459 *
94789460 * Parses a XML schema model group definition.
94799461 *
94809480- * Note that the contraint src-redefine (6.2) can't be applied until
94629462+ * Note that the constraint src-redefine (6.2) can't be applied until
94819463 * references have been resolved. So we will do this at the
94829464 * component fixup level.
94839465 *
···1018510167 goto exit;
1018610168 /*
1018710169 * TODO: Not nice, but I'm not 100% sure we will get always an error
1018810188- * as a result of the obove functions; so better rely on pctxt->err
1017010170+ * as a result of the above functions; so better rely on pctxt->err
1018910171 * as well.
1019010172 */
1019110173 if ((ret == 0) && (oldErrs != pctxt->nberrors)) {
···1027910261 xmlNodePtr ctxtNode)
1028010262{
1028110263 /*
1028210282- * Build an absolue location URI.
1026410264+ * Build an absolute location URI.
1028310265 */
1028410266 if (location != NULL) {
1028510267 if (ctxtNode == NULL)
···1036110343 if ((type == XML_SCHEMA_SCHEMA_MAIN) || (! WXS_HAS_BUCKETS(pctxt)))
1036210344 goto doc_load;
10363103451036410364- /* Note that we expect the location to be an absulute URI. */
1034610346+ /* Note that we expect the location to be an absolute URI. */
1036510347 if (schemaLocation != NULL) {
1036610348 bkt = xmlSchemaGetSchemaBucket(pctxt, schemaLocation);
1036710349 if ((bkt != NULL) &&
···10508104901050910491 /*
1051010492 * Chameleon include/redefine: skip loading only if it was
1051110511- * aleady build for the targetNamespace of the including
1049310493+ * already build for the targetNamespace of the including
1051210494 * schema.
1051310495 */
1051410496 /*
···1051610498 * the components into the including schema and modify the
1051710499 * targetNamespace of those components, do nothing otherwise.
1051810500 * NOTE: This is currently worked-around by compiling the
1051910519- * chameleon for every destinct including targetNamespace; thus
1050110501+ * chameleon for every distinct including targetNamespace; thus
1052010502 * not performant at the moment.
1052110503 * TODO: Check when the namespace in wildcards for chameleons
1052210504 * needs to be converted: before we built wildcard intersections
···10707106891070810690exit:
1070910691 /*
1071010710- * Return the bucket explicitely; this is needed for the
1069210692+ * Return the bucket explicitly; this is needed for the
1071110693 * main schema.
1071210694 */
1071310695 if (bucket != NULL)
···12888128701288912871 ret = 1;
1289012872 /*
1289112891- * If max and min occurances are default (1) then
1287312873+ * If max and min occurrences are default (1) then
1289212874 * simply iterate over the particles of the <sequence>.
1289312875 */
1289412876 if ((particle->minOccurs == 1) && (particle->maxOccurs == 1)) {
···1304713029 particle->minOccurs < 1 ? 0 : particle->minOccurs - 1;
13048130301304913031 /*
1305013050- * use a counter to keep track of the number of transtions
1303213032+ * use a counter to keep track of the number of transitions
1305113033 * which went through the choice.
1305213034 */
1305313035 counter =
···1351213494 * @source: the source wildcard
1351313495 *
1351413496 * Clones the namespace constraints of source
1351513515- * and assignes them to dest.
1349713497+ * and assigns them to dest.
1351613498 * Returns -1 on internal error, 0 otherwise.
1351713499 */
1351813500static int
···1373513717 */
1373613718 xmlSchemaPErr(ctxt, completeWild->node,
1373713719 XML_SCHEMAP_UNION_NOT_EXPRESSIBLE,
1373813738- "The union of the wilcard is not expressible.\n",
1372013720+ "The union of the wildcard is not expressible.\n",
1373913721 NULL, NULL);
1374013722 return(XML_SCHEMAP_UNION_NOT_EXPRESSIBLE);
1374113723 } else if ((!nsFound) && (!absentFound)) {
···1397213954 (curWild->negNsSet->value != NULL)) {
13973139551397413956 xmlSchemaPErr(ctxt, completeWild->node, XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE,
1397513975- "The intersection of the wilcard is not expressible.\n",
1395713957+ "The intersection of the wildcard is not expressible.\n",
1397613958 NULL, NULL);
1397713959 return(XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE);
1397813960 }
···1444314425 * Builds the wildcard and the attribute uses on the given complex type.
1444414426 * Returns -1 if an internal error occurs, 0 otherwise.
1444514427 *
1444614446- * ATTENTION TODO: Experimantally this uses pointer comparisons for
1442814428+ * ATTENTION TODO: Experimentally this uses pointer comparisons for
1444714429 * strings, so recheck this if we start to hardcode some schemata, since
1444814430 * they might not be in the same dict.
1444914431 * NOTE: It is allowed to "extend" the xs:anyType type.
···1464314625 * Evaluates if a type definition contains the given "final".
1464414626 * This does take "finalDefault" into account as well.
1464514627 *
1464614646- * Returns 1 if the type does containt the given "final",
1462814628+ * Returns 1 if the type does contain the given "final",
1464714629 * 0 otherwise.
1464814630 */
1464914631static int
···1468314665 * Schema Component Constraint: Effective Total Range
1468414666 * (all and sequence) + (choice)
1468514667 *
1468614686- * Returns the minimun Effective Total Range.
1466814668+ * Returns the minimum Effective Total Range.
1468714669 */
1468814670static int
1468914671xmlSchemaGetParticleTotalRangeMin(xmlSchemaParticlePtr particle)
···1482714809 * @actxt: a context
1482814810 * @type: the derived simple type definition
1482914811 * @baseType: the base type definition
1483014830- * @subset: the subset of ('restriction', ect.)
1481214812+ * @subset: the subset of ('restriction', etc.)
1483114813 *
1483214814 * Schema Component Constraint:
1483314815 * Type Derivation OK (Simple) (cos-st-derived-OK)
1483414816 *
1483514835- * Checks wheter @type can be validly
1481714817+ * Checks whether @type can be validly
1483614818 * derived from @baseType.
1483714819 *
1483814820 * Returns 0 on success, an positive error code otherwise.
···1484514827{
1484614828 /*
1484714829 * 1 They are the same type definition.
1484814848- * TODO: The identy check might have to be more complex than this.
1483014830+ * TODO: The identity check might have to be more complex than this.
1484914831 */
1485014832 if (type == baseType)
1485114833 return (0);
···1505515037 * @ctxt: the parser context
1505615038 * @name: the name
1505715039 *
1505815058- * Resolvese type definition references
1504015040+ * Resolves type definition references
1505915041 */
1506015042static void
1506115043xmlSchemaResolveTypeReferences(xmlSchemaTypePtr typeDef,
···1613216114 * Calls:
1613316115 * Type Derivation OK (Simple) AND Type Derivation OK (Complex)
1613416116 *
1613516135- * Checks wheter @type can be validly derived from @baseType.
1611716117+ * Checks whether @type can be validly derived from @baseType.
1613616118 *
1613716119 * Returns 0 on success, an positive error code otherwise.
1613816120 */
···1626516247 * if created the type via a schema construction API.
1626616248 */
1626716249 if (base->attributeWildcard != NULL) {
1626816268- if (type->attributeWilcard == NULL) {
1625016250+ if (type->attributeWildcard == NULL) {
1626916251 xmlChar *str = NULL;
16270162521627116253 xmlSchemaCustomErr(ACTXT_CAST pctxt,
···1649416476 * the {content type} is validly derived given the empty
1649516477 * set as defined in Type Derivation OK (Simple) ($3.14.6)."
1649616478 *
1649716497- * ATTENTION TODO: This seems not needed if the type implicitely
1647916479+ * ATTENTION TODO: This seems not needed if the type implicitly
1649816480 * derived from the base type.
1649916481 *
1650016482 */
···1771917701 *
1772017702 * *Patterns*: won't be add here, since they are ORed at
1772117703 * type level and ANDed at ancestor level. This will
1772217722- * happed during validation by walking the base axis
1770417704+ * happen during validation by walking the base axis
1772317705 * of the type.
1772417706 */
1772517707 for (cur = base->facetSet; cur != NULL; cur = cur->next) {
···1831918301 WXS_BASIC_CAST type, NULL,
1832018302 "Internal error: xmlSchemaTypeFixup, "
1832118303 "complex type '%s': the <simpleContent><restriction> "
1832218322- "is missing a <simpleType> child, but was not catched "
1830418304+ "is missing a <simpleType> child, but was not caught "
1832318305 "by xmlSchemaCheckSRCCT()", type->name);
1832418306 goto exit_failure;
1832518307 }
···1833218314 if (baseType->contentTypeDef == NULL) {
1833318315 /*
1833418316 * TODO: Check if this ever happens. xmlSchemaCheckSRCCT
1833518335- * should have catched this already.
1831718317+ * should have caught this already.
1833618318 */
1833718319 xmlSchemaPCustomErr(pctxt,
1833818320 XML_SCHEMAP_INTERNAL,
···1857518557 * NOTE that, although we miss to add an intermediate
1857618558 * <sequence>, this should produce no difference to
1857718559 * neither the regex compilation of the content model,
1857818578- * nor to the complex type contraints.
1856018560+ * nor to the complex type constraints.
1857918561 */
1858018562 particle->children->children =
1858118563 (xmlSchemaTreeItemPtr) baseType->subtypes;
···1900018982 * is defined for model groups but not definitions, but since
1900118983 * there cannot be any circular model groups without a model group
1900218984 * definition (if not using a construction API), we check those
1900319003- * defintions only.
1898518985+ * definitions only.
1900418986 */
1900518987 xmlSchemaPCustomErr(ctxt,
1900618988 XML_SCHEMAP_MG_PROPS_CORRECT_2,
···1907319055 * This one is intended to be used by
1907419056 * xmlSchemaCheckAttrGroupCircular only.
1907519057 *
1907619076- * Returns the circular attribute grou reference, otherwise NULL.
1905819058+ * Returns the circular attribute group reference, otherwise NULL.
1907719059 */
1907819060static xmlSchemaQNameRefPtr
1907919061xmlSchemaCheckAttrGroupCircularRecur(xmlSchemaAttributeGroupPtr ctxtGr,
···1918719169 * @list: the attribute uses
1918819170 *
1918919171 * Substitutes contained attribute group references
1919019190- * for their attribute uses. Wilcards are intersected.
1917219172+ * for their attribute uses. Wildcards are intersected.
1919119173 * Attribute use prohibitions are removed from the list
1919219174 * and returned via the @prohibs list.
1919319175 * Pointlessness of attr. prohibs, if a matching attr. decl
···1936119343 * {attribute wildcard} property
1936219344 *
1936319345 * Substitutes contained attribute group references
1936419364- * for their attribute uses. Wilcards are intersected.
1934619346+ * for their attribute uses. Wildcards are intersected.
1936519347 */
1936619348static int
1936719349xmlSchemaAttributeGroupExpandRefs(xmlSchemaParserCtxtPtr pctxt,
···1938419366 * @attrGr: the attribute group definition
1938519367 *
1938619368 * Substitutes contained attribute group references
1938719387- * for their attribute uses. Wilcards are intersected.
1936919369+ * for their attribute uses. Wildcards are intersected.
1938819370 *
1938919371 * Schema Component Constraint:
1939019372 * Attribute Group Definition Properties Correct (ag-props-correct)
···1952019502 * Attribute Declaration Properties Correct (a-props-correct)
1952119503 *
1952219504 * Validates the value constraints of an attribute declaration/use.
1952319523- * NOTE that this needs the simle type definitions to be already
1952419524- * builded and checked.
1950519505+ * NOTE that this needs the simple type definitions to be already
1950619506+ * built and checked.
1952519507 */
1952619508static int
1952719509xmlSchemaCheckAttrPropsCorrect(xmlSchemaParserCtxtPtr pctxt,
···2050820490 * it's not clear if the referenced component needs to originate
2050920491 * from the <redefine>d schema _document_ or the schema; the latter
2051020492 * would include all imported and included sub-schemas of the
2051120511- * <redefine>d schema. Currenlty we latter approach is used.
2049320493+ * <redefine>d schema. Currently the latter approach is used.
2051220494 * SUPPLEMENT: It seems that the WG moves towards the latter
2051320495 * approach, so we are doing it right.
2051420496 *
···2062320605 * This is the complicated case: we need
2062420606 * to apply src-redefine (7.2.2) at a later
2062520607 * stage, i.e. when attribute group references
2062620626- * have beed expanded and simple types have
2062720627- * beed fixed.
2060820608+ * have been expanded and simple types have
2060920609+ * been fixed.
2062820610 */
2062920611 redef->target = prev;
2063020612 }
···2099920981 * 1. the base axis of type definitions
2100020982 * 2. nested model group definitions
2100120983 * 3. nested attribute group definitions
2100221002- * TODO: check for circual substitution groups.
2098420984+ * TODO: check for circular substitution groups.
2100320985 */
2100420986 for (i = 0; i < nbItems; i++) {
2100520987 item = items[i];
···2108021062 goto exit_error;
2108121063 /*
2108221064 * First compute the variety of simple types. This is needed as
2108321083- * a seperate step, since otherwise we won't be able to detect
2106521065+ * a separate step, since otherwise we won't be able to detect
2108421066 * circular union types in all cases.
2108521067 */
2108621068 for (i = 0; i < nbItems; i++) {
···2114221124 * At this point we need build and check all simple types.
2114321125 */
2114421126 /*
2114521145- * Apply contraints for attribute declarations.
2112721127+ * Apply constraints for attribute declarations.
2114621128 */
2114721129 for (i = 0; i < nbItems; i++) {
2114821130 item = items[i];
···2120721189 goto exit_error;
21208211902120921191 /*
2121021210- * Complex types are builded and checked.
2119221192+ * Complex types are built and checked.
2121121193 */
2121221194 for (i = 0; i < nbItems; i++) {
2121321195 item = con->pending->items[i];
···2132421306 * @ctxt: a schema validation context
2132521307 *
2132621308 * parse a schema definition resource and build an internal
2132721327- * XML Shema struture which can be used to validate instances.
2130921309+ * XML Schema structure which can be used to validate instances.
2132821310 *
2132921311 * Returns the internal XML Schema structure built from the resource or
2133021312 * NULL in case of error
···2142621408exit_failure:
2142721409 /*
2142821410 * Quite verbose, but should catch internal errors, which were
2142921429- * not communitated.
2141121411+ * not communicated.
2143021412 */
2143121413 if (mainSchema) {
2143221414 xmlSchemaFree(mainSchema);
···2189321875 if ((vctxt->inode->node == NULL) ||
2189421876 (vctxt->inode->node->doc == NULL)) {
2189521877 VERROR_INT("xmlSchemaLookupNamespace",
2189621896- "no node or node's doc avaliable");
2187821878+ "no node or node's doc available");
2189721879 return (NULL);
2189821880 }
2189921881 ns = xmlSearchNs(vctxt->inode->node->doc,
···2210622088 xmlSchemaPSVIIDCNodePtr item)
2210722089{
2210822090 /*
2210922109- * Add to gobal list.
2209122091+ * Add to global list.
2211022092 */
2211122093 if (vctxt->idcNodes == NULL) {
2211222094 vctxt->idcNodes = (xmlSchemaPSVIIDCNodePtr *)
···2214722129 xmlSchemaPSVIIDCKeyPtr key)
2214822130{
2214922131 /*
2215022150- * Add to gobal list.
2213222132+ * Add to global list.
2215122133 */
2215222134 if (vctxt->idcKeys == NULL) {
2215322135 vctxt->idcKeys = (xmlSchemaPSVIIDCKeyPtr *)
···2280422786 VERROR(XML_SCHEMAV_CVC_IDC,
2280522787 WXS_BASIC_CAST sto->matcher->aidc->def,
2280622788 "Warning: No precomputed value available, the value "
2280722807- "was either invalid or something strange happend");
2278922789+ "was either invalid or something strange happened");
2280822790 sto->nbHistory--;
2280922791 goto deregister_check;
2281022792 } else {
···2282522807 * <bar>
2282622808 * </scope>
2282722809 *
2282822828- * The size of the list is only dependant on the depth of
2281022810+ * The size of the list is only dependent on the depth of
2282922811 * the tree.
2283022812 * An entry will be NULLed in selector_leave, i.e. when
2283122813 * we hit the target's
···2336623348 * Get/create the IDC binding on this element for the IDC definition.
2336723349 */
2336823350 bind = xmlSchemaIDCAcquireBinding(vctxt, matcher);
2335123351+ if (bind == NULL)
2335223352+ goto internal_error;
23369233532337023354 if (! WXS_ILIST_IS_EMPTY(bind->dupls)) {
2337123355 dupls = (xmlSchemaPSVIIDCNodePtr *) bind->dupls->items;
···2411824102 * @vctxt: the schema validation context
2411924103 *
2412024104 * Creates/reuses and initializes the element info item for
2412124121- * the currect tree depth.
2410524105+ * the current tree depth.
2412224106 *
2412324107 * Returns the element info item or NULL on API or internal errors.
2412424108 */
···2439124375 found = 1;
2439224376 /*
2439324377 * NOTE that for patterns, @value needs to be the
2439424394- * normalized vaule.
2437824378+ * normalized value.
2439524379 */
2439624380 ret = xmlRegexpExec(facetLink->facet->regexp, value);
2439724381 if (ret == 1)
···2466524649 ret = XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1;
2466624650 }
2466724651 }
2466824668- if (fireErrors && (ret > 0))
2465224652+ else if (fireErrors && (ret > 0))
2466924653 xmlSchemaSimpleTypeErr(actxt, ret, node, value, type, 1);
2467024654 } else if (WXS_IS_LIST(type)) {
2467124655···2492824912 else {
2492924913 const xmlChar *nsName = NULL, *local = NULL;
2493024914 /*
2493124931- * TODO: We should report a *warning* that the type was overriden
2491524915+ * TODO: We should report a *warning* that the type was overridden
2493224916 * by the instance.
2493324917 */
2493424918 ACTIVATE_ATTRIBUTE(iattr);
···2634726331 XML_SCHEMA_ELEM_INFO_HAS_ELEM_CONTENT) {
2634826332 ret = XML_SCHEMAV_CVC_ELT_5_2_2_1;
2634926333 VERROR(ret, NULL,
2635026350- "The content must not containt element nodes since "
2633426334+ "The content must not contain element nodes since "
2635126335 "there is a fixed value constraint");
2635226336 goto end_elem;
2635326337 } else {
···2655426538 if (ptype->builtInType == XML_SCHEMAS_ANYTYPE) {
2655526539 /*
2655626540 * Workaround for "anyType": we have currently no content model
2655726557- * assigned for "anyType", so handle it explicitely.
2654126541+ * assigned for "anyType", so handle it explicitly.
2655826542 * "anyType" has an unbounded, lax "any" wildcard.
2655926543 */
2656026544 vctxt->inode->decl = xmlSchemaGetElem(vctxt->schema,
···2662926613 return (-1);
2663026614 }
2663126615 /*
2663226632- * Safety belf for evaluation if the cont. model was already
2661626616+ * Safety belt for evaluation if the cont. model was already
2663326617 * examined to be invalid.
2663426618 */
2663526619 if (pielem->flags & XML_SCHEMA_ELEM_INFO_ERR_BAD_CONTENT) {
···2881828802 *
2881928803 * Internal locator function for the readers
2882028804 *
2882128821- * Returns 0 in case the Schema validation could be (des)activated and
2880528805+ * Returns 0 in case the Schema validation could be (de)activated and
2882228806 * -1 in case of error.
2882328807 */
2882428808static int
+11-9
sdk/lib/3rdparty/libxml2/xmlschemastypes.c
···7070 unsigned int hour :5; /* 0 <= hour <= 24 */
7171 unsigned int min :6; /* 0 <= min <= 59 */
7272 double sec;
7373- unsigned int tz_flag :1; /* is tzo explicitely set? */
7373+ unsigned int tz_flag :1; /* is tzo explicitly set? */
7474 signed int tzo :12; /* -1440 <= tzo <= 1440;
7575 currently only -840 to +840 are needed */
7676};
···11291129#define VALID_HOUR(hr) ((hr >= 0) && (hr <= 23))
11301130#define VALID_MIN(min) ((min >= 0) && (min <= 59))
11311131#define VALID_SEC(sec) ((sec >= 0) && (sec < 60))
11321132-#define VALID_TZO(tzo) ((tzo > -840) && (tzo < 840))
11321132+#define VALID_TZO(tzo) ((tzo >= -840) && (tzo <= 840))
11331133#define IS_LEAP(y) \
11341134 (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0))
11351135···21302130 * @value: the value to check
21312131 * @val: the return computed value
21322132 * @node: the node containing the value
21332133- * flags: flags to control the vlidation
21332133+ * flags: flags to control the validation
21342134 *
21352135 * Check that a value conforms to the lexical space of the atomic type.
21362136 * if true a value is computed and returned in @val.
···21552155 return (-1);
2156215621572157 /*
21582158- * validating a non existant text node is similar to validating
21582158+ * validating a non existent text node is similar to validating
21592159 * an empty one.
21602160 */
21612161 if (value == NULL)
···29252925 if (*value != 0) {
29262926 xmlURIPtr uri;
29272927 xmlChar *tmpval, *cur;
29282928- if (normOnTheFly) {
29282928+ if ((norm == NULL) && (normOnTheFly)) {
29292929 norm = xmlSchemaCollapseString(value);
29302930 if (norm != NULL)
29312931 value = norm;
···30673067 * following cases can arise: (1) the final quantum of
30683068 * encoding input is an integral multiple of 24 bits; here,
30693069 * the final unit of encoded output will be an integral
30703070- * multiple ofindent: Standard input:701: Warning:old style
30703070+ * multiple of indent: Standard input:701: Warning:old style
30713071 * assignment ambiguity in "=*". Assuming "= *" 4 characters
30723072 * with no "=" padding, (2) the final
30733073 * quantum of encoding input is exactly 8 bits; here, the
···36283628 minday = 0;
36293629 maxday = 0;
36303630 } else {
36313631- maxday = 366 * ((myear + 3) / 4) +
36323632- 365 * ((myear - 1) % 4);
36313631+ /* FIXME: This doesn't take leap year exceptions every 100/400 years
36323632+ into account. */
36333633+ maxday = 365 * myear + (myear + 3) / 4;
36343634+ /* FIXME: Needs to be calculated separately */
36333635 minday = maxday - 1;
36343636 }
36353637···3877387938783880 temp = r->mon + carry;
38793881 r->mon = (unsigned int) MODULO_RANGE(temp, 1, 13);
38803880- r->year = r->year + (unsigned int) FQUOTIENT_RANGE(temp, 1, 13);
38823882+ r->year = r->year + (long) FQUOTIENT_RANGE(temp, 1, 13);
38813883 if (r->year == 0) {
38823884 if (temp < 1)
38833885 r->year--;
+3-3
sdk/lib/3rdparty/libxml2/xmlwriter.c
···541541 if (encoding != NULL) {
542542 encoder = xmlFindCharEncodingHandler(encoding);
543543 if (encoder == NULL) {
544544- xmlWriterErrMsg(writer, XML_ERR_NO_MEMORY,
545545- "xmlTextWriterStartDocument : out of memory!\n");
544544+ xmlWriterErrMsg(writer, XML_ERR_UNSUPPORTED_ENCODING,
545545+ "xmlTextWriterStartDocument : unsupported encoding\n");
546546 return -1;
547547 }
548548 }
···801801 * xmlTextWriterEndComment:
802802 * @writer: the xmlTextWriterPtr
803803 *
804804- * End the current xml coment.
804804+ * End the current xml comment.
805805 *
806806 * Returns the bytes written (may be 0 because of buffering) or -1 in case of error
807807 */
+638-1059
sdk/lib/3rdparty/libxml2/xpath.c
···343343 }
344344345345 /*
346346- * Speedup using document order if availble.
346346+ * Speedup using document order if available.
347347 */
348348 if ((node1->type == XML_ELEMENT_NODE) &&
349349 (node2->type == XML_ELEMENT_NODE) &&
···411411 if (node1 == node2->next)
412412 return(-1);
413413 /*
414414- * Speedup using document order if availble.
414414+ * Speedup using document order if available.
415415 */
416416 if ((node1->type == XML_ELEMENT_NODE) &&
417417 (node2->type == XML_ELEMENT_NODE) &&
···435435#endif /* XP_OPTIMIZED_NON_ELEM_COMPARISON */
436436437437/*
438438- * Wrapper for the Timsort argorithm from timsort.h
438438+ * Wrapper for the Timsort algorithm from timsort.h
439439 */
440440#ifdef WITH_TIM_SORT
441441#define SORT_NAME libxml_domnode
···610610 "Invalid or incomplete context\n",
611611 "Stack usage error\n",
612612 "Forbidden variable\n",
613613+ "Operation limit exceeded\n",
614614+ "Recursion limit exceeded\n",
613615 "?? Unknown error ??\n" /* Must be last in the list! */
614616};
615617#define MAXERRNO ((int)(sizeof(xmlXPathErrorMessages) / \
···625627xmlXPathErrMemory(xmlXPathContextPtr ctxt, const char *extra)
626628{
627629 if (ctxt != NULL) {
630630+ xmlResetError(&ctxt->lastError);
628631 if (extra) {
629632 xmlChar buf[200];
630633···747750 xmlXPathErr(ctxt, no);
748751}
749752753753+/**
754754+ * xmlXPathCheckOpLimit:
755755+ * @ctxt: the XPath Parser context
756756+ * @opCount: the number of operations to be added
757757+ *
758758+ * Adds opCount to the running total of operations and returns -1 if the
759759+ * operation limit is exceeded. Returns 0 otherwise.
760760+ */
761761+static int
762762+xmlXPathCheckOpLimit(xmlXPathParserContextPtr ctxt, unsigned long opCount) {
763763+ xmlXPathContextPtr xpctxt = ctxt->context;
764764+765765+ if ((opCount > xpctxt->opLimit) ||
766766+ (xpctxt->opCount > xpctxt->opLimit - opCount)) {
767767+ xpctxt->opCount = xpctxt->opLimit;
768768+ xmlXPathErr(ctxt, XPATH_OP_LIMIT_EXCEEDED);
769769+ return(-1);
770770+ }
771771+772772+ xpctxt->opCount += opCount;
773773+ return(0);
774774+}
775775+776776+#define OP_LIMIT_EXCEEDED(ctxt, n) \
777777+ ((ctxt->context->opLimit != 0) && (xmlXPathCheckOpLimit(ctxt, n) < 0))
778778+750779/************************************************************************
751780 * *
752781 * Utilities *
···10761105 * Returns -1 in case of failure, the index otherwise
10771106 */
10781107static int
10791079-xmlXPathCompExprAdd(xmlXPathCompExprPtr comp, int ch1, int ch2,
11081108+xmlXPathCompExprAdd(xmlXPathParserContextPtr ctxt, int ch1, int ch2,
10801109 xmlXPathOp op, int value,
10811110 int value2, int value3, void *value4, void *value5) {
11111111+ xmlXPathCompExprPtr comp = ctxt->comp;
10821112 if (comp->nbStep >= comp->maxStep) {
10831113 xmlXPathStepOp *real;
1084111410851115 if (comp->maxStep >= XPATH_MAX_STEPS) {
10861086- xmlXPathErrMemory(NULL, "adding step\n");
11161116+ xmlXPathPErrMemory(ctxt, "adding step\n");
10871117 return(-1);
10881118 }
10891119 comp->maxStep *= 2;
···10911121 comp->maxStep * sizeof(xmlXPathStepOp));
10921122 if (real == NULL) {
10931123 comp->maxStep /= 2;
10941094- xmlXPathErrMemory(NULL, "adding step\n");
11241124+ xmlXPathPErrMemory(ctxt, "adding step\n");
10951125 return(-1);
10961126 }
10971127 comp->steps = real;
···11531183}
1154118411551185#define PUSH_FULL_EXPR(op, op1, op2, val, val2, val3, val4, val5) \
11561156- xmlXPathCompExprAdd(ctxt->comp, (op1), (op2), \
11861186+ xmlXPathCompExprAdd(ctxt, (op1), (op2), \
11571187 (op), (val), (val2), (val3), (val4), (val5))
11581188#define PUSH_LONG_EXPR(op, val, val2, val3, val4, val5) \
11591159- xmlXPathCompExprAdd(ctxt->comp, ctxt->comp->last, -1, \
11891189+ xmlXPathCompExprAdd(ctxt, ctxt->comp->last, -1, \
11601190 (op), (val), (val2), (val3), (val4), (val5))
1161119111621192#define PUSH_LEAVE_EXPR(op, val, val2) \
11631163-xmlXPathCompExprAdd(ctxt->comp, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
11931193+xmlXPathCompExprAdd(ctxt, -1, -1, (op), (val), (val2), 0 ,NULL ,NULL)
1164119411651195#define PUSH_UNARY_EXPR(op, ch, val, val2) \
11661166-xmlXPathCompExprAdd(ctxt->comp, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
11961196+xmlXPathCompExprAdd(ctxt, (ch), -1, (op), (val), (val2), 0 ,NULL ,NULL)
1167119711681198#define PUSH_BINARY_EXPR(op, ch1, ch2, val, val2) \
11691169-xmlXPathCompExprAdd(ctxt->comp, (ch1), (ch2), (op), \
11991199+xmlXPathCompExprAdd(ctxt, (ch1), (ch2), (op), \
11701200 (val), (val2), 0 ,NULL ,NULL)
1171120111721202/************************************************************************
···22262256 *
22272257 * @ctxt: the XPath context
22282258 * @active: enables/disables (creates/frees) the cache
22292229- * @value: a value with semantics dependant on @options
22592259+ * @value: a value with semantics dependent on @options
22302260 * @options: options (currently only the value 0 is used)
22312261 *
22322262 * Creates/frees an object cache on the XPath context.
···23862416 {
23872417 xmlXPathObjectPtr ret;
23882418 /*
23892389- * Use the nodset-cache.
24192419+ * Use the nodeset-cache.
23902420 */
23912421 ret = (xmlXPathObjectPtr)
23922422 cache->nodesetObjs->items[--cache->nodesetObjs->number];
···23962426 if ((ret->nodesetval->nodeMax == 0) ||
23972427 (val->type == XML_NAMESPACE_DECL))
23982428 {
24292429+ /* TODO: Check memory error. */
23992430 xmlXPathNodeSetAddUnique(ret->nodesetval, val);
24002431 } else {
24012432 ret->nodesetval->nodeTab[0] = val;
···28422873 * @ctxt: an XPath evaluation context
28432874 * @value: the XPath object
28442875 *
28452845- * Pushes a new XPath object on top of the value stack
28762876+ * Pushes a new XPath object on top of the value stack. If value is NULL,
28772877+ * a memory error is recorded in the parser context.
28462878 *
28472847- * returns the number of items on the value stack
28792879+ * Returns the number of items on the value stack, or -1 in case of error.
28482880 */
28492881int
28502882valuePush(xmlXPathParserContextPtr ctxt, xmlXPathObjectPtr value)
28512883{
28522852- if ((ctxt == NULL) || (value == NULL)) return(-1);
28842884+ if (ctxt == NULL) return(-1);
28852885+ if (value == NULL) {
28862886+ /*
28872887+ * A NULL value typically indicates that a memory allocation failed,
28882888+ * so we set ctxt->error here to propagate the error.
28892889+ */
28902890+ ctxt->error = XPATH_MEMORY_ERROR;
28912891+ return(-1);
28922892+ }
28532893 if (ctxt->valueNr >= ctxt->valueMax) {
28542894 xmlXPathObjectPtr *tmp;
2855289528562896 if (ctxt->valueMax >= XPATH_MAX_STACK_DEPTH) {
28572857- xmlXPathErrMemory(NULL, "XPath stack depth limit reached\n");
28582858- ctxt->error = XPATH_MEMORY_ERROR;
28592859- return (0);
28972897+ xmlXPathPErrMemory(ctxt, "XPath stack depth limit reached\n");
28982898+ return (-1);
28602899 }
28612900 tmp = (xmlXPathObjectPtr *) xmlRealloc(ctxt->valueTab,
28622901 2 * ctxt->valueMax *
28632902 sizeof(ctxt->valueTab[0]));
28642903 if (tmp == NULL) {
28652865- xmlXPathErrMemory(NULL, "pushing value\n");
28662866- ctxt->error = XPATH_MEMORY_ERROR;
28672867- return (0);
29042904+ xmlXPathPErrMemory(ctxt, "pushing value\n");
29052905+ return (-1);
28682906 }
28692907 ctxt->valueMax *= 2;
28702908 ctxt->valueTab = tmp;
···33203358 return(-1);
3321335933223360 /*
33233323- * Speedup using document order if availble.
33613361+ * Speedup using document order if available.
33243362 */
33253363 if ((node1->type == XML_ELEMENT_NODE) &&
33263364 (node2->type == XML_ELEMENT_NODE) &&
···33833421 if (node1 == node2->next)
33843422 return(-1);
33853423 /*
33863386- * Speedup using document order if availble.
34243424+ * Speedup using document order if available.
33873425 */
33883426 if ((node1->type == XML_ELEMENT_NODE) &&
33893427 (node2->type == XML_ELEMENT_NODE) &&
···35473585 if (val->type == XML_NAMESPACE_DECL) {
35483586 xmlNsPtr ns = (xmlNsPtr) val;
3549358735883588+ /* TODO: Check memory error. */
35503589 ret->nodeTab[ret->nodeNr++] =
35513590 xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
35523591 } else
···35563595}
3557359635583597/**
35593559- * xmlXPathNodeSetCreateSize:
35603560- * @size: the initial size of the set
35613561- *
35623562- * Create a new xmlNodeSetPtr of type double and of value @val
35633563- *
35643564- * Returns the newly created object.
35653565- */
35663566-static xmlNodeSetPtr
35673567-xmlXPathNodeSetCreateSize(int size) {
35683568- xmlNodeSetPtr ret;
35693569-35703570- ret = (xmlNodeSetPtr) xmlMalloc(sizeof(xmlNodeSet));
35713571- if (ret == NULL) {
35723572- xmlXPathErrMemory(NULL, "creating nodeset\n");
35733573- return(NULL);
35743574- }
35753575- memset(ret, 0 , (size_t) sizeof(xmlNodeSet));
35763576- if (size < XML_NODESET_DEFAULT)
35773577- size = XML_NODESET_DEFAULT;
35783578- ret->nodeTab = (xmlNodePtr *) xmlMalloc(size * sizeof(xmlNodePtr));
35793579- if (ret->nodeTab == NULL) {
35803580- xmlXPathErrMemory(NULL, "creating nodeset\n");
35813581- xmlFree(ret);
35823582- return(NULL);
35833583- }
35843584- memset(ret->nodeTab, 0 , size * (size_t) sizeof(xmlNodePtr));
35853585- ret->nodeMax = size;
35863586- return(ret);
35873587-}
35883588-35893589-/**
35903598 * xmlXPathNodeSetContains:
35913599 * @cur: the node-set
35923600 * @val: the node
···36843692 cur->nodeMax *= 2;
36853693 cur->nodeTab = temp;
36863694 }
36953695+ /* TODO: Check memory error. */
36873696 cur->nodeTab[cur->nodeNr++] = xmlXPathNodeSetDupNs(node, ns);
36883697 return(0);
36893698}
···37423751 if (val->type == XML_NAMESPACE_DECL) {
37433752 xmlNsPtr ns = (xmlNsPtr) val;
3744375337543754+ /* TODO: Check memory error. */
37453755 cur->nodeTab[cur->nodeNr++] =
37463756 xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
37473757 } else
···37963806 if (val->type == XML_NAMESPACE_DECL) {
37973807 xmlNsPtr ns = (xmlNsPtr) val;
3798380838093809+ /* TODO: Check memory error. */
37993810 cur->nodeTab[cur->nodeNr++] =
38003811 xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
38013812 } else
···38303841 * xmlXPathNodeSetDupNs() to the set; thus a pure
38313842 * memcpy is not possible.
38323843 * If there was a flag on the nodesetval, indicating that
38333833- * some temporary nodes are in, that would be helpfull.
38443844+ * some temporary nodes are in, that would be helpful.
38343845 */
38353846 /*
38363847 * Optimization: Create an equally sized node-set
···39123923 if (n2->type == XML_NAMESPACE_DECL) {
39133924 xmlNsPtr ns = (xmlNsPtr) n2;
3914392539263926+ /* TODO: Check memory error. */
39153927 val1->nodeTab[val1->nodeNr++] =
39163928 xmlXPathNodeSetDupNs((xmlNodePtr) ns->next, ns);
39173929 } else
···39263938 * xmlXPathNodeSetMergeAndClear:
39273939 * @set1: the first NodeSet or NULL
39283940 * @set2: the second NodeSet
39293929- * @hasSet2NsNodes: 1 if set2 contains namespaces nodes
39303941 *
39313931- * Merges two nodesets, all nodes from @set2 are added to @set1
39323932- * if @set1 is NULL, a new set is created and copied from @set2.
39423942+ * Merges two nodesets, all nodes from @set2 are added to @set1.
39333943 * Checks for duplicate nodes. Clears set2.
39343944 *
39353945 * Returns @set1 once extended or NULL in case of error.
39363946 */
39373947static xmlNodeSetPtr
39383938-xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
39393939- int hasNullEntries)
39483948+xmlXPathNodeSetMergeAndClear(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
39403949{
39413941- if ((set1 == NULL) && (hasNullEntries == 0)) {
39423942- /*
39433943- * Note that doing a memcpy of the list, namespace nodes are
39443944- * just assigned to set1, since set2 is cleared anyway.
39453945- */
39463946- set1 = xmlXPathNodeSetCreateSize(set2->nodeNr);
39473947- if (set1 == NULL)
39483948- return(NULL);
39493949- if (set2->nodeNr != 0) {
39503950- memcpy(set1->nodeTab, set2->nodeTab,
39513951- set2->nodeNr * sizeof(xmlNodePtr));
39523952- set1->nodeNr = set2->nodeNr;
39533953- }
39543954- } else {
39503950+ {
39553951 int i, j, initNbSet1;
39563952 xmlNodePtr n1, n2;
39573957-39583958- if (set1 == NULL)
39593959- set1 = xmlXPathNodeSetCreate(NULL);
39603960- if (set1 == NULL)
39613961- return (NULL);
3962395339633954 initNbSet1 = set1->nodeNr;
39643955 for (i = 0;i < set2->nodeNr;i++) {
39653956 n2 = set2->nodeTab[i];
39663966- /*
39673967- * Skip NULLed entries.
39683968- */
39693969- if (n2 == NULL)
39703970- continue;
39713957 /*
39723958 * Skip duplicates.
39733959 */
···40334019 * xmlXPathNodeSetMergeAndClearNoDupls:
40344020 * @set1: the first NodeSet or NULL
40354021 * @set2: the second NodeSet
40364036- * @hasSet2NsNodes: 1 if set2 contains namespaces nodes
40374022 *
40384038- * Merges two nodesets, all nodes from @set2 are added to @set1
40394039- * if @set1 is NULL, a new set is created and copied from @set2.
40404040- * Doesn't chack for duplicate nodes. Clears set2.
40234023+ * Merges two nodesets, all nodes from @set2 are added to @set1.
40244024+ * Doesn't check for duplicate nodes. Clears set2.
40414025 *
40424026 * Returns @set1 once extended or NULL in case of error.
40434027 */
40444028static xmlNodeSetPtr
40454045-xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2,
40464046- int hasNullEntries)
40294029+xmlXPathNodeSetMergeAndClearNoDupls(xmlNodeSetPtr set1, xmlNodeSetPtr set2)
40474030{
40484048- if (set2 == NULL)
40494049- return(set1);
40504050- if ((set1 == NULL) && (hasNullEntries == 0)) {
40514051- /*
40524052- * Note that doing a memcpy of the list, namespace nodes are
40534053- * just assigned to set1, since set2 is cleared anyway.
40544054- */
40554055- set1 = xmlXPathNodeSetCreateSize(set2->nodeNr);
40564056- if (set1 == NULL)
40574057- return(NULL);
40584058- if (set2->nodeNr != 0) {
40594059- memcpy(set1->nodeTab, set2->nodeTab,
40604060- set2->nodeNr * sizeof(xmlNodePtr));
40614061- set1->nodeNr = set2->nodeNr;
40624062- }
40634063- } else {
40314031+ {
40644032 int i;
40654033 xmlNodePtr n2;
40664066-40674067- if (set1 == NULL)
40684068- set1 = xmlXPathNodeSetCreate(NULL);
40694069- if (set1 == NULL)
40704070- return (NULL);
4071403440724035 for (i = 0;i < set2->nodeNr;i++) {
40734036 n2 = set2->nodeTab[i];
40744074- /*
40754075- * Skip NULLed entries.
40764076- */
40774077- if (n2 == NULL)
40784078- continue;
40794037 if (set1->nodeMax == 0) {
40804038 set1->nodeTab = (xmlNodePtr *) xmlMalloc(
40814039 XML_NODESET_DEFAULT * sizeof(xmlNodePtr));
···43464304 memset(ret, 0 , (size_t) sizeof(xmlXPathObject));
43474305 ret->type = XPATH_NODESET;
43484306 ret->boolval = 0;
43074307+ /* TODO: Check memory error. */
43494308 ret->nodesetval = xmlXPathNodeSetCreate(val);
43504309 /* @@ with_ns to check whether namespace nodes should be looked at @@ */
43514310#ifdef XP_DEBUG_OBJ_USAGE
···44064365 ret = xmlXPathNewNodeSet(val->nodeTab[0]);
44074366 if (ret) {
44084367 for (i = 1; i < val->nodeNr; ++i) {
43684368+ /* TODO: Propagate memory error. */
44094369 if (xmlXPathNodeSetAddUnique(ret->nodesetval, val->nodeTab[i])
44104370 < 0) break;
44114371 }
···44774437 if (xmlXPathNodeSetIsEmpty(nodes2))
44784438 return(nodes1);
4479443944404440+ /* TODO: Check memory error. */
44804441 ret = xmlXPathNodeSetCreate(NULL);
44814442 if (xmlXPathNodeSetIsEmpty(nodes1))
44824443 return(ret);
···44864447 for (i = 0; i < l1; i++) {
44874448 cur = xmlXPathNodeSetItem(nodes1, i);
44884449 if (!xmlXPathNodeSetContains(nodes2, cur)) {
44504450+ /* TODO: Propagate memory error. */
44894451 if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
44904452 break;
44914453 }
···45224484 for (i = 0; i < l1; i++) {
45234485 cur = xmlXPathNodeSetItem(nodes1, i);
45244486 if (xmlXPathNodeSetContains(nodes2, cur)) {
44874487+ /* TODO: Propagate memory error. */
45254488 if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
45264489 break;
45274490 }
···45604523 strval = xmlXPathCastNodeToString(cur);
45614524 if (xmlHashLookup(hash, strval) == NULL) {
45624525 xmlHashAddEntry(hash, strval, strval);
45264526+ /* TODO: Propagate memory error. */
45634527 if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
45644528 break;
45654529 } else {
···46534617 cur = xmlXPathNodeSetItem(nodes, i);
46544618 if (cur == node)
46554619 break;
46204620+ /* TODO: Propagate memory error. */
46564621 if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
46574622 break;
46584623 }
···47584723 cur = xmlXPathNodeSetItem(nodes, i);
47594724 if (cur == node)
47604725 break;
47264726+ /* TODO: Propagate memory error. */
47614727 if (xmlXPathNodeSetAddUnique(ret, cur) < 0)
47624728 break;
47634729 }
···54575423 break;
54585424#endif
54595425 case XPATH_NODESET:
54265426+ /* TODO: Check memory error. */
54605427 ret->nodesetval = xmlXPathNodeSetMerge(NULL, val->nodesetval);
54615428 /* Do not deallocate the copied tree value */
54625429 ret->boolval = 0;
···59445911 return(NAN);
59455912 switch (val->type) {
59465913 case XPATH_UNDEFINED:
59475947-#ifdef DEGUB_EXPR
59145914+#ifdef DEBUG_EXPR
59485915 xmlGenericError(xmlGenericErrorContext, "NUMBER: undefined\n");
59495916#endif
59505917 ret = NAN;
···61536120 ret->contextSize = -1;
61546121 ret->proximityPosition = -1;
6155612261236123+ ret->maxDepth = INT_MAX;
61246124+ ret->maxParserDepth = INT_MAX;
61256125+61566126#ifdef XP_DEFAULT_CACHE_ON
61576127 if (xmlXPathContextSetCache(ret, 1, -1, 0) == -1) {
61586128 xmlXPathFreeContext(ret);
···6643661366446614 values2 = (double *) xmlMalloc(ns2->nodeNr * sizeof(double));
66456615 if (values2 == NULL) {
66166616+ /* TODO: Propagate memory error. */
66466617 xmlXPathErrMemory(NULL, "comparing nodesets\n");
66476618 xmlXPathFreeObject(arg1);
66486619 xmlXPathFreeObject(arg2);
···6903687469046875 values1 = (xmlChar **) xmlMalloc(ns1->nodeNr * sizeof(xmlChar *));
69056876 if (values1 == NULL) {
68776877+ /* TODO: Propagate memory error. */
69066878 xmlXPathErrMemory(NULL, "comparing nodesets\n");
69076879 return(0);
69086880 }
69096881 hashs1 = (unsigned int *) xmlMalloc(ns1->nodeNr * sizeof(unsigned int));
69106882 if (hashs1 == NULL) {
68836883+ /* TODO: Propagate memory error. */
69116884 xmlXPathErrMemory(NULL, "comparing nodesets\n");
69126885 xmlFree(values1);
69136886 return(0);
···69156888 memset(values1, 0, ns1->nodeNr * sizeof(xmlChar *));
69166889 values2 = (xmlChar **) xmlMalloc(ns2->nodeNr * sizeof(xmlChar *));
69176890 if (values2 == NULL) {
68916891+ /* TODO: Propagate memory error. */
69186892 xmlXPathErrMemory(NULL, "comparing nodesets\n");
69196893 xmlFree(hashs1);
69206894 xmlFree(values1);
···69226896 }
69236897 hashs2 = (unsigned int *) xmlMalloc(ns2->nodeNr * sizeof(unsigned int));
69246898 if (hashs2 == NULL) {
68996899+ /* TODO: Propagate memory error. */
69256900 xmlXPathErrMemory(NULL, "comparing nodesets\n");
69266901 xmlFree(hashs1);
69276902 xmlFree(values1);
···75517526 * The numeric operators convert their operands to numbers as if
75527527 * by calling the number function.
75537528 */
75297529+ATTRIBUTE_NO_SANITIZE("float-divide-by-zero")
75547530void
75557531xmlXPathDivValues(xmlXPathParserContextPtr ctxt) {
75567532 xmlXPathObjectPtr arg;
···76237599 * Used for merging node sets in xmlXPathCollectAndTest().
76247600 */
76257601typedef xmlNodeSetPtr (*xmlXPathNodeSetMergeFunction)
76267626- (xmlNodeSetPtr, xmlNodeSetPtr, int);
76027602+ (xmlNodeSetPtr, xmlNodeSetPtr);
762776037628760476297605/**
···8562853885638539 if ((cur == NULL) || (cur->nodesetval == NULL))
85648540 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
85658565- else if ((cur->type == XPATH_NODESET) || (cur->type == XPATH_XSLT_TREE)) {
85418541+ else
85668542 valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context,
85678543 (double) cur->nodesetval->nodeNr));
85688568- } else {
85698569- if ((cur->nodesetval->nodeNr != 1) ||
85708570- (cur->nodesetval->nodeTab == NULL)) {
85718571- valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) 0));
85728572- } else {
85738573- xmlNodePtr tmp;
85748574- int i = 0;
85758575-85768576- tmp = cur->nodesetval->nodeTab[0];
85778577- if ((tmp != NULL) && (tmp->type != XML_NAMESPACE_DECL)) {
85788578- tmp = tmp->children;
85798579- while (tmp != NULL) {
85808580- tmp = tmp->next;
85818581- i++;
85828582- }
85838583- }
85848584- valuePush(ctxt, xmlXPathCacheNewFloat(ctxt->context, (double) i));
85858585- }
85868586- }
85878544 xmlXPathReleaseObject(ctxt->context, cur);
85888545}
85898546···86218578 * We used to check the fact that the value passed
86228579 * was an NCName, but this generated much troubles for
86238580 * me and Aleksey Sanin, people blatantly violated that
86248624- * constaint, like Visa3D spec.
85818581+ * constraint, like Visa3D spec.
86258582 * if (xmlValidateNCName(ID, 1) == 0)
86268583 */
86278584 attr = xmlGetID(doc, ID);
···86328589 elem = (xmlNodePtr) attr;
86338590 else
86348591 elem = NULL;
85928592+ /* TODO: Check memory error. */
86358593 if (elem != NULL)
86368594 xmlXPathNodeSetAdd(ret, elem);
86378595 }
···86758633 xmlNodeSetPtr ns;
86768634 int i;
8677863586368636+ /* TODO: Check memory error. */
86788637 ret = xmlXPathNodeSetCreate(NULL);
86798679- /*
86808680- * FIXME -- in an out-of-memory condition this will behave badly.
86818681- * The solution is not clear -- we already popped an item from
86828682- * ctxt, so the object is in a corrupt state.
86838683- */
8684863886858639 if (obj->nodesetval != NULL) {
86868640 for (i = 0; i < obj->nodesetval->nodeNr; i++) {
86878641 tokens =
86888642 xmlXPathCastNodeToString(obj->nodesetval->nodeTab[i]);
86898643 ns = xmlXPathGetElementsByIds(ctxt->context->doc, tokens);
86448644+ /* TODO: Check memory error. */
86908645 ret = xmlXPathNodeSetMerge(ret, ns);
86918646 xmlXPathFreeNodeSet(ns);
86928647 if (tokens != NULL)
···86988653 return;
86998654 }
87008655 obj = xmlXPathCacheConvertString(ctxt->context, obj);
86568656+ if (obj == NULL) return;
87018657 ret = xmlXPathGetElementsByIds(ctxt->context->doc, obj->stringval);
87028658 valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, ret));
87038659 xmlXPathReleaseObject(ctxt->context, obj);
···91359091xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs) {
91369092 xmlXPathObjectPtr str, start, len;
91379093 double le=0, in;
91389138- int i, l, m;
91399139- xmlChar *ret;
90949094+ int i = 1, j = INT_MAX;
9140909591419096 if (nargs < 2) {
91429097 CHECK_ARITY(2);
···91639118 CAST_TO_STRING;
91649119 CHECK_TYPE(XPATH_STRING);
91659120 str = valuePop(ctxt);
91669166- m = xmlUTF8Strlen((const unsigned char *)str->stringval);
9167912191689168- /*
91699169- * If last pos not present, calculate last position
91709170- */
91719171- if (nargs != 3) {
91729172- le = (double)m;
91739173- if (in < 1.0)
91749174- in = 1.0;
91229122+ if (!(in < INT_MAX)) { /* Logical NOT to handle NaNs */
91239123+ i = INT_MAX;
91249124+ } else if (in >= 1.0) {
91259125+ i = (int)in;
91269126+ if (in - floor(in) >= 0.5)
91279127+ i += 1;
91759128 }
9176912991779177- /* Need to check for the special cases where either
91789178- * the index is NaN, the length is NaN, or both
91799179- * arguments are infinity (relying on Inf + -Inf = NaN)
91809180- */
91819181- if (!xmlXPathIsInf(in) && !xmlXPathIsNaN(in + le)) {
91829182- /*
91839183- * To meet the requirements of the spec, the arguments
91849184- * must be converted to integer format before
91859185- * initial index calculations are done
91869186- *
91879187- * First we go to integer form, rounding up
91889188- * and checking for special cases
91899189- */
91909190- i = (int) in;
91919191- if (((double)i)+0.5 <= in) i++;
91309130+ if (nargs == 3) {
91319131+ double rin, rle, end;
9192913291939193- if (xmlXPathIsInf(le) == 1) {
91949194- l = m;
91959195- if (i < 1)
91969196- i = 1;
91979197- }
91989198- else if (xmlXPathIsInf(le) == -1 || le < 0.0)
91999199- l = 0;
92009200- else {
92019201- l = (int) le;
92029202- if (((double)l)+0.5 <= le) l++;
92039203- }
91339133+ rin = floor(in);
91349134+ if (in - rin >= 0.5)
91359135+ rin += 1.0;
9204913692059205- /* Now we normalize inidices */
92069206- i -= 1;
92079207- l += i;
92089208- if (i < 0)
92099209- i = 0;
92109210- if (l > m)
92119211- l = m;
91379137+ rle = floor(le);
91389138+ if (le - rle >= 0.5)
91399139+ rle += 1.0;
9212914092139213- /* number of chars to copy */
92149214- l -= i;
92159215-92169216- ret = xmlUTF8Strsub(str->stringval, i, l);
92179217- }
92189218- else {
92199219- ret = NULL;
91419141+ end = rin + rle;
91429142+ if (!(end >= 1.0)) { /* Logical NOT to handle NaNs */
91439143+ j = 1;
91449144+ } else if (end < INT_MAX) {
91459145+ j = (int)end;
91469146+ }
92209147 }
92219221- if (ret == NULL)
92229222- valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
92239223- else {
91489148+91499149+ if (i < j) {
91509150+ xmlChar *ret = xmlUTF8Strsub(str->stringval, i - 1, j - i);
92249151 valuePush(ctxt, xmlXPathCacheNewString(ctxt->context, ret));
92259152 xmlFree(ret);
91539153+ } else {
91549154+ valuePush(ctxt, xmlXPathCacheNewCString(ctxt->context, ""));
92269155 }
91569156+92279157 xmlXPathReleaseObject(ctxt->context, str);
92289158}
92299159···96829612 CAST_TO_NUMBER;
96839613 CHECK_TYPE(XPATH_NUMBER);
9684961496159615+#ifdef _AIX
96169616+ /* Work around buggy ceil() function on AIX */
96179617+ ctxt->value->floatval = copysign(ceil(ctxt->value->floatval), ctxt->value->floatval);
96189618+#else
96859619 ctxt->value->floatval = ceil(ctxt->value->floatval);
96209620+#endif
96869621}
9687962296889623/**
···99999934 (IS_COMBINING(c)) ||
100009935 (IS_EXTENDER(c))) {
100019936 if (len + 10 > max) {
99379937+ xmlChar *tmp;
100029938 if (max > XML_MAX_NAME_LENGTH) {
99399939+ xmlFree(buffer);
100039940 XP_ERRORNULL(XPATH_EXPR_ERROR);
100049941 }
100059942 max *= 2;
1000610006- buffer = (xmlChar *) xmlRealloc(buffer,
1000710007- max * sizeof(xmlChar));
1000810008- if (buffer == NULL) {
99439943+ tmp = (xmlChar *) xmlRealloc(buffer,
99449944+ max * sizeof(xmlChar));
99459945+ if (tmp == NULL) {
99469946+ xmlFree(buffer);
100099947 XP_ERRORNULL(XPATH_MEMORY_ERROR);
100109948 }
99499949+ buffer = tmp;
100119950 }
100129951 COPY_BUF(l,buffer,len,c);
100139952 NEXTL(l);
···1089910838 xmlXPathCompAdditiveExpr(ctxt);
1090010839 CHECK_ERROR;
1090110840 SKIP_BLANKS;
1090210902- while ((CUR == '<') ||
1090310903- (CUR == '>') ||
1090410904- ((CUR == '<') && (NXT(1) == '=')) ||
1090510905- ((CUR == '>') && (NXT(1) == '='))) {
1084110841+ while ((CUR == '<') || (CUR == '>')) {
1090610842 int inf, strict;
1090710843 int op1 = ctxt->comp->last;
1090810844···1099510931 */
1099610932static void
1099710933xmlXPathCompileExpr(xmlXPathParserContextPtr ctxt, int sort) {
1093410934+ xmlXPathContextPtr xpctxt = ctxt->context;
1093510935+1093610936+ if (xpctxt != NULL) {
1093710937+ if (xpctxt->depth >= xpctxt->maxParserDepth)
1093810938+ XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED);
1093910939+ xpctxt->depth += 1;
1094010940+ }
1094110941+1099810942 xmlXPathCompAndExpr(ctxt);
1099910943 CHECK_ERROR;
1100010944 SKIP_BLANKS;
···1101610960 */
1101710961 PUSH_UNARY_EXPR(XPATH_OP_SORT, ctxt->comp->last , 0, 0);
1101810962 }
1096310963+1096410964+ if (xpctxt != NULL)
1096510965+ xpctxt->depth -= 1;
1101910966}
11020109671102110968/**
···1163411581}
1163511582#endif /* DEBUG_STEP */
11636115831163711637-static int
1163811638-xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
1163911639- xmlXPathStepOpPtr op,
1164011640- xmlNodeSetPtr set,
1164111641- int contextSize,
1164211642- int hasNsNodes)
1158411584+/**
1158511585+ * xmlXPathNodeSetFilter:
1158611586+ * @ctxt: the XPath Parser context
1158711587+ * @set: the node set to filter
1158811588+ * @filterOpIndex: the index of the predicate/filter op
1158911589+ * @minPos: minimum position in the filtered set (1-based)
1159011590+ * @maxPos: maximum position in the filtered set (1-based)
1159111591+ * @hasNsNodes: true if the node set may contain namespace nodes
1159211592+ *
1159311593+ * Filter a node set, keeping only nodes for which the predicate expression
1159411594+ * matches. Afterwards, keep only nodes between minPos and maxPos in the
1159511595+ * filtered result.
1159611596+ */
1159711597+static void
1159811598+xmlXPathNodeSetFilter(xmlXPathParserContextPtr ctxt,
1159911599+ xmlNodeSetPtr set,
1160011600+ int filterOpIndex,
1160111601+ int minPos, int maxPos,
1160211602+ int hasNsNodes)
1164311603{
1164411644- if (op->ch1 != -1) {
1164511645- xmlXPathCompExprPtr comp = ctxt->comp;
1164611646- /*
1164711647- * Process inner predicates first.
1164811648- */
1164911649- if (comp->steps[op->ch1].op != XPATH_OP_PREDICATE) {
1165011650- /*
1165111651- * TODO: raise an internal error.
1165211652- */
1165311653- }
1165411654- contextSize = xmlXPathCompOpEvalPredicate(ctxt,
1165511655- &comp->steps[op->ch1], set, contextSize, hasNsNodes);
1165611656- CHECK_ERROR0;
1165711657- if (contextSize <= 0)
1165811658- return(0);
1160411604+ xmlXPathContextPtr xpctxt;
1160511605+ xmlNodePtr oldnode;
1160611606+ xmlDocPtr olddoc;
1160711607+ xmlXPathStepOpPtr filterOp;
1160811608+ int oldcs, oldpp;
1160911609+ int i, j, pos;
1161011610+1161111611+ if ((set == NULL) || (set->nodeNr == 0))
1161211612+ return;
1161311613+1161411614+ /*
1161511615+ * Check if the node set contains a sufficient number of nodes for
1161611616+ * the requested range.
1161711617+ */
1161811618+ if (set->nodeNr < minPos) {
1161911619+ xmlXPathNodeSetClear(set, hasNsNodes);
1162011620+ return;
1165911621 }
1166011660- if (op->ch2 != -1) {
1166111661- xmlXPathContextPtr xpctxt = ctxt->context;
1166211662- xmlNodePtr contextNode, oldContextNode;
1166311663- xmlDocPtr oldContextDoc;
1166411664- int oldcs, oldpp;
1166511665- int i, res, contextPos = 0, newContextSize;
1166611666- xmlXPathStepOpPtr exprOp;
1166711667- xmlXPathObjectPtr contextObj = NULL, exprRes = NULL;
1162211622+1162311623+ xpctxt = ctxt->context;
1162411624+ oldnode = xpctxt->node;
1162511625+ olddoc = xpctxt->doc;
1162611626+ oldcs = xpctxt->contextSize;
1162711627+ oldpp = xpctxt->proximityPosition;
1162811628+ filterOp = &ctxt->comp->steps[filterOpIndex];
1162911629+1163011630+ xpctxt->contextSize = set->nodeNr;
1163111631+1163211632+ for (i = 0, j = 0, pos = 1; i < set->nodeNr; i++) {
1163311633+ xmlNodePtr node = set->nodeTab[i];
1163411634+ int res;
11668116351166911669-#ifdef LIBXML_XPTR_ENABLED
1167011670- /*
1167111671- * URGENT TODO: Check the following:
1167211672- * We don't expect location sets if evaluating prediates, right?
1167311673- * Only filters should expect location sets, right?
1167411674- */
1167511675-#endif
1167611676- /*
1167711677- * SPEC XPath 1.0:
1167811678- * "For each node in the node-set to be filtered, the
1167911679- * PredicateExpr is evaluated with that node as the
1168011680- * context node, with the number of nodes in the
1168111681- * node-set as the context size, and with the proximity
1168211682- * position of the node in the node-set with respect to
1168311683- * the axis as the context position;"
1168411684- * @oldset is the node-set" to be filtered.
1168511685- *
1168611686- * SPEC XPath 1.0:
1168711687- * "only predicates change the context position and
1168811688- * context size (see [2.4 Predicates])."
1168911689- * Example:
1169011690- * node-set context pos
1169111691- * nA 1
1169211692- * nB 2
1169311693- * nC 3
1169411694- * After applying predicate [position() > 1] :
1169511695- * node-set context pos
1169611696- * nB 1
1169711697- * nC 2
1169811698- */
1169911699- oldContextNode = xpctxt->node;
1170011700- oldContextDoc = xpctxt->doc;
1170111701- oldcs = xpctxt->contextSize;
1170211702- oldpp = xpctxt->proximityPosition;
1170311703- /*
1170411704- * Get the expression of this predicate.
1170511705- */
1170611706- exprOp = &ctxt->comp->steps[op->ch2];
1170711707- newContextSize = 0;
1170811708- for (i = 0; i < set->nodeNr; i++) {
1170911709- if (set->nodeTab[i] == NULL)
1171011710- continue;
1163611636+ xpctxt->node = node;
1163711637+ xpctxt->proximityPosition = i + 1;
11711116381171211712- contextNode = set->nodeTab[i];
1171311713- xpctxt->node = contextNode;
1171411714- xpctxt->contextSize = contextSize;
1171511715- xpctxt->proximityPosition = ++contextPos;
1163911639+ /*
1164011640+ * Also set the xpath document in case things like
1164111641+ * key() are evaluated in the predicate.
1164211642+ *
1164311643+ * TODO: Get real doc for namespace nodes.
1164411644+ */
1164511645+ if ((node->type != XML_NAMESPACE_DECL) &&
1164611646+ (node->doc != NULL))
1164711647+ xpctxt->doc = node->doc;
11716116481171711717- /*
1171811718- * Also set the xpath document in case things like
1171911719- * key() are evaluated in the predicate.
1172011720- */
1172111721- if ((contextNode->type != XML_NAMESPACE_DECL) &&
1172211722- (contextNode->doc != NULL))
1172311723- xpctxt->doc = contextNode->doc;
1172411724- /*
1172511725- * Evaluate the predicate expression with 1 context node
1172611726- * at a time; this node is packaged into a node set; this
1172711727- * node set is handed over to the evaluation mechanism.
1172811728- */
1172911729- if (contextObj == NULL)
1173011730- contextObj = xmlXPathCacheNewNodeSet(xpctxt, contextNode);
1173111731- else {
1173211732- if (xmlXPathNodeSetAddUnique(contextObj->nodesetval,
1173311733- contextNode) < 0) {
1173411734- ctxt->error = XPATH_MEMORY_ERROR;
1173511735- goto evaluation_exit;
1173611736- }
1173711737- }
1164911649+ res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1);
11738116501173911739- valuePush(ctxt, contextObj);
1165111651+ if (ctxt->error != XPATH_EXPRESSION_OK)
1165211652+ goto exit;
1165311653+ if (res < 0) {
1165411654+ /* Shouldn't happen */
1165511655+ xmlXPathErr(ctxt, XPATH_EXPR_ERROR);
1165611656+ goto exit;
1165711657+ }
11740116581174111741- res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
1165911659+ if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) {
1166011660+ if (i != j) {
1166111661+ set->nodeTab[j] = node;
1166211662+ set->nodeTab[i] = NULL;
1166311663+ }
11742116641174311743- if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
1174411744- xmlXPathNodeSetClear(set, hasNsNodes);
1174511745- newContextSize = 0;
1174611746- goto evaluation_exit;
1174711747- }
1166511665+ j += 1;
1166611666+ } else {
1166711667+ /* Remove the entry from the initial node set. */
1166811668+ set->nodeTab[i] = NULL;
1166911669+ if (node->type == XML_NAMESPACE_DECL)
1167011670+ xmlXPathNodeSetFreeNs((xmlNsPtr) node);
1167111671+ }
11748116721174911749- if (res != 0) {
1175011750- newContextSize++;
1175111751- } else {
1175211752- /*
1175311753- * Remove the entry from the initial node set.
1175411754- */
1175511755- set->nodeTab[i] = NULL;
1175611756- if (contextNode->type == XML_NAMESPACE_DECL)
1175711757- xmlXPathNodeSetFreeNs((xmlNsPtr) contextNode);
1175811758- }
1175911759- if (ctxt->value == contextObj) {
1176011760- /*
1176111761- * Don't free the temporary XPath object holding the
1176211762- * context node, in order to avoid massive recreation
1176311763- * inside this loop.
1176411764- */
1176511765- valuePop(ctxt);
1176611766- xmlXPathNodeSetClear(contextObj->nodesetval, hasNsNodes);
1176711767- } else {
1176811768- /*
1176911769- * TODO: The object was lost in the evaluation machinery.
1177011770- * Can this happen? Maybe in internal-error cases.
1177111771- */
1177211772- contextObj = NULL;
1177311773- }
1177411774- }
1167311673+ if (res != 0) {
1167411674+ if (pos == maxPos) {
1167511675+ /* Clear remaining nodes and exit loop. */
1167611676+ if (hasNsNodes) {
1167711677+ for (i++; i < set->nodeNr; i++) {
1167811678+ node = set->nodeTab[i];
1167911679+ if ((node != NULL) &&
1168011680+ (node->type == XML_NAMESPACE_DECL))
1168111681+ xmlXPathNodeSetFreeNs((xmlNsPtr) node);
1168211682+ }
1168311683+ }
1168411684+ break;
1168511685+ }
11775116861177611776- if (contextObj != NULL) {
1177711777- if (ctxt->value == contextObj)
1177811778- valuePop(ctxt);
1177911779- xmlXPathReleaseObject(xpctxt, contextObj);
1178011780- }
1178111781-evaluation_exit:
1178211782- if (exprRes != NULL)
1178311783- xmlXPathReleaseObject(ctxt->context, exprRes);
1178411784- /*
1178511785- * Reset/invalidate the context.
1178611786- */
1178711787- xpctxt->node = oldContextNode;
1178811788- xpctxt->doc = oldContextDoc;
1178911789- xpctxt->contextSize = oldcs;
1179011790- xpctxt->proximityPosition = oldpp;
1179111791- return(newContextSize);
1168711687+ pos += 1;
1168811688+ }
1179211689 }
1179311793- return(contextSize);
1179411794-}
1169011690+1169111691+ set->nodeNr = j;
1169211692+1169311693+ /* If too many elements were removed, shrink table to preserve memory. */
1169411694+ if ((set->nodeMax > XML_NODESET_DEFAULT) &&
1169511695+ (set->nodeNr < set->nodeMax / 2)) {
1169611696+ xmlNodePtr *tmp;
1169711697+ int nodeMax = set->nodeNr;
11795116981179611796-static int
1179711797-xmlXPathCompOpEvalPositionalPredicate(xmlXPathParserContextPtr ctxt,
1179811798- xmlXPathStepOpPtr op,
1179911799- xmlNodeSetPtr set,
1180011800- int contextSize,
1180111801- int minPos,
1180211802- int maxPos,
1180311803- int hasNsNodes)
1180411804-{
1180511805- if (op->ch1 != -1) {
1180611806- xmlXPathCompExprPtr comp = ctxt->comp;
1180711807- if (comp->steps[op->ch1].op != XPATH_OP_PREDICATE) {
1180811808- /*
1180911809- * TODO: raise an internal error.
1181011810- */
1181111811- }
1181211812- contextSize = xmlXPathCompOpEvalPredicate(ctxt,
1181311813- &comp->steps[op->ch1], set, contextSize, hasNsNodes);
1181411814- CHECK_ERROR0;
1181511815- if (contextSize <= 0)
1181611816- return(0);
1181711817- }
1181811818- /*
1181911819- * Check if the node set contains a sufficient number of nodes for
1182011820- * the requested range.
1182111821- */
1182211822- if (contextSize < minPos) {
1182311823- xmlXPathNodeSetClear(set, hasNsNodes);
1182411824- return(0);
1169911699+ if (nodeMax < XML_NODESET_DEFAULT)
1170011700+ nodeMax = XML_NODESET_DEFAULT;
1170111701+ tmp = (xmlNodePtr *) xmlRealloc(set->nodeTab,
1170211702+ nodeMax * sizeof(xmlNodePtr));
1170311703+ if (tmp == NULL) {
1170411704+ xmlXPathPErrMemory(ctxt, "shrinking nodeset\n");
1170511705+ } else {
1170611706+ set->nodeTab = tmp;
1170711707+ set->nodeMax = nodeMax;
1170811708+ }
1182511709 }
1182611826- if (op->ch2 == -1) {
1182711827- /*
1182811828- * TODO: Can this ever happen?
1182911829- */
1183011830- return (contextSize);
1183111831- } else {
1183211832- xmlDocPtr oldContextDoc;
1183311833- int oldcs, oldpp;
1183411834- int i, pos = 0, newContextSize = 0, contextPos = 0, res;
1183511835- xmlXPathStepOpPtr exprOp;
1183611836- xmlXPathObjectPtr contextObj = NULL, exprRes = NULL;
1183711837- xmlNodePtr oldContextNode, contextNode = NULL;
1183811838- xmlXPathContextPtr xpctxt = ctxt->context;
1183911839- int frame;
1171011710+1171111711+exit:
1171211712+ xpctxt->node = oldnode;
1171311713+ xpctxt->doc = olddoc;
1171411714+ xpctxt->contextSize = oldcs;
1171511715+ xpctxt->proximityPosition = oldpp;
1171611716+}
11840117171184111718#ifdef LIBXML_XPTR_ENABLED
1184211842- /*
1184311843- * URGENT TODO: Check the following:
1184411844- * We don't expect location sets if evaluating prediates, right?
1184511845- * Only filters should expect location sets, right?
1184611846- */
1184711847-#endif /* LIBXML_XPTR_ENABLED */
1171911719+/**
1172011720+ * xmlXPathLocationSetFilter:
1172111721+ * @ctxt: the XPath Parser context
1172211722+ * @locset: the location set to filter
1172311723+ * @filterOpIndex: the index of the predicate/filter op
1172411724+ * @minPos: minimum position in the filtered set (1-based)
1172511725+ * @maxPos: maximum position in the filtered set (1-based)
1172611726+ *
1172711727+ * Filter a location set, keeping only nodes for which the predicate
1172811728+ * expression matches. Afterwards, keep only nodes between minPos and maxPos
1172911729+ * in the filtered result.
1173011730+ */
1173111731+static void
1173211732+xmlXPathLocationSetFilter(xmlXPathParserContextPtr ctxt,
1173311733+ xmlLocationSetPtr locset,
1173411734+ int filterOpIndex,
1173511735+ int minPos, int maxPos)
1173611736+{
1173711737+ xmlXPathContextPtr xpctxt;
1173811738+ xmlNodePtr oldnode;
1173911739+ xmlDocPtr olddoc;
1174011740+ xmlXPathStepOpPtr filterOp;
1174111741+ int oldcs, oldpp;
1174211742+ int i, j, pos;
11848117431184911849- /*
1185011850- * Save old context.
1185111851- */
1185211852- oldContextNode = xpctxt->node;
1185311853- oldContextDoc = xpctxt->doc;
1185411854- oldcs = xpctxt->contextSize;
1185511855- oldpp = xpctxt->proximityPosition;
1185611856- /*
1185711857- * Get the expression of this predicate.
1185811858- */
1185911859- exprOp = &ctxt->comp->steps[op->ch2];
1186011860- for (i = 0; i < set->nodeNr; i++) {
1186111861- xmlXPathObjectPtr tmp;
1174411744+ if ((locset == NULL) || (locset->locNr == 0) || (filterOpIndex == -1))
1174511745+ return;
11862117461186311863- if (set->nodeTab[i] == NULL)
1186411864- continue;
1174711747+ xpctxt = ctxt->context;
1174811748+ oldnode = xpctxt->node;
1174911749+ olddoc = xpctxt->doc;
1175011750+ oldcs = xpctxt->contextSize;
1175111751+ oldpp = xpctxt->proximityPosition;
1175211752+ filterOp = &ctxt->comp->steps[filterOpIndex];
11865117531186611866- contextNode = set->nodeTab[i];
1186711867- xpctxt->node = contextNode;
1186811868- xpctxt->contextSize = contextSize;
1186911869- xpctxt->proximityPosition = ++contextPos;
1175411754+ xpctxt->contextSize = locset->locNr;
11870117551187111871- /*
1187211872- * Initialize the new set.
1187311873- * Also set the xpath document in case things like
1187411874- * key() evaluation are attempted on the predicate
1187511875- */
1187611876- if ((contextNode->type != XML_NAMESPACE_DECL) &&
1187711877- (contextNode->doc != NULL))
1187811878- xpctxt->doc = contextNode->doc;
1187911879- /*
1188011880- * Evaluate the predicate expression with 1 context node
1188111881- * at a time; this node is packaged into a node set; this
1188211882- * node set is handed over to the evaluation mechanism.
1188311883- */
1188411884- if (contextObj == NULL)
1188511885- contextObj = xmlXPathCacheNewNodeSet(xpctxt, contextNode);
1188611886- else {
1188711887- if (xmlXPathNodeSetAddUnique(contextObj->nodesetval,
1188811888- contextNode) < 0) {
1188911889- ctxt->error = XPATH_MEMORY_ERROR;
1189011890- goto evaluation_exit;
1189111891- }
1189211892- }
1175611756+ for (i = 0, j = 0, pos = 1; i < locset->locNr; i++) {
1175711757+ xmlNodePtr contextNode = locset->locTab[i]->user;
1175811758+ int res;
1175911759+1176011760+ xpctxt->node = contextNode;
1176111761+ xpctxt->proximityPosition = i + 1;
1176211762+1176311763+ /*
1176411764+ * Also set the xpath document in case things like
1176511765+ * key() are evaluated in the predicate.
1176611766+ *
1176711767+ * TODO: Get real doc for namespace nodes.
1176811768+ */
1176911769+ if ((contextNode->type != XML_NAMESPACE_DECL) &&
1177011770+ (contextNode->doc != NULL))
1177111771+ xpctxt->doc = contextNode->doc;
1177211772+1177311773+ res = xmlXPathCompOpEvalToBoolean(ctxt, filterOp, 1);
1177411774+1177511775+ if (ctxt->error != XPATH_EXPRESSION_OK)
1177611776+ goto exit;
1177711777+ if (res < 0) {
1177811778+ /* Shouldn't happen */
1177911779+ xmlXPathErr(ctxt, XPATH_EXPR_ERROR);
1178011780+ goto exit;
1178111781+ }
11893117821189411894- valuePush(ctxt, contextObj);
1189511895- frame = xmlXPathSetFrame(ctxt);
1189611896- res = xmlXPathCompOpEvalToBoolean(ctxt, exprOp, 1);
1189711897- xmlXPathPopFrame(ctxt, frame);
1189811898- tmp = valuePop(ctxt);
1178311783+ if ((res != 0) && ((pos >= minPos) && (pos <= maxPos))) {
1178411784+ if (i != j) {
1178511785+ locset->locTab[j] = locset->locTab[i];
1178611786+ locset->locTab[i] = NULL;
1178711787+ }
11899117881190011900- if ((ctxt->error != XPATH_EXPRESSION_OK) || (res == -1)) {
1190111901- while (tmp != contextObj) {
1190211902- /*
1190311903- * Free up the result
1190411904- * then pop off contextObj, which will be freed later
1190511905- */
1190611906- xmlXPathReleaseObject(xpctxt, tmp);
1190711907- tmp = valuePop(ctxt);
1178911789+ j += 1;
1179011790+ } else {
1179111791+ /* Remove the entry from the initial location set. */
1179211792+ xmlXPathFreeObject(locset->locTab[i]);
1179311793+ locset->locTab[i] = NULL;
1179411794+ }
1179511795+1179611796+ if (res != 0) {
1179711797+ if (pos == maxPos) {
1179811798+ /* Clear remaining nodes and exit loop. */
1179911799+ for (i++; i < locset->locNr; i++) {
1180011800+ xmlXPathFreeObject(locset->locTab[i]);
1190811801 }
1190911909- goto evaluation_error;
1191011910- }
1191111911- /* push the result back onto the stack */
1191211912- valuePush(ctxt, tmp);
1180211802+ break;
1180311803+ }
1180411804+1180511805+ pos += 1;
1180611806+ }
1180711807+ }
1180811808+1180911809+ locset->locNr = j;
11913118101191411914- if (res)
1191511915- pos++;
1181111811+ /* If too many elements were removed, shrink table to preserve memory. */
1181211812+ if ((locset->locMax > XML_NODESET_DEFAULT) &&
1181311813+ (locset->locNr < locset->locMax / 2)) {
1181411814+ xmlXPathObjectPtr *tmp;
1181511815+ int locMax = locset->locNr;
11916118161191711917- if (res && (pos >= minPos) && (pos <= maxPos)) {
1191811918- /*
1191911919- * Fits in the requested range.
1192011920- */
1192111921- newContextSize++;
1192211922- if (minPos == maxPos) {
1192311923- /*
1192411924- * Only 1 node was requested.
1192511925- */
1192611926- if (contextNode->type == XML_NAMESPACE_DECL) {
1192711927- /*
1192811928- * As always: take care of those nasty
1192911929- * namespace nodes.
1193011930- */
1193111931- set->nodeTab[i] = NULL;
1193211932- }
1193311933- xmlXPathNodeSetClear(set, hasNsNodes);
1193411934- set->nodeNr = 1;
1193511935- set->nodeTab[0] = contextNode;
1193611936- goto evaluation_exit;
1193711937- }
1193811938- if (pos == maxPos) {
1193911939- /*
1194011940- * We are done.
1194111941- */
1194211942- xmlXPathNodeSetClearFromPos(set, i +1, hasNsNodes);
1194311943- goto evaluation_exit;
1194411944- }
1194511945- } else {
1194611946- /*
1194711947- * Remove the entry from the initial node set.
1194811948- */
1194911949- set->nodeTab[i] = NULL;
1195011950- if (contextNode->type == XML_NAMESPACE_DECL)
1195111951- xmlXPathNodeSetFreeNs((xmlNsPtr) contextNode);
1195211952- }
1195311953- if (exprRes != NULL) {
1195411954- xmlXPathReleaseObject(ctxt->context, exprRes);
1195511955- exprRes = NULL;
1195611956- }
1195711957- if (ctxt->value == contextObj) {
1195811958- /*
1195911959- * Don't free the temporary XPath object holding the
1196011960- * context node, in order to avoid massive recreation
1196111961- * inside this loop.
1196211962- */
1196311963- valuePop(ctxt);
1196411964- xmlXPathNodeSetClear(contextObj->nodesetval, hasNsNodes);
1196511965- } else {
1196611966- /*
1196711967- * The object was lost in the evaluation machinery.
1196811968- * Can this happen? Maybe in case of internal-errors.
1196911969- */
1197011970- contextObj = NULL;
1197111971- }
1197211972- }
1197311973- goto evaluation_exit;
1181711817+ if (locMax < XML_NODESET_DEFAULT)
1181811818+ locMax = XML_NODESET_DEFAULT;
1181911819+ tmp = (xmlXPathObjectPtr *) xmlRealloc(locset->locTab,
1182011820+ locMax * sizeof(xmlXPathObjectPtr));
1182111821+ if (tmp == NULL) {
1182211822+ xmlXPathPErrMemory(ctxt, "shrinking locset\n");
1182311823+ } else {
1182411824+ locset->locTab = tmp;
1182511825+ locset->locMax = locMax;
1182611826+ }
1182711827+ }
11974118281197511975-evaluation_error:
1197611976- xmlXPathNodeSetClear(set, hasNsNodes);
1197711977- newContextSize = 0;
1182911829+exit:
1183011830+ xpctxt->node = oldnode;
1183111831+ xpctxt->doc = olddoc;
1183211832+ xpctxt->contextSize = oldcs;
1183311833+ xpctxt->proximityPosition = oldpp;
1183411834+}
1183511835+#endif /* LIBXML_XPTR_ENABLED */
11978118361197911979-evaluation_exit:
1198011980- if (contextObj != NULL) {
1198111981- if (ctxt->value == contextObj)
1198211982- valuePop(ctxt);
1198311983- xmlXPathReleaseObject(xpctxt, contextObj);
1198411984- }
1198511985- if (exprRes != NULL)
1198611986- xmlXPathReleaseObject(ctxt->context, exprRes);
1183711837+/**
1183811838+ * xmlXPathCompOpEvalPredicate:
1183911839+ * @ctxt: the XPath Parser context
1184011840+ * @op: the predicate op
1184111841+ * @set: the node set to filter
1184211842+ * @minPos: minimum position in the filtered set (1-based)
1184311843+ * @maxPos: maximum position in the filtered set (1-based)
1184411844+ * @hasNsNodes: true if the node set may contain namespace nodes
1184511845+ *
1184611846+ * Filter a node set, keeping only nodes for which the sequence of predicate
1184711847+ * expressions matches. Afterwards, keep only nodes between minPos and maxPos
1184811848+ * in the filtered result.
1184911849+ */
1185011850+static void
1185111851+xmlXPathCompOpEvalPredicate(xmlXPathParserContextPtr ctxt,
1185211852+ xmlXPathStepOpPtr op,
1185311853+ xmlNodeSetPtr set,
1185411854+ int minPos, int maxPos,
1185511855+ int hasNsNodes)
1185611856+{
1185711857+ if (op->ch1 != -1) {
1185811858+ xmlXPathCompExprPtr comp = ctxt->comp;
1198711859 /*
1198811988- * Reset/invalidate the context.
1186011860+ * Process inner predicates first.
1198911861 */
1199011990- xpctxt->node = oldContextNode;
1199111991- xpctxt->doc = oldContextDoc;
1199211992- xpctxt->contextSize = oldcs;
1199311993- xpctxt->proximityPosition = oldpp;
1199411994- return(newContextSize);
1186211862+ if (comp->steps[op->ch1].op != XPATH_OP_PREDICATE) {
1186311863+ xmlGenericError(xmlGenericErrorContext,
1186411864+ "xmlXPathCompOpEvalPredicate: Expected a predicate\n");
1186511865+ XP_ERROR(XPATH_INVALID_OPERAND);
1186611866+ }
1186711867+ if (ctxt->context->depth >= ctxt->context->maxDepth)
1186811868+ XP_ERROR(XPATH_RECURSION_LIMIT_EXCEEDED);
1186911869+ ctxt->context->depth += 1;
1187011870+ xmlXPathCompOpEvalPredicate(ctxt, &comp->steps[op->ch1], set,
1187111871+ 1, set->nodeNr, hasNsNodes);
1187211872+ ctxt->context->depth -= 1;
1187311873+ CHECK_ERROR;
1199511874 }
1199611996- return(contextSize);
1187511875+1187611876+ if (op->ch2 != -1)
1187711877+ xmlXPathNodeSetFilter(ctxt, set, op->ch2, minPos, maxPos, hasNsNodes);
1199711878}
11998118791199911880static int
···1201311894 * 1) For predicates (XPATH_OP_PREDICATE):
1201411895 * - an inner predicate operator
1201511896 * 2) For filters (XPATH_OP_FILTER):
1201612016- * - an inner filter operater OR
1189711897+ * - an inner filter operator OR
1201711898 * - an expression selecting the node set.
1201811899 * E.g. "key('a', 'b')" or "(//foo | //bar)".
1201911900 */
···1211111992 /* First predicate operator */
1211211993 xmlXPathStepOpPtr predOp;
1211311994 int maxPos; /* The requested position() (when a "[n]" predicate) */
1211412114- int hasPredicateRange, hasAxisRange, pos, size, newSize;
1199511995+ int hasPredicateRange, hasAxisRange, pos;
1211511996 int breakOnFirstHit;
12116119971211711998 xmlXPathTraversalFunction next = NULL;
···1230412185 if (seq == NULL) {
1230512186 seq = xmlXPathNodeSetCreate(NULL);
1230612187 if (seq == NULL) {
1218812188+ /* TODO: Propagate memory error. */
1230712189 total = 0;
1230812190 goto error;
1230912191 }
···1231512197 cur = NULL;
1231612198 hasNsNodes = 0;
1231712199 do {
1220012200+ if (OP_LIMIT_EXCEEDED(ctxt, 1))
1220112201+ goto error;
1220212202+1231812203 cur = next(ctxt, cur);
1231912204 if (cur == NULL)
1232012205 break;
···1252212407 outSeq = seq;
1252312408 seq = NULL;
1252412409 } else
1252512525- outSeq = mergeAndClear(outSeq, seq, 0);
1241012410+ /* TODO: Check memory error. */
1241112411+ outSeq = mergeAndClear(outSeq, seq);
1252612412 /*
1252712413 * Break if only a true/false result was requested.
1252812414 */
···1253912425 outSeq = seq;
1254012426 seq = NULL;
1254112427 } else
1254212542- outSeq = mergeAndClear(outSeq, seq, 0);
1242812428+ /* TODO: Check memory error. */
1242912429+ outSeq = mergeAndClear(outSeq, seq);
1254312430 break;
12544124311254512432#ifdef DEBUG_STEP
···1258312470 * For the moment, I'll try to solve this with a recursive
1258412471 * function: xmlXPathCompOpEvalPredicate().
1258512472 */
1258612586- size = seq->nodeNr;
1258712473 if (hasPredicateRange != 0)
1258812588- newSize = xmlXPathCompOpEvalPositionalPredicate(ctxt,
1258912589- predOp, seq, size, maxPos, maxPos, hasNsNodes);
1247412474+ xmlXPathCompOpEvalPredicate(ctxt, predOp, seq, maxPos, maxPos,
1247512475+ hasNsNodes);
1259012476 else
1259112591- newSize = xmlXPathCompOpEvalPredicate(ctxt,
1259212592- predOp, seq, size, hasNsNodes);
1247712477+ xmlXPathCompOpEvalPredicate(ctxt, predOp, seq, 1, seq->nodeNr,
1247812478+ hasNsNodes);
12593124791259412480 if (ctxt->error != XPATH_EXPRESSION_OK) {
1259512481 total = 0;
1259612482 goto error;
1259712483 }
1259812598- /*
1259912599- * Add the filtered set of nodes to the result node set.
1260012600- */
1260112601- if (newSize == 0) {
1260212602- /*
1260312603- * The predicates filtered all nodes out.
1260412604- */
1260512605- xmlXPathNodeSetClear(seq, hasNsNodes);
1260612606- } else if (seq->nodeNr > 0) {
1260712607- /*
1260812608- * Add to result set.
1260912609- */
1261012610- if (outSeq == NULL) {
1261112611- if (size != newSize) {
1261212612- /*
1261312613- * We need to merge and clear here, since
1261412614- * the sequence will contained NULLed entries.
1261512615- */
1261612616- outSeq = mergeAndClear(NULL, seq, 1);
1261712617- } else {
1261812618- outSeq = seq;
1261912619- seq = NULL;
1262012620- }
1262112621- } else
1262212622- outSeq = mergeAndClear(outSeq, seq,
1262312623- (size != newSize) ? 1: 0);
1262412624- /*
1262512625- * Break if only a true/false result was requested.
1262612626- */
1262712627- if (toBool)
1262812628- break;
1262912629- }
1263012630- } else if (seq->nodeNr > 0) {
1248412484+ }
1248512485+1248612486+ if (seq->nodeNr > 0) {
1263112487 /*
1263212488 * Add to result set.
1263312489 */
···1263512491 outSeq = seq;
1263612492 seq = NULL;
1263712493 } else {
1263812638- outSeq = mergeAndClear(outSeq, seq, 0);
1249412494+ /* TODO: Check memory error. */
1249512495+ outSeq = mergeAndClear(outSeq, seq);
1263912496 }
1249712497+1249812498+ if (toBool)
1249912499+ break;
1264012500 }
1264112501 }
1264212502···1265512515 xmlXPathReleaseObject(xpctxt, obj);
12656125161265712517 /*
1265812658- * Ensure we return at least an emtpy set.
1251812518+ * Ensure we return at least an empty set.
1265912519 */
1266012520 if (outSeq == NULL) {
1266112521 if ((seq != NULL) && (seq->nodeNr == 0))
1266212522 outSeq = seq;
1266312523 else
1252412524+ /* TODO: Check memory error. */
1266412525 outSeq = xmlXPathNodeSetCreate(NULL);
1266512665- /* XXX what if xmlXPathNodeSetCreate returned NULL here? */
1266612526 }
1266712527 if ((seq != NULL) && (seq != outSeq)) {
1266812528 xmlXPathFreeNodeSet(seq);
···1271812578 xmlXPathObjectPtr arg1, arg2;
12719125791272012580 CHECK_ERROR0;
1258112581+ if (OP_LIMIT_EXCEEDED(ctxt, 1))
1258212582+ return(0);
1258312583+ if (ctxt->context->depth >= ctxt->context->maxDepth)
1258412584+ XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
1258512585+ ctxt->context->depth += 1;
1272112586 comp = ctxt->comp;
1272212587 switch (op->op) {
1272312588 case XPATH_OP_END:
1272412724- return (0);
1258912589+ break;
1272512590 case XPATH_OP_UNION:
1272612591 total =
1272712592 xmlXPathCompOpEvalFirst(ctxt, &comp->steps[op->ch1],
···1273512600 * limit tree traversing to first node in the result
1273612601 */
1273712602 /*
1273812738- * OPTIMIZE TODO: This implicitely sorts
1260312603+ * OPTIMIZE TODO: This implicitly sorts
1273912604 * the result, even if not needed. E.g. if the argument
1274012605 * of the count() function, no sorting is needed.
1274112606 * OPTIMIZE TODO: How do we know if the node-list wasn't
1274212742- * aready sorted?
1260712607+ * already sorted?
1274312608 */
1274412609 if (ctxt->value->nodesetval->nodeNr > 1)
1274512610 xmlXPathNodeSetSort(ctxt->value->nodesetval);
···1275812623 xmlXPathReleaseObject(ctxt->context, arg2);
1275912624 XP_ERROR0(XPATH_INVALID_TYPE);
1276012625 }
1262612626+ if ((ctxt->context->opLimit != 0) &&
1262712627+ (((arg1->nodesetval != NULL) &&
1262812628+ (xmlXPathCheckOpLimit(ctxt,
1262912629+ arg1->nodesetval->nodeNr) < 0)) ||
1263012630+ ((arg2->nodesetval != NULL) &&
1263112631+ (xmlXPathCheckOpLimit(ctxt,
1263212632+ arg2->nodesetval->nodeNr) < 0)))) {
1263312633+ xmlXPathReleaseObject(ctxt->context, arg1);
1263412634+ xmlXPathReleaseObject(ctxt->context, arg2);
1263512635+ break;
1263612636+ }
12761126371263812638+ /* TODO: Check memory error. */
1276212639 arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval,
1276312640 arg2->nodesetval);
1276412641 valuePush(ctxt, arg1);
···1276612643 /* optimizer */
1276712644 if (total > cur)
1276812645 xmlXPathCompSwap(op);
1276912769- return (total + cur);
1264612646+ total += cur;
1264712647+ break;
1277012648 case XPATH_OP_ROOT:
1277112649 xmlXPathRoot(ctxt);
1277212772- return (0);
1265012650+ break;
1277312651 case XPATH_OP_NODE:
1277412652 if (op->ch1 != -1)
1277512653 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
···1277912657 CHECK_ERROR0;
1278012658 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
1278112659 ctxt->context->node));
1278212782- return (total);
1266012660+ break;
1278312661 case XPATH_OP_COLLECT:{
1278412662 if (op->ch1 == -1)
1278512785- return (total);
1266312663+ break;
12786126641278712665 total = xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1278812666 CHECK_ERROR0;
12789126671279012668 total += xmlXPathNodeCollectAndTest(ctxt, op, first, NULL, 0);
1279112791- return (total);
1266912669+ break;
1279212670 }
1279312671 case XPATH_OP_VALUE:
1279412672 valuePush(ctxt,
1279512673 xmlXPathCacheObjectCopy(ctxt->context,
1279612674 (xmlXPathObjectPtr) op->value4));
1279712797- return (0);
1267512675+ break;
1279812676 case XPATH_OP_SORT:
1279912677 if (op->ch1 != -1)
1280012678 total +=
···1280612684 && (ctxt->value->nodesetval != NULL)
1280712685 && (ctxt->value->nodesetval->nodeNr > 1))
1280812686 xmlXPathNodeSetSort(ctxt->value->nodesetval);
1280912809- return (total);
1268712687+ break;
1281012688#ifdef XP_OPTIMIZED_FILTER_FIRST
1281112689 case XPATH_OP_FILTER:
1281212690 total += xmlXPathCompOpEvalFilterFirst(ctxt, op, first);
1281312813- return (total);
1269112691+ break;
1281412692#endif
1281512693 default:
1281612816- return (xmlXPathCompOpEval(ctxt, op));
1269412694+ total += xmlXPathCompOpEval(ctxt, op);
1269512695+ break;
1281712696 }
1269712697+1269812698+ ctxt->context->depth -= 1;
1269912699+ return(total);
1281812700}
12819127011282012702/**
···1283712719 xmlXPathObjectPtr arg1, arg2;
12838127201283912721 CHECK_ERROR0;
1272212722+ if (OP_LIMIT_EXCEEDED(ctxt, 1))
1272312723+ return(0);
1272412724+ if (ctxt->context->depth >= ctxt->context->maxDepth)
1272512725+ XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
1272612726+ ctxt->context->depth += 1;
1284012727 comp = ctxt->comp;
1284112728 switch (op->op) {
1284212729 case XPATH_OP_END:
1284312843- return (0);
1273012730+ break;
1284412731 case XPATH_OP_UNION:
1284512732 total =
1284612733 xmlXPathCompOpEvalLast(ctxt, &comp->steps[op->ch1], last);
···1287612763 xmlXPathReleaseObject(ctxt->context, arg2);
1287712764 XP_ERROR0(XPATH_INVALID_TYPE);
1287812765 }
1276612766+ if ((ctxt->context->opLimit != 0) &&
1276712767+ (((arg1->nodesetval != NULL) &&
1276812768+ (xmlXPathCheckOpLimit(ctxt,
1276912769+ arg1->nodesetval->nodeNr) < 0)) ||
1277012770+ ((arg2->nodesetval != NULL) &&
1277112771+ (xmlXPathCheckOpLimit(ctxt,
1277212772+ arg2->nodesetval->nodeNr) < 0)))) {
1277312773+ xmlXPathReleaseObject(ctxt->context, arg1);
1277412774+ xmlXPathReleaseObject(ctxt->context, arg2);
1277512775+ break;
1277612776+ }
12879127771277812778+ /* TODO: Check memory error. */
1288012779 arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval,
1288112780 arg2->nodesetval);
1288212781 valuePush(ctxt, arg1);
···1288412783 /* optimizer */
1288512784 if (total > cur)
1288612785 xmlXPathCompSwap(op);
1288712887- return (total + cur);
1278612786+ total += cur;
1278712787+ break;
1288812788 case XPATH_OP_ROOT:
1288912789 xmlXPathRoot(ctxt);
1289012890- return (0);
1279012790+ break;
1289112791 case XPATH_OP_NODE:
1289212792 if (op->ch1 != -1)
1289312793 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
···1289712797 CHECK_ERROR0;
1289812798 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
1289912799 ctxt->context->node));
1290012900- return (total);
1280012800+ break;
1290112801 case XPATH_OP_COLLECT:{
1290212802 if (op->ch1 == -1)
1290312903- return (0);
1280312803+ break;
12904128041290512805 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1290612806 CHECK_ERROR0;
12907128071290812808 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, last, 0);
1290912909- return (total);
1280912809+ break;
1291012810 }
1291112811 case XPATH_OP_VALUE:
1291212812 valuePush(ctxt,
1291312813 xmlXPathCacheObjectCopy(ctxt->context,
1291412814 (xmlXPathObjectPtr) op->value4));
1291512915- return (0);
1281512815+ break;
1291612816 case XPATH_OP_SORT:
1291712817 if (op->ch1 != -1)
1291812818 total +=
···1292412824 && (ctxt->value->nodesetval != NULL)
1292512825 && (ctxt->value->nodesetval->nodeNr > 1))
1292612826 xmlXPathNodeSetSort(ctxt->value->nodesetval);
1292712927- return (total);
1282712827+ break;
1292812828 default:
1292912929- return (xmlXPathCompOpEval(ctxt, op));
1282912829+ total += xmlXPathCompOpEval(ctxt, op);
1283012830+ break;
1293012831 }
1283212832+1283312833+ ctxt->context->depth -= 1;
1283412834+ return (total);
1293112835}
12932128361293312837#ifdef XP_OPTIMIZED_FILTER_FIRST
···1293712841{
1293812842 int total = 0;
1293912843 xmlXPathCompExprPtr comp;
1294012940- xmlXPathObjectPtr res;
1294112941- xmlXPathObjectPtr obj;
1294212942- xmlNodeSetPtr oldset;
1294312943- xmlNodePtr oldnode;
1294412944- xmlDocPtr oldDoc;
1294512945- int oldcs, oldpp;
1294612946- int i;
1284412844+ xmlNodeSetPtr set;
12947128451294812846 CHECK_ERROR0;
1294912847 comp = ctxt->comp;
···1299812896 * Hum are we filtering the result of an XPointer expression
1299912897 */
1300012898 if (ctxt->value->type == XPATH_LOCATIONSET) {
1300113001- xmlXPathObjectPtr tmp = NULL;
1300213002- xmlLocationSetPtr newlocset = NULL;
1300313003- xmlLocationSetPtr oldlocset;
1300413004-1300513005- /*
1300613006- * Extract the old locset, and then evaluate the result of the
1300713007- * expression for all the element in the locset. use it to grow
1300813008- * up a new locset.
1300913009- */
1301013010- CHECK_TYPE0(XPATH_LOCATIONSET);
1301113011-1301213012- if ((ctxt->value->user == NULL) ||
1301313013- (((xmlLocationSetPtr) ctxt->value->user)->locNr == 0))
1301413014- return (total);
1289912899+ xmlLocationSetPtr locset = ctxt->value->user;
13015129001301613016- obj = valuePop(ctxt);
1301713017- oldlocset = obj->user;
1301813018- oldnode = ctxt->context->node;
1301913019- oldcs = ctxt->context->contextSize;
1302013020- oldpp = ctxt->context->proximityPosition;
1290112901+ if (locset != NULL) {
1290212902+ xmlXPathLocationSetFilter(ctxt, locset, op->ch2, 1, 1);
1290312903+ if (locset->locNr > 0)
1290412904+ *first = (xmlNodePtr) locset->locTab[0]->user;
1290512905+ }
13021129061302213022- newlocset = xmlXPtrLocationSetCreate(NULL);
1302313023-1302413024- for (i = 0; i < oldlocset->locNr; i++) {
1302513025- /*
1302613026- * Run the evaluation with a node list made of a
1302713027- * single item in the nodelocset.
1302813028- */
1302913029- ctxt->context->node = oldlocset->locTab[i]->user;
1303013030- ctxt->context->contextSize = oldlocset->locNr;
1303113031- ctxt->context->proximityPosition = i + 1;
1303213032- if (tmp == NULL) {
1303313033- tmp = xmlXPathCacheNewNodeSet(ctxt->context,
1303413034- ctxt->context->node);
1303513035- } else {
1303613036- if (xmlXPathNodeSetAddUnique(tmp->nodesetval,
1303713037- ctxt->context->node) < 0) {
1303813038- ctxt->error = XPATH_MEMORY_ERROR;
1303913039- }
1304013040- }
1304113041- valuePush(ctxt, tmp);
1304213042- if (op->ch2 != -1)
1304313043- total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
1304413044- if (ctxt->error != XPATH_EXPRESSION_OK) {
1304513045- xmlXPtrFreeLocationSet(newlocset);
1304613046- goto xptr_error;
1304713047- }
1304813048- /*
1304913049- * The result of the evaluation need to be tested to
1305013050- * decided whether the filter succeeded or not
1305113051- */
1305213052- res = valuePop(ctxt);
1305313053- if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
1305413054- xmlXPtrLocationSetAdd(newlocset,
1305513055- xmlXPathCacheObjectCopy(ctxt->context,
1305613056- oldlocset->locTab[i]));
1305713057- }
1305813058- /*
1305913059- * Cleanup
1306013060- */
1306113061- if (res != NULL) {
1306213062- xmlXPathReleaseObject(ctxt->context, res);
1306313063- }
1306413064- if (ctxt->value == tmp) {
1306513065- valuePop(ctxt);
1306613066- xmlXPathNodeSetClear(tmp->nodesetval, 1);
1306713067- /*
1306813068- * REVISIT TODO: Don't create a temporary nodeset
1306913069- * for everly iteration.
1307013070- */
1307113071- /* OLD: xmlXPathFreeObject(res); */
1307213072- } else
1307313073- tmp = NULL;
1307413074- /*
1307513075- * Only put the first node in the result, then leave.
1307613076- */
1307713077- if (newlocset->locNr > 0) {
1307813078- *first = (xmlNodePtr) oldlocset->locTab[i]->user;
1307913079- break;
1308013080- }
1308113081- }
1308213082- if (tmp != NULL) {
1308313083- xmlXPathReleaseObject(ctxt->context, tmp);
1308413084- }
1308513085- /*
1308613086- * The result is used as the new evaluation locset.
1308713087- */
1308813088- valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
1308913089-xptr_error:
1309013090- xmlXPathReleaseObject(ctxt->context, obj);
1309113091- ctxt->context->node = oldnode;
1309213092- ctxt->context->contextSize = oldcs;
1309313093- ctxt->context->proximityPosition = oldpp;
1309412907 return (total);
1309512908 }
1309612909#endif /* LIBXML_XPTR_ENABLED */
13097129101309813098- /*
1309913099- * Extract the old set, and then evaluate the result of the
1310013100- * expression for all the element in the set. use it to grow
1310113101- * up a new set.
1310213102- */
1310312911 CHECK_TYPE0(XPATH_NODESET);
1310413104-1310513105- if ((ctxt->value->nodesetval != NULL) &&
1310613106- (ctxt->value->nodesetval->nodeNr != 0)) {
1310713107- xmlNodeSetPtr newset;
1310813108- xmlXPathObjectPtr tmp = NULL;
1310913109-1311013110- obj = valuePop(ctxt);
1311113111- oldset = obj->nodesetval;
1311213112- oldnode = ctxt->context->node;
1311313113- oldDoc = ctxt->context->doc;
1311413114- oldcs = ctxt->context->contextSize;
1311513115- oldpp = ctxt->context->proximityPosition;
1311613116-1311713117- /*
1311813118- * Initialize the new set.
1311913119- * Also set the xpath document in case things like
1312013120- * key() evaluation are attempted on the predicate
1312113121- */
1312213122- newset = xmlXPathNodeSetCreate(NULL);
1312313123- /* XXX what if xmlXPathNodeSetCreate returned NULL? */
1312413124-1312513125- for (i = 0; i < oldset->nodeNr; i++) {
1312613126- /*
1312713127- * Run the evaluation with a node list made of
1312813128- * a single item in the nodeset.
1312913129- */
1313013130- ctxt->context->node = oldset->nodeTab[i];
1313113131- if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) &&
1313213132- (oldset->nodeTab[i]->doc != NULL))
1313313133- ctxt->context->doc = oldset->nodeTab[i]->doc;
1313413134- if (tmp == NULL) {
1313513135- tmp = xmlXPathCacheNewNodeSet(ctxt->context,
1313613136- ctxt->context->node);
1313713137- } else {
1313813138- if (xmlXPathNodeSetAddUnique(tmp->nodesetval,
1313913139- ctxt->context->node) < 0) {
1314013140- ctxt->error = XPATH_MEMORY_ERROR;
1314113141- }
1314213142- }
1314313143- valuePush(ctxt, tmp);
1314413144- ctxt->context->contextSize = oldset->nodeNr;
1314513145- ctxt->context->proximityPosition = i + 1;
1314613146- if (op->ch2 != -1)
1314713147- total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
1314813148- if (ctxt->error != XPATH_EXPRESSION_OK) {
1314913149- xmlXPathFreeNodeSet(newset);
1315013150- goto error;
1315113151- }
1315213152- /*
1315313153- * The result of the evaluation needs to be tested to
1315413154- * decide whether the filter succeeded or not
1315513155- */
1315613156- res = valuePop(ctxt);
1315713157- if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
1315813158- if (xmlXPathNodeSetAdd(newset, oldset->nodeTab[i]) < 0)
1315913159- ctxt->error = XPATH_MEMORY_ERROR;
1316013160- }
1316113161- /*
1316213162- * Cleanup
1316313163- */
1316413164- if (res != NULL) {
1316513165- xmlXPathReleaseObject(ctxt->context, res);
1316613166- }
1316713167- if (ctxt->value == tmp) {
1316813168- valuePop(ctxt);
1316913169- /*
1317013170- * Don't free the temporary nodeset
1317113171- * in order to avoid massive recreation inside this
1317213172- * loop.
1317313173- */
1317413174- xmlXPathNodeSetClear(tmp->nodesetval, 1);
1317513175- } else
1317613176- tmp = NULL;
1317713177- /*
1317813178- * Only put the first node in the result, then leave.
1317913179- */
1318013180- if (newset->nodeNr > 0) {
1318113181- *first = *(newset->nodeTab);
1318213182- break;
1318313183- }
1318413184- }
1318513185- if (tmp != NULL) {
1318613186- xmlXPathReleaseObject(ctxt->context, tmp);
1318713187- }
1318813188- /*
1318913189- * The result is used as the new evaluation set.
1319013190- */
1319113191- valuePush(ctxt, xmlXPathCacheWrapNodeSet(ctxt->context, newset));
1319213192-error:
1319313193- xmlXPathReleaseObject(ctxt->context, obj);
1319413194- ctxt->context->node = oldnode;
1319513195- ctxt->context->doc = oldDoc;
1319613196- ctxt->context->contextSize = oldcs;
1319713197- ctxt->context->proximityPosition = oldpp;
1291212912+ set = ctxt->value->nodesetval;
1291312913+ if (set != NULL) {
1291412914+ xmlXPathNodeSetFilter(ctxt, set, op->ch2, 1, 1, 1);
1291512915+ if (set->nodeNr > 0)
1291612916+ *first = set->nodeTab[0];
1319812917 }
1319913199- return(total);
1291812918+1291912919+ return (total);
1320012920}
1320112921#endif /* XP_OPTIMIZED_FILTER_FIRST */
1320212922···1321712937 xmlXPathObjectPtr arg1, arg2;
13218129381321912939 CHECK_ERROR0;
1294012940+ if (OP_LIMIT_EXCEEDED(ctxt, 1))
1294112941+ return(0);
1294212942+ if (ctxt->context->depth >= ctxt->context->maxDepth)
1294312943+ XP_ERROR0(XPATH_RECURSION_LIMIT_EXCEEDED);
1294412944+ ctxt->context->depth += 1;
1322012945 comp = ctxt->comp;
1322112946 switch (op->op) {
1322212947 case XPATH_OP_END:
1322313223- return (0);
1294812948+ break;
1322412949 case XPATH_OP_AND:
1322512950 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1322612951 CHECK_ERROR0;
1322712952 xmlXPathBooleanFunction(ctxt, 1);
1322812953 if ((ctxt->value == NULL) || (ctxt->value->boolval == 0))
1322913229- return (total);
1295412954+ break;
1323012955 arg2 = valuePop(ctxt);
1323112956 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
1323212957 if (ctxt->error) {
1323312958 xmlXPathFreeObject(arg2);
1323413234- return(0);
1295912959+ break;
1323512960 }
1323612961 xmlXPathBooleanFunction(ctxt, 1);
1323712962 if (ctxt->value != NULL)
1323812963 ctxt->value->boolval &= arg2->boolval;
1323912964 xmlXPathReleaseObject(ctxt->context, arg2);
1324013240- return (total);
1296512965+ break;
1324112966 case XPATH_OP_OR:
1324212967 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1324312968 CHECK_ERROR0;
1324412969 xmlXPathBooleanFunction(ctxt, 1);
1324512970 if ((ctxt->value == NULL) || (ctxt->value->boolval == 1))
1324613246- return (total);
1297112971+ break;
1324712972 arg2 = valuePop(ctxt);
1324812973 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
1324912974 if (ctxt->error) {
1325012975 xmlXPathFreeObject(arg2);
1325113251- return(0);
1297612976+ break;
1325212977 }
1325312978 xmlXPathBooleanFunction(ctxt, 1);
1325412979 if (ctxt->value != NULL)
1325512980 ctxt->value->boolval |= arg2->boolval;
1325612981 xmlXPathReleaseObject(ctxt->context, arg2);
1325713257- return (total);
1298212982+ break;
1325812983 case XPATH_OP_EQUAL:
1325912984 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1326012985 CHECK_ERROR0;
···1326512990 else
1326612991 equal = xmlXPathNotEqualValues(ctxt);
1326712992 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, equal));
1326813268- return (total);
1299312993+ break;
1326912994 case XPATH_OP_CMP:
1327012995 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1327112996 CHECK_ERROR0;
···1327312998 CHECK_ERROR0;
1327412999 ret = xmlXPathCompareValues(ctxt, op->value, op->value2);
1327513000 valuePush(ctxt, xmlXPathCacheNewBoolean(ctxt->context, ret));
1327613276- return (total);
1300113001+ break;
1327713002 case XPATH_OP_PLUS:
1327813003 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1327913004 CHECK_ERROR0;
···1329113016 CAST_TO_NUMBER;
1329213017 CHECK_TYPE0(XPATH_NUMBER);
1329313018 }
1329413294- return (total);
1301913019+ break;
1329513020 case XPATH_OP_MULT:
1329613021 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1329713022 CHECK_ERROR0;
···1330313028 xmlXPathDivValues(ctxt);
1330413029 else if (op->value == 2)
1330513030 xmlXPathModValues(ctxt);
1330613306- return (total);
1303113031+ break;
1330713032 case XPATH_OP_UNION:
1330813033 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1330913034 CHECK_ERROR0;
···1331813043 xmlXPathReleaseObject(ctxt->context, arg2);
1331913044 XP_ERROR0(XPATH_INVALID_TYPE);
1332013045 }
1304613046+ if ((ctxt->context->opLimit != 0) &&
1304713047+ (((arg1->nodesetval != NULL) &&
1304813048+ (xmlXPathCheckOpLimit(ctxt,
1304913049+ arg1->nodesetval->nodeNr) < 0)) ||
1305013050+ ((arg2->nodesetval != NULL) &&
1305113051+ (xmlXPathCheckOpLimit(ctxt,
1305213052+ arg2->nodesetval->nodeNr) < 0)))) {
1305313053+ xmlXPathReleaseObject(ctxt->context, arg1);
1305413054+ xmlXPathReleaseObject(ctxt->context, arg2);
1305513055+ break;
1305613056+ }
13321130571332213058 if ((arg1->nodesetval == NULL) ||
1332313059 ((arg2->nodesetval != NULL) &&
1332413060 (arg2->nodesetval->nodeNr != 0)))
1332513061 {
1306213062+ /* TODO: Check memory error. */
1332613063 arg1->nodesetval = xmlXPathNodeSetMerge(arg1->nodesetval,
1332713064 arg2->nodesetval);
1332813065 }
13329130661333013067 valuePush(ctxt, arg1);
1333113068 xmlXPathReleaseObject(ctxt->context, arg2);
1333213332- return (total);
1306913069+ break;
1333313070 case XPATH_OP_ROOT:
1333413071 xmlXPathRoot(ctxt);
1333513335- return (total);
1307213072+ break;
1333613073 case XPATH_OP_NODE:
1333713074 if (op->ch1 != -1)
1333813075 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
···1334213079 CHECK_ERROR0;
1334313080 valuePush(ctxt, xmlXPathCacheNewNodeSet(ctxt->context,
1334413081 ctxt->context->node));
1334513345- return (total);
1308213082+ break;
1334613083 case XPATH_OP_COLLECT:{
1334713084 if (op->ch1 == -1)
1334813348- return (total);
1308513085+ break;
13349130861335013087 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1335113088 CHECK_ERROR0;
13352130891335313090 total += xmlXPathNodeCollectAndTest(ctxt, op, NULL, NULL, 0);
1335413354- return (total);
1309113091+ break;
1335513092 }
1335613093 case XPATH_OP_VALUE:
1335713094 valuePush(ctxt,
1335813095 xmlXPathCacheObjectCopy(ctxt->context,
1335913096 (xmlXPathObjectPtr) op->value4));
1336013360- return (total);
1309713097+ break;
1336113098 case XPATH_OP_VARIABLE:{
1336213099 xmlXPathObjectPtr val;
1336313100···1337813115 "xmlXPathCompOpEval: variable %s bound to undefined prefix %s\n",
1337913116 (char *) op->value4, (char *)op->value5);
1338013117 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
1338113381- return (total);
1311813118+ break;
1338213119 }
1338313120 val = xmlXPathVariableLookupNS(ctxt->context,
1338413121 op->value4, URI);
···1338613123 XP_ERROR0(XPATH_UNDEF_VARIABLE_ERROR);
1338713124 valuePush(ctxt, val);
1338813125 }
1338913389- return (total);
1312613126+ break;
1339013127 }
1339113128 case XPATH_OP_FUNCTION:{
1339213129 xmlXPathFunction func;
···1340013137 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1340113138 if (ctxt->error != XPATH_EXPRESSION_OK) {
1340213139 xmlXPathPopFrame(ctxt, frame);
1340313403- return (total);
1314013140+ break;
1340413141 }
1340513142 }
1340613143 if (ctxt->valueNr < ctxt->valueFrame + op->value) {
···1340813145 "xmlXPathCompOpEval: parameter error\n");
1340913146 ctxt->error = XPATH_INVALID_OPERAND;
1341013147 xmlXPathPopFrame(ctxt, frame);
1341113411- return (total);
1314813148+ break;
1341213149 }
1341313150 for (i = 0; i < op->value; i++) {
1341413151 if (ctxt->valueTab[(ctxt->valueNr - 1) - i] == NULL) {
···1341613153 "xmlXPathCompOpEval: parameter error\n");
1341713154 ctxt->error = XPATH_INVALID_OPERAND;
1341813155 xmlXPathPopFrame(ctxt, frame);
1341913419- return (total);
1315613156+ break;
1342013157 }
1342113158 }
1342213159 if (op->cache != NULL)
···1343613173 (char *)op->value4, (char *)op->value5);
1343713174 xmlXPathPopFrame(ctxt, frame);
1343813175 ctxt->error = XPATH_UNDEF_PREFIX_ERROR;
1343913439- return (total);
1317613176+ break;
1344013177 }
1344113178 func = xmlXPathFunctionLookupNS(ctxt->context,
1344213179 op->value4, URI);
···1345713194 func(ctxt, op->value);
1345813195 ctxt->context->function = oldFunc;
1345913196 ctxt->context->functionURI = oldFuncURI;
1319713197+ if ((ctxt->error == XPATH_EXPRESSION_OK) &&
1319813198+ (ctxt->valueNr != ctxt->valueFrame + 1))
1319913199+ XP_ERROR0(XPATH_STACK_ERROR);
1346013200 xmlXPathPopFrame(ctxt, frame);
1346113461- return (total);
1320113201+ break;
1346213202 }
1346313203 case XPATH_OP_ARG:
1346413204 if (op->ch1 != -1) {
···1346913209 total += xmlXPathCompOpEval(ctxt, &comp->steps[op->ch2]);
1347013210 CHECK_ERROR0;
1347113211 }
1347213472- return (total);
1321213212+ break;
1347313213 case XPATH_OP_PREDICATE:
1347413214 case XPATH_OP_FILTER:{
1347513475- xmlXPathObjectPtr res;
1347613476- xmlXPathObjectPtr obj, tmp;
1347713477- xmlNodeSetPtr newset = NULL;
1347813478- xmlNodeSetPtr oldset;
1347913479- xmlNodePtr oldnode;
1348013480- xmlDocPtr oldDoc;
1348113481- int oldcs, oldpp;
1348213482- int i;
1321513215+ xmlNodeSetPtr set;
13483132161348413217 /*
1348513218 * Optimization for ()[1] selection i.e. the first elem
···1349113224 * will result in an ordered list if we have an
1349213225 * XPATH_OP_FILTER?
1349313226 * What about an additional field or flag on
1349413494- * xmlXPathObject like @sorted ? This way we wouln'd need
1322713227+ * xmlXPathObject like @sorted ? This way we wouldn't need
1349513228 * to assume anything, so it would be more robust and
1349613229 * easier to optimize.
1349713230 */
···1352313256 (ctxt->value->nodesetval->nodeNr > 1))
1352413257 xmlXPathNodeSetClearFromPos(ctxt->value->nodesetval,
1352513258 1, 1);
1352613526- return (total);
1325913259+ break;
1352713260 }
1352813261 }
1352913262 /*
···1355813291 (ctxt->value->nodesetval->nodeTab != NULL) &&
1355913292 (ctxt->value->nodesetval->nodeNr > 1))
1356013293 xmlXPathNodeSetKeepLast(ctxt->value->nodesetval);
1356113561- return (total);
1329413294+ break;
1356213295 }
1356313296 }
1356413297 /*
···1357713310 xmlXPathCompOpEval(ctxt, &comp->steps[op->ch1]);
1357813311 CHECK_ERROR0;
1357913312 if (op->ch2 == -1)
1358013580- return (total);
1331313313+ break;
1358113314 if (ctxt->value == NULL)
1358213582- return (total);
1331513315+ break;
13583133161358413317#ifdef LIBXML_XPTR_ENABLED
1358513318 /*
1358613319 * Hum are we filtering the result of an XPointer expression
1358713320 */
1358813321 if (ctxt->value->type == XPATH_LOCATIONSET) {
1358913589- xmlLocationSetPtr newlocset = NULL;
1359013590- xmlLocationSetPtr oldlocset;
1359113591-1359213592- /*
1359313593- * Extract the old locset, and then evaluate the result of the
1359413594- * expression for all the element in the locset. use it to grow
1359513595- * up a new locset.
1359613596- */
1359713597- CHECK_TYPE0(XPATH_LOCATIONSET);
1359813598-1359913599- if ((ctxt->value->user == NULL) ||
1360013600- (((xmlLocationSetPtr) ctxt->value->user)->locNr == 0))
1360113601- return (total);
1360213602-1360313603- obj = valuePop(ctxt);
1360413604- oldlocset = obj->user;
1360513605- oldnode = ctxt->context->node;
1360613606- oldcs = ctxt->context->contextSize;
1360713607- oldpp = ctxt->context->proximityPosition;
1360813608-1360913609- newlocset = xmlXPtrLocationSetCreate(NULL);
1361013610-1361113611- for (i = 0; i < oldlocset->locNr; i++) {
1361213612- /*
1361313613- * Run the evaluation with a node list made of a
1361413614- * single item in the nodelocset.
1361513615- */
1361613616- ctxt->context->node = oldlocset->locTab[i]->user;
1361713617- ctxt->context->contextSize = oldlocset->locNr;
1361813618- ctxt->context->proximityPosition = i + 1;
1361913619- tmp = xmlXPathCacheNewNodeSet(ctxt->context,
1362013620- ctxt->context->node);
1362113621- valuePush(ctxt, tmp);
1362213622-1362313623- if (op->ch2 != -1)
1362413624- total +=
1362513625- xmlXPathCompOpEval(ctxt,
1362613626- &comp->steps[op->ch2]);
1362713627- if (ctxt->error != XPATH_EXPRESSION_OK) {
1362813628- xmlXPtrFreeLocationSet(newlocset);
1362913629- goto filter_xptr_error;
1363013630- }
1363113631-1363213632- /*
1363313633- * The result of the evaluation need to be tested to
1363413634- * decided whether the filter succeeded or not
1363513635- */
1363613636- res = valuePop(ctxt);
1363713637- if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
1363813638- xmlXPtrLocationSetAdd(newlocset,
1363913639- xmlXPathObjectCopy
1364013640- (oldlocset->locTab[i]));
1364113641- }
1364213642-1364313643- /*
1364413644- * Cleanup
1364513645- */
1364613646- if (res != NULL) {
1364713647- xmlXPathReleaseObject(ctxt->context, res);
1364813648- }
1364913649- if (ctxt->value == tmp) {
1365013650- res = valuePop(ctxt);
1365113651- xmlXPathReleaseObject(ctxt->context, res);
1365213652- }
1365313653- }
1365413654-1365513655- /*
1365613656- * The result is used as the new evaluation locset.
1365713657- */
1365813658- valuePush(ctxt, xmlXPtrWrapLocationSet(newlocset));
1365913659-filter_xptr_error:
1366013660- xmlXPathReleaseObject(ctxt->context, obj);
1366113661- ctxt->context->node = oldnode;
1366213662- ctxt->context->contextSize = oldcs;
1366313663- ctxt->context->proximityPosition = oldpp;
1366413664- return (total);
1332213322+ xmlLocationSetPtr locset = ctxt->value->user;
1332313323+ xmlXPathLocationSetFilter(ctxt, locset, op->ch2,
1332413324+ 1, locset->locNr);
1332513325+ break;
1366513326 }
1366613327#endif /* LIBXML_XPTR_ENABLED */
13667133281366813668- /*
1366913669- * Extract the old set, and then evaluate the result of the
1367013670- * expression for all the element in the set. use it to grow
1367113671- * up a new set.
1367213672- */
1367313329 CHECK_TYPE0(XPATH_NODESET);
1367413674-1367513675- if ((ctxt->value->nodesetval != NULL) &&
1367613676- (ctxt->value->nodesetval->nodeNr != 0)) {
1367713677- obj = valuePop(ctxt);
1367813678- oldset = obj->nodesetval;
1367913679- oldnode = ctxt->context->node;
1368013680- oldDoc = ctxt->context->doc;
1368113681- oldcs = ctxt->context->contextSize;
1368213682- oldpp = ctxt->context->proximityPosition;
1368313683- tmp = NULL;
1368413684- /*
1368513685- * Initialize the new set.
1368613686- * Also set the xpath document in case things like
1368713687- * key() evaluation are attempted on the predicate
1368813688- */
1368913689- newset = xmlXPathNodeSetCreate(NULL);
1369013690- /*
1369113691- * SPEC XPath 1.0:
1369213692- * "For each node in the node-set to be filtered, the
1369313693- * PredicateExpr is evaluated with that node as the
1369413694- * context node, with the number of nodes in the
1369513695- * node-set as the context size, and with the proximity
1369613696- * position of the node in the node-set with respect to
1369713697- * the axis as the context position;"
1369813698- * @oldset is the node-set" to be filtered.
1369913699- *
1370013700- * SPEC XPath 1.0:
1370113701- * "only predicates change the context position and
1370213702- * context size (see [2.4 Predicates])."
1370313703- * Example:
1370413704- * node-set context pos
1370513705- * nA 1
1370613706- * nB 2
1370713707- * nC 3
1370813708- * After applying predicate [position() > 1] :
1370913709- * node-set context pos
1371013710- * nB 1
1371113711- * nC 2
1371213712- *
1371313713- * removed the first node in the node-set, then
1371413714- * the context position of the
1371513715- */
1371613716- for (i = 0; i < oldset->nodeNr; i++) {
1371713717- /*
1371813718- * Run the evaluation with a node list made of
1371913719- * a single item in the nodeset.
1372013720- */
1372113721- ctxt->context->node = oldset->nodeTab[i];
1372213722- if ((oldset->nodeTab[i]->type != XML_NAMESPACE_DECL) &&
1372313723- (oldset->nodeTab[i]->doc != NULL))
1372413724- ctxt->context->doc = oldset->nodeTab[i]->doc;
1372513725- if (tmp == NULL) {
1372613726- tmp = xmlXPathCacheNewNodeSet(ctxt->context,
1372713727- ctxt->context->node);
1372813728- } else {
1372913729- if (xmlXPathNodeSetAddUnique(tmp->nodesetval,
1373013730- ctxt->context->node) < 0) {
1373113731- ctxt->error = XPATH_MEMORY_ERROR;
1373213732- }
1373313733- }
1373413734- valuePush(ctxt, tmp);
1373513735- ctxt->context->contextSize = oldset->nodeNr;
1373613736- ctxt->context->proximityPosition = i + 1;
1373713737- /*
1373813738- * Evaluate the predicate against the context node.
1373913739- * Can/should we optimize position() predicates
1374013740- * here (e.g. "[1]")?
1374113741- */
1374213742- if (op->ch2 != -1)
1374313743- total +=
1374413744- xmlXPathCompOpEval(ctxt,
1374513745- &comp->steps[op->ch2]);
1374613746- if (ctxt->error != XPATH_EXPRESSION_OK) {
1374713747- xmlXPathFreeNodeSet(newset);
1374813748- goto filter_error;
1374913749- }
1375013750-1375113751- /*
1375213752- * The result of the evaluation needs to be tested to
1375313753- * decide whether the filter succeeded or not
1375413754- */
1375513755- /*
1375613756- * OPTIMIZE TODO: Can we use
1375713757- * xmlXPathNodeSetAdd*Unique()* instead?
1375813758- */
1375913759- res = valuePop(ctxt);
1376013760- if (xmlXPathEvaluatePredicateResult(ctxt, res)) {
1376113761- if (xmlXPathNodeSetAdd(newset, oldset->nodeTab[i])
1376213762- < 0)
1376313763- ctxt->error = XPATH_MEMORY_ERROR;
1376413764- }
1376513765-1376613766- /*
1376713767- * Cleanup
1376813768- */
1376913769- if (res != NULL) {
1377013770- xmlXPathReleaseObject(ctxt->context, res);
1377113771- }
1377213772- if (ctxt->value == tmp) {
1377313773- valuePop(ctxt);
1377413774- xmlXPathNodeSetClear(tmp->nodesetval, 1);
1377513775- /*
1377613776- * Don't free the temporary nodeset
1377713777- * in order to avoid massive recreation inside this
1377813778- * loop.
1377913779- */
1378013780- } else
1378113781- tmp = NULL;
1378213782- }
1378313783- if (tmp != NULL)
1378413784- xmlXPathReleaseObject(ctxt->context, tmp);
1378513785- /*
1378613786- * The result is used as the new evaluation set.
1378713787- */
1378813788- valuePush(ctxt,
1378913789- xmlXPathCacheWrapNodeSet(ctxt->context, newset));
1379013790-filter_error:
1379113791- xmlXPathReleaseObject(ctxt->context, obj);
1379213792- ctxt->context->node = oldnode;
1379313793- ctxt->context->doc = oldDoc;
1379413794- ctxt->context->contextSize = oldcs;
1379513795- ctxt->context->proximityPosition = oldpp;
1379613796- }
1379713797- return (total);
1333013330+ set = ctxt->value->nodesetval;
1333113331+ if (set != NULL)
1333213332+ xmlXPathNodeSetFilter(ctxt, set, op->ch2,
1333313333+ 1, set->nodeNr, 1);
1333413334+ break;
1379813335 }
1379913336 case XPATH_OP_SORT:
1380013337 if (op->ch1 != -1)
···1380713344 {
1380813345 xmlXPathNodeSetSort(ctxt->value->nodesetval);
1380913346 }
1381013810- return (total);
1334713347+ break;
1381113348#ifdef LIBXML_XPTR_ENABLED
1381213349 case XPATH_OP_RANGETO:{
1381313350 xmlXPathObjectPtr range;
···1383013367 XP_ERROR0(XPATH_INVALID_OPERAND);
1383113368 }
1383213369 if (op->ch2 == -1)
1383313833- return (total);
1337013370+ break;
13834133711383513372 if (ctxt->value->type == XPATH_LOCATIONSET) {
1383613373 /*
···13842133791384313380 if ((ctxt->value->user == NULL) ||
1384413381 (((xmlLocationSetPtr) ctxt->value->user)->locNr == 0))
1384513845- return (total);
1338213382+ break;
13846133831384713384 obj = valuePop(ctxt);
1384813385 oldlocset = obj->user;
···1396413501 ctxt->context->node = oldnode;
1396513502 ctxt->context->contextSize = oldcs;
1396613503 ctxt->context->proximityPosition = oldpp;
1396713967- return (total);
1350413504+ break;
1396813505 }
1396913506#endif /* LIBXML_XPTR_ENABLED */
1350713507+ default:
1350813508+ xmlGenericError(xmlGenericErrorContext,
1350913509+ "XPath: unknown precompiled operation %d\n", op->op);
1351013510+ ctxt->error = XPATH_INVALID_OPERAND;
1351113511+ break;
1397013512 }
1397113971- xmlGenericError(xmlGenericErrorContext,
1397213972- "XPath: unknown precompiled operation %d\n", op->op);
1397313973- ctxt->error = XPATH_INVALID_OPERAND;
1351313513+1351413514+ ctxt->context->depth -= 1;
1397413515 return (total);
1397513516}
1397613517···1399013531 xmlXPathObjectPtr resObj = NULL;
13991135321399213533start:
1353413534+ if (OP_LIMIT_EXCEEDED(ctxt, 1))
1353513535+ return(0);
1399313536 /* comp = ctxt->comp; */
1399413537 switch (op->op) {
1399513538 case XPATH_OP_END:
···1411613659 /* Select "/" */
1411713660 if (toBool)
1411813661 return(1);
1366213662+ /* TODO: Check memory error. */
1411913663 xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval,
1412013664 (xmlNodePtr) ctxt->doc);
1412113665 } else {
1412213666 /* Select "self::node()" */
1412313667 if (toBool)
1412413668 return(1);
1366913669+ /* TODO: Check memory error. */
1412513670 xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, ctxt->node);
1412613671 }
1412713672 }
···1418213727 } else if (ret == 1) {
1418313728 if (toBool)
1418413729 goto return_1;
1373013730+ /* TODO: Check memory error. */
1418513731 xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur);
1418613732 }
1418713733 }
···1418913735 goto scan_children;
1419013736next_node:
1419113737 do {
1373813738+ if (ctxt->opLimit != 0) {
1373913739+ if (ctxt->opCount >= ctxt->opLimit) {
1374013740+ xmlGenericError(xmlGenericErrorContext,
1374113741+ "XPath operation limit exceeded\n");
1374213742+ xmlFreeStreamCtxt(patstream);
1374313743+ return(-1);
1374413744+ }
1374513745+ ctxt->opCount++;
1374613746+ }
1374713747+1419213748 nb_nodes++;
14193137491419413750 switch (cur->type) {
···14311138671431213868 if ((ctxt == NULL) || (ctxt->comp == NULL))
1431313869 return(-1);
1387013870+1387113871+ ctxt->context->depth = 0;
14314138721431513873 if (ctxt->valueTab == NULL) {
1431613874 /* Allocate the value stack */
···14498140561449914057 /*
1450014058 * We don't try to handle expressions using the verbose axis
1450114501- * specifiers ("::"), just the simplied form at this point.
1405914059+ * specifiers ("::"), just the simplified form at this point.
1450214060 * Additionally, if there is no list of namespaces available and
1450314061 * there's a ":" in the expression, indicating a prefixed QName,
1450414062 * then we won't try to compile either. xmlPatterncompile() needs
···1455214110#endif /* XPATH_STREAMING */
14553141111455414112static void
1455514555-xmlXPathOptimizeExpression(xmlXPathCompExprPtr comp, xmlXPathStepOpPtr op)
1411314113+xmlXPathOptimizeExpression(xmlXPathParserContextPtr pctxt,
1411414114+ xmlXPathStepOpPtr op)
1455614115{
1411614116+ xmlXPathCompExprPtr comp = pctxt->comp;
1411714117+ xmlXPathContextPtr ctxt;
1411814118+1455714119 /*
1455814120 * Try to rewrite "descendant-or-self::node()/foo" to an optimized
1455914121 * internal representation.
···1460914171 return;
14610141721461114173 /* Recurse */
1417414174+ ctxt = pctxt->context;
1417514175+ if (ctxt != NULL) {
1417614176+ if (ctxt->depth >= ctxt->maxDepth)
1417714177+ return;
1417814178+ ctxt->depth += 1;
1417914179+ }
1461214180 if (op->ch1 != -1)
1461314613- xmlXPathOptimizeExpression(comp, &comp->steps[op->ch1]);
1418114181+ xmlXPathOptimizeExpression(pctxt, &comp->steps[op->ch1]);
1461414182 if (op->ch2 != -1)
1461514615- xmlXPathOptimizeExpression(comp, &comp->steps[op->ch2]);
1418314183+ xmlXPathOptimizeExpression(pctxt, &comp->steps[op->ch2]);
1418414184+ if (ctxt != NULL)
1418514185+ ctxt->depth -= 1;
1461614186}
14617141871461814188/**
···1464114211 pctxt = xmlXPathNewParserContext(str, ctxt);
1464214212 if (pctxt == NULL)
1464314213 return NULL;
1421414214+ if (ctxt != NULL)
1421514215+ ctxt->depth = 0;
1464414216 xmlXPathCompileExpr(pctxt, 1);
14645142171464614218 if( pctxt->error != XPATH_EXPRESSION_OK )
···1466014232 comp = NULL;
1466114233 } else {
1466214234 comp = pctxt->comp;
1423514235+ if ((comp->nbStep > 1) && (comp->last >= 0)) {
1423614236+ if (ctxt != NULL)
1423714237+ ctxt->depth = 0;
1423814238+ xmlXPathOptimizeExpression(pctxt, &comp->steps[comp->last]);
1423914239+ }
1466314240 pctxt->comp = NULL;
1466414241 }
1466514242 xmlXPathFreeParserContext(pctxt);
···1467014247 comp->string = xmlStrdup(str);
1467114248 comp->nb = 0;
1467214249#endif
1467314673- if ((comp->nbStep > 1) && (comp->last >= 0)) {
1467414674- xmlXPathOptimizeExpression(comp, &comp->steps[comp->last]);
1467514675- }
1467614250 }
1467714251 return(comp);
1467814252}
···1482914403 } else
1483014404#endif
1483114405 {
1440614406+ if (ctxt->context != NULL)
1440714407+ ctxt->context->depth = 0;
1483214408 xmlXPathCompileExpr(ctxt, 1);
1483314409 CHECK_ERROR;
1483414410···1483614412 if (*ctxt->cur != 0)
1483714413 XP_ERROR(XPATH_EXPR_ERROR);
14838144141483914839- if ((ctxt->comp->nbStep > 1) && (ctxt->comp->last >= 0))
1484014840- xmlXPathOptimizeExpression(ctxt->comp,
1441514415+ if ((ctxt->comp->nbStep > 1) && (ctxt->comp->last >= 0)) {
1441614416+ if (ctxt->context != NULL)
1441714417+ ctxt->context->depth = 0;
1441814418+ xmlXPathOptimizeExpression(ctxt,
1484114419 &ctxt->comp->steps[ctxt->comp->last]);
1442014420+ }
1484214421 }
14843144221484414423 xmlXPathRunEval(ctxt, 0);
+14-4
sdk/lib/3rdparty/libxml2/xpointer.c
···2727 * be parsed beforehand instead of a progressive evaluation
2828 * TODO: Access into entities references are not supported now ...
2929 * need a start to be able to pop out of entities refs since
3030- * parent is the endity declaration, not the ref.
3030+ * parent is the entity declaration, not the ref.
3131 */
32323333#include <string.h>
···11861186static void
11871187xmlXPtrEvalChildSeq(xmlXPathParserContextPtr ctxt, xmlChar *name) {
11881188 /*
11891189- * XPointer don't allow by syntax to address in mutirooted trees
11891189+ * XPointer don't allow by syntax to address in multirooted trees
11901190 * this might prove useful in some cases, warn about it.
11911191 */
11921192 if ((name == NULL) && (CUR == '/') && (NXT(1) != '1')) {
···12021202 }
1203120312041204 while (CUR == '/') {
12051205- int child = 0;
12051205+ int child = 0, overflow = 0;
12061206 NEXT;
1207120712081208 while ((CUR >= '0') && (CUR <= '9')) {
12091209- child = child * 10 + (CUR - '0');
12091209+ int d = CUR - '0';
12101210+ if (child > INT_MAX / 10)
12111211+ overflow = 1;
12121212+ else
12131213+ child *= 10;
12141214+ if (child > INT_MAX - d)
12151215+ overflow = 1;
12161216+ else
12171217+ child += d;
12101218 NEXT;
12111219 }
12201220+ if (overflow)
12211221+ child = 0;
12121222 xmlXPtrGetChildNo(ctxt, child);
12131223 }
12141224}
+2-2
sdk/lib/3rdparty/libxml2/xzlib.c
···11/**
22- * xzlib.c: front end for the transparent suport of lzma compression
22+ * xzlib.c: front end for the transparent support of lzma compression
33 * at the I/O layer, based on an example file from lzma project
44 *
55 * See Copyright for the status of this software.
···7171 int err; /* error code */
7272 char *msg; /* error message */
7373 /* lzma stream */
7474- int init; /* is the iniflate stream initialized */
7474+ int init; /* is the inflate stream initialized */
7575 lzma_stream strm; /* stream structure in-place (not a pointer) */
7676 char padding1[32]; /* padding allowing to cope with possible
7777 extensions of above structure without
+1-1
sdk/lib/3rdparty/libxml2/xzlib.h
···11/**
22- * xzlib.h: header for the front end for the transparent suport of lzma
22+ * xzlib.h: header for the front end for the transparent support of lzma
33 * compression at the I/O layer
44 *
55 * See Copyright for the status of this software.