mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-16 23:37:11 +00:00
(libxml) remove XML_PATTERN
This commit is contained in:
parent
14cd3c1184
commit
1379d895ed
@ -39,7 +39,6 @@ LOCAL_LIBXML_SRC_FILES = $(LIBXML_PATH)/c14n.c \
|
||||
$(LIBXML_PATH)/list.c \
|
||||
$(LIBXML_PATH)/parser.c \
|
||||
$(LIBXML_PATH)/parserInternals.c \
|
||||
$(LIBXML_PATH)/pattern.c \
|
||||
$(LIBXML_PATH)/relaxng.c \
|
||||
$(LIBXML_PATH)/SAX.c \
|
||||
$(LIBXML_PATH)/SAX2.c \
|
||||
|
@ -2447,30 +2447,6 @@ extern __typeof (xmlFreeParserInputBuffer) xmlFreeParserInputBuffer__internal_al
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlFreePattern
|
||||
extern __typeof (xmlFreePattern) xmlFreePattern __attribute((alias("xmlFreePattern__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlFreePattern
|
||||
extern __typeof (xmlFreePattern) xmlFreePattern__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlFreePattern xmlFreePattern__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlFreePatternList
|
||||
extern __typeof (xmlFreePatternList) xmlFreePatternList __attribute((alias("xmlFreePatternList__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlFreePatternList
|
||||
extern __typeof (xmlFreePatternList) xmlFreePatternList__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlFreePatternList xmlFreePatternList__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef bottom_tree
|
||||
#undef xmlFreeProp
|
||||
extern __typeof (xmlFreeProp) xmlFreeProp __attribute((alias("xmlFreeProp__internal_alias")));
|
||||
@ -2511,18 +2487,6 @@ extern __typeof (xmlFreeRefTable) xmlFreeRefTable__internal_alias __attribute((v
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlFreeStreamCtxt
|
||||
extern __typeof (xmlFreeStreamCtxt) xmlFreeStreamCtxt __attribute((alias("xmlFreeStreamCtxt__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlFreeStreamCtxt
|
||||
extern __typeof (xmlFreeStreamCtxt) xmlFreeStreamCtxt__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlFreeStreamCtxt xmlFreeStreamCtxt__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_READER_ENABLED)
|
||||
#ifdef bottom_xmlreader
|
||||
#undef xmlFreeTextReader
|
||||
@ -5839,90 +5803,6 @@ extern __typeof (xmlPathToURI) xmlPathToURI__internal_alias __attribute((visibil
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatternFromRoot
|
||||
extern __typeof (xmlPatternFromRoot) xmlPatternFromRoot __attribute((alias("xmlPatternFromRoot__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatternFromRoot
|
||||
extern __typeof (xmlPatternFromRoot) xmlPatternFromRoot__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatternFromRoot xmlPatternFromRoot__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatternGetStreamCtxt
|
||||
extern __typeof (xmlPatternGetStreamCtxt) xmlPatternGetStreamCtxt __attribute((alias("xmlPatternGetStreamCtxt__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatternGetStreamCtxt
|
||||
extern __typeof (xmlPatternGetStreamCtxt) xmlPatternGetStreamCtxt__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatternGetStreamCtxt xmlPatternGetStreamCtxt__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatternMatch
|
||||
extern __typeof (xmlPatternMatch) xmlPatternMatch __attribute((alias("xmlPatternMatch__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatternMatch
|
||||
extern __typeof (xmlPatternMatch) xmlPatternMatch__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatternMatch xmlPatternMatch__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatternMaxDepth
|
||||
extern __typeof (xmlPatternMaxDepth) xmlPatternMaxDepth __attribute((alias("xmlPatternMaxDepth__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatternMaxDepth
|
||||
extern __typeof (xmlPatternMaxDepth) xmlPatternMaxDepth__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatternMaxDepth xmlPatternMaxDepth__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatternMinDepth
|
||||
extern __typeof (xmlPatternMinDepth) xmlPatternMinDepth __attribute((alias("xmlPatternMinDepth__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatternMinDepth
|
||||
extern __typeof (xmlPatternMinDepth) xmlPatternMinDepth__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatternMinDepth xmlPatternMinDepth__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatternStreamable
|
||||
extern __typeof (xmlPatternStreamable) xmlPatternStreamable __attribute((alias("xmlPatternStreamable__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatternStreamable
|
||||
extern __typeof (xmlPatternStreamable) xmlPatternStreamable__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatternStreamable xmlPatternStreamable__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlPatterncompile
|
||||
extern __typeof (xmlPatterncompile) xmlPatterncompile __attribute((alias("xmlPatterncompile__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlPatterncompile
|
||||
extern __typeof (xmlPatterncompile) xmlPatterncompile__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlPatterncompile xmlPatterncompile__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef bottom_parserInternals
|
||||
#undef xmlPedanticParserDefault
|
||||
extern __typeof (xmlPedanticParserDefault) xmlPedanticParserDefault __attribute((alias("xmlPedanticParserDefault__internal_alias")));
|
||||
@ -8655,66 +8535,6 @@ extern __typeof (xmlStrdup) xmlStrdup__internal_alias __attribute((visibility("h
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlStreamPop
|
||||
extern __typeof (xmlStreamPop) xmlStreamPop __attribute((alias("xmlStreamPop__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlStreamPop
|
||||
extern __typeof (xmlStreamPop) xmlStreamPop__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlStreamPop xmlStreamPop__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlStreamPush
|
||||
extern __typeof (xmlStreamPush) xmlStreamPush __attribute((alias("xmlStreamPush__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlStreamPush
|
||||
extern __typeof (xmlStreamPush) xmlStreamPush__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlStreamPush xmlStreamPush__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlStreamPushAttr
|
||||
extern __typeof (xmlStreamPushAttr) xmlStreamPushAttr __attribute((alias("xmlStreamPushAttr__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlStreamPushAttr
|
||||
extern __typeof (xmlStreamPushAttr) xmlStreamPushAttr__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlStreamPushAttr xmlStreamPushAttr__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlStreamPushNode
|
||||
extern __typeof (xmlStreamPushNode) xmlStreamPushNode __attribute((alias("xmlStreamPushNode__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlStreamPushNode
|
||||
extern __typeof (xmlStreamPushNode) xmlStreamPushNode__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlStreamPushNode xmlStreamPushNode__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_pattern
|
||||
#undef xmlStreamWantsAnyNode
|
||||
extern __typeof (xmlStreamWantsAnyNode) xmlStreamWantsAnyNode __attribute((alias("xmlStreamWantsAnyNode__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlStreamWantsAnyNode
|
||||
extern __typeof (xmlStreamWantsAnyNode) xmlStreamWantsAnyNode__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlStreamWantsAnyNode xmlStreamWantsAnyNode__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef bottom_parserInternals
|
||||
#undef xmlStringCurrentChar
|
||||
extern __typeof (xmlStringCurrentChar) xmlStringCurrentChar __attribute((alias("xmlStringCurrentChar__internal_alias")));
|
||||
@ -9505,18 +9325,6 @@ extern __typeof (xmlTextReaderPreserve) xmlTextReaderPreserve__internal_alias __
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_READER_ENABLED) && defined(LIBXML_PATTERN_ENABLED)
|
||||
#ifdef bottom_xmlreader
|
||||
#undef xmlTextReaderPreservePattern
|
||||
extern __typeof (xmlTextReaderPreservePattern) xmlTextReaderPreservePattern __attribute((alias("xmlTextReaderPreservePattern__internal_alias")));
|
||||
#else
|
||||
#ifndef xmlTextReaderPreservePattern
|
||||
extern __typeof (xmlTextReaderPreservePattern) xmlTextReaderPreservePattern__internal_alias __attribute((visibility("hidden")));
|
||||
#define xmlTextReaderPreservePattern xmlTextReaderPreservePattern__internal_alias
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(LIBXML_READER_ENABLED)
|
||||
#ifdef bottom_xmlreader
|
||||
#undef xmlTextReaderQuoteChar
|
||||
|
@ -15,86 +15,5 @@
|
||||
#include <libxml/tree.h>
|
||||
#include <libxml/dict.h>
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlPattern:
|
||||
*
|
||||
* A compiled (XPath based) pattern to select nodes
|
||||
*/
|
||||
typedef struct _xmlPattern xmlPattern;
|
||||
typedef xmlPattern *xmlPatternPtr;
|
||||
|
||||
/**
|
||||
* xmlPatternFlags:
|
||||
*
|
||||
* This is the set of options affecting the behaviour of pattern
|
||||
* matching with this module
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
XML_PATTERN_DEFAULT = 0, /* simple pattern match */
|
||||
XML_PATTERN_XPATH = 1<<0, /* standard XPath pattern */
|
||||
XML_PATTERN_XSSEL = 1<<1, /* XPath subset for schema selector */
|
||||
XML_PATTERN_XSFIELD = 1<<2 /* XPath subset for schema field */
|
||||
} xmlPatternFlags;
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreePattern (xmlPatternPtr comp);
|
||||
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreePatternList (xmlPatternPtr comp);
|
||||
|
||||
XMLPUBFUN xmlPatternPtr XMLCALL
|
||||
xmlPatterncompile (const xmlChar *pattern,
|
||||
xmlDict *dict,
|
||||
int flags,
|
||||
const xmlChar **namespaces);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPatternMatch (xmlPatternPtr comp,
|
||||
xmlNodePtr node);
|
||||
|
||||
/* streaming interfaces */
|
||||
typedef struct _xmlStreamCtxt xmlStreamCtxt;
|
||||
typedef xmlStreamCtxt *xmlStreamCtxtPtr;
|
||||
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPatternStreamable (xmlPatternPtr comp);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPatternMaxDepth (xmlPatternPtr comp);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPatternMinDepth (xmlPatternPtr comp);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlPatternFromRoot (xmlPatternPtr comp);
|
||||
XMLPUBFUN xmlStreamCtxtPtr XMLCALL
|
||||
xmlPatternGetStreamCtxt (xmlPatternPtr comp);
|
||||
XMLPUBFUN void XMLCALL
|
||||
xmlFreeStreamCtxt (xmlStreamCtxtPtr stream);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlStreamPushNode (xmlStreamCtxtPtr stream,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns,
|
||||
int nodeType);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlStreamPush (xmlStreamCtxtPtr stream,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlStreamPushAttr (xmlStreamCtxtPtr stream,
|
||||
const xmlChar *name,
|
||||
const xmlChar *ns);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlStreamPop (xmlStreamCtxtPtr stream);
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlStreamWantsAnyNode (xmlStreamCtxtPtr stream);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
|
||||
#endif /* __XML_PATTERN_H__ */
|
||||
|
@ -264,12 +264,6 @@ XMLPUBFUN int XMLCALL
|
||||
|
||||
XMLPUBFUN xmlNodePtr XMLCALL
|
||||
xmlTextReaderPreserve (xmlTextReaderPtr reader);
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlTextReaderPreservePattern(xmlTextReaderPtr reader,
|
||||
const xmlChar *pattern,
|
||||
const xmlChar **namespaces);
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
XMLPUBFUN xmlDocPtr XMLCALL
|
||||
xmlTextReaderCurrentDoc (xmlTextReaderPtr reader);
|
||||
XMLPUBFUN xmlNodePtr XMLCALL
|
||||
|
@ -133,15 +133,6 @@ XMLPUBFUN void XMLCALL xmlCheckVersion(int version);
|
||||
#define LIBXML_READER_ENABLED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LIBXML_PATTERN_ENABLED:
|
||||
*
|
||||
* Whether the xmlPattern node selection interface is configured in
|
||||
*/
|
||||
#if 0
|
||||
#define LIBXML_PATTERN_ENABLED
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LIBXML_WRITER_ENABLED:
|
||||
*
|
||||
|
@ -800,11 +800,7 @@ xmlHasFeature(xmlFeature feature)
|
||||
return(0);
|
||||
#endif
|
||||
case XML_WITH_PATTERN:
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
return(1);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
case XML_WITH_WRITER:
|
||||
#ifdef LIBXML_WRITER_ENABLED
|
||||
return(1);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -89,9 +89,6 @@
|
||||
#include <libxml/relaxng.h>
|
||||
#include <libxml/xmlschemas.h>
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#include <libxml/pattern.h>
|
||||
#endif
|
||||
#ifdef LIBXML_C14N_ENABLED
|
||||
#include <libxml/c14n.h>
|
||||
#endif
|
||||
@ -183,11 +180,6 @@ static int nbregister = 0;
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
static int sax1 = 0;
|
||||
#endif /* LIBXML_SAX1_ENABLED */
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
static const char *pattern = NULL;
|
||||
static xmlPatternPtr patternc = NULL;
|
||||
static xmlStreamCtxtPtr patstream = NULL;
|
||||
#endif
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
static const char *xpathquery = NULL;
|
||||
#endif
|
||||
@ -1693,68 +1685,6 @@ static void processNode(xmlTextReaderPtr reader) {
|
||||
printf(" %s\n", value);
|
||||
}
|
||||
}
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (patternc) {
|
||||
xmlChar *path = NULL;
|
||||
int match = -1;
|
||||
|
||||
if (type == XML_READER_TYPE_ELEMENT) {
|
||||
/* do the check only on element start */
|
||||
match = xmlPatternMatch(patternc, xmlTextReaderCurrentNode(reader));
|
||||
|
||||
if (match) {
|
||||
#if defined(LIBXML_TREE_ENABLED)
|
||||
path = xmlGetNodePath(xmlTextReaderCurrentNode(reader));
|
||||
printf("Node %s matches pattern %s\n", path, pattern);
|
||||
#else
|
||||
printf("Node %s matches pattern %s\n",
|
||||
xmlTextReaderConstName(reader), pattern);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (patstream != NULL) {
|
||||
int ret;
|
||||
|
||||
if (type == XML_READER_TYPE_ELEMENT) {
|
||||
ret = xmlStreamPush(patstream,
|
||||
xmlTextReaderConstLocalName(reader),
|
||||
xmlTextReaderConstNamespaceUri(reader));
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "xmlStreamPush() failure\n");
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
patstream = NULL;
|
||||
} else if (ret != match) {
|
||||
#if defined(LIBXML_TREE_ENABLED)
|
||||
if (path == NULL) {
|
||||
path = xmlGetNodePath(
|
||||
xmlTextReaderCurrentNode(reader));
|
||||
}
|
||||
#endif
|
||||
fprintf(stderr,
|
||||
"xmlPatternMatch and xmlStreamPush disagree\n");
|
||||
if (path != NULL)
|
||||
fprintf(stderr, " pattern %s node %s\n",
|
||||
pattern, path);
|
||||
else
|
||||
fprintf(stderr, " pattern %s node %s\n",
|
||||
pattern, xmlTextReaderConstName(reader));
|
||||
}
|
||||
|
||||
}
|
||||
if ((type == XML_READER_TYPE_END_ELEMENT) ||
|
||||
((type == XML_READER_TYPE_ELEMENT) && (empty))) {
|
||||
ret = xmlStreamPop(patstream);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "xmlStreamPop() failure\n");
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
patstream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (path != NULL)
|
||||
xmlFree(path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void streamFile(char *filename) {
|
||||
@ -1780,28 +1710,6 @@ static void streamFile(char *filename) {
|
||||
} else
|
||||
#endif
|
||||
reader = xmlReaderForFile(filename, NULL, options);
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (pattern != NULL) {
|
||||
patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
|
||||
if (patternc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Pattern %s failed to compile\n", pattern);
|
||||
progresult = XMLLINT_ERR_SCHEMAPAT;
|
||||
pattern = NULL;
|
||||
}
|
||||
}
|
||||
if (patternc != NULL) {
|
||||
patstream = xmlPatternGetStreamCtxt(patternc);
|
||||
if (patstream != NULL) {
|
||||
ret = xmlStreamPush(patstream, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "xmlStreamPush() failure\n");
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
patstream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (reader != NULL) {
|
||||
@ -1853,9 +1761,6 @@ static void streamFile(char *filename) {
|
||||
ret = xmlTextReaderRead(reader);
|
||||
while (ret == 1) {
|
||||
if ((debug)
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
|| (patternc)
|
||||
#endif
|
||||
)
|
||||
processNode(reader);
|
||||
ret = xmlTextReaderRead(reader);
|
||||
@ -1905,12 +1810,6 @@ static void streamFile(char *filename) {
|
||||
fprintf(stderr, "Unable to open %s\n", filename);
|
||||
progresult = XMLLINT_ERR_UNCLASS;
|
||||
}
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (patstream != NULL) {
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
patstream = NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_SYS_MMAN_H
|
||||
if (memory) {
|
||||
xmlFreeParserInputBuffer(input);
|
||||
@ -1924,42 +1823,6 @@ static void walkDoc(xmlDocPtr doc) {
|
||||
xmlTextReaderPtr reader;
|
||||
int ret;
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
xmlNodePtr root;
|
||||
const xmlChar *namespaces[22];
|
||||
int i;
|
||||
xmlNsPtr ns;
|
||||
|
||||
root = xmlDocGetRootElement(doc);
|
||||
for (ns = root->nsDef, i = 0;ns != NULL && i < 20;ns=ns->next) {
|
||||
namespaces[i++] = ns->href;
|
||||
namespaces[i++] = ns->prefix;
|
||||
}
|
||||
namespaces[i++] = NULL;
|
||||
namespaces[i] = NULL;
|
||||
|
||||
if (pattern != NULL) {
|
||||
patternc = xmlPatterncompile((const xmlChar *) pattern, doc->dict,
|
||||
0, &namespaces[0]);
|
||||
if (patternc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Pattern %s failed to compile\n", pattern);
|
||||
progresult = XMLLINT_ERR_SCHEMAPAT;
|
||||
pattern = NULL;
|
||||
}
|
||||
}
|
||||
if (patternc != NULL) {
|
||||
patstream = xmlPatternGetStreamCtxt(patternc);
|
||||
if (patstream != NULL) {
|
||||
ret = xmlStreamPush(patstream, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
fprintf(stderr, "xmlStreamPush() failure\n");
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
patstream = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
reader = xmlReaderWalker(doc);
|
||||
if (reader != NULL) {
|
||||
if ((timing) && (!repeat)) {
|
||||
@ -1968,9 +1831,6 @@ static void walkDoc(xmlDocPtr doc) {
|
||||
ret = xmlTextReaderRead(reader);
|
||||
while (ret == 1) {
|
||||
if ((debug)
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
|| (patternc)
|
||||
#endif
|
||||
)
|
||||
processNode(reader);
|
||||
ret = xmlTextReaderRead(reader);
|
||||
@ -1987,12 +1847,6 @@ static void walkDoc(xmlDocPtr doc) {
|
||||
fprintf(stderr, "Failed to crate a reader from the document\n");
|
||||
progresult = XMLLINT_ERR_UNCLASS;
|
||||
}
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (patstream != NULL) {
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
patstream = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* LIBXML_READER_ENABLED */
|
||||
|
||||
@ -2843,9 +2697,6 @@ static void usage(const char *name) {
|
||||
printf("\t--stream : use the streaming interface to process very large files\n");
|
||||
printf("\t--walker : create a reader and walk though the resulting doc\n");
|
||||
#endif /* LIBXML_READER_ENABLED */
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
printf("\t--pattern pattern_value : test the pattern support\n");
|
||||
#endif
|
||||
printf("\t--chkregister : verify the node registration code\n");
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
printf("\t--relaxng schema : do RelaxNG validation against the schema\n");
|
||||
@ -3178,12 +3029,6 @@ main(int argc, char **argv) {
|
||||
(!strcmp(argv[i], "--path"))) {
|
||||
i++;
|
||||
parsePath(BAD_CAST argv[i]);
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
} else if ((!strcmp(argv[i], "-pattern")) ||
|
||||
(!strcmp(argv[i], "--pattern"))) {
|
||||
i++;
|
||||
pattern = argv[i];
|
||||
#endif
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
} else if ((!strcmp(argv[i], "-xpath")) ||
|
||||
(!strcmp(argv[i], "--xpath"))) {
|
||||
@ -3338,21 +3183,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
#endif /* LIBXML_SCHEMAS_ENABLED */
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if ((pattern != NULL)
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
&& (walker == 0)
|
||||
#endif
|
||||
) {
|
||||
patternc = xmlPatterncompile((const xmlChar *) pattern, NULL, 0, NULL);
|
||||
if (patternc == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
"Pattern %s failed to compile\n", pattern);
|
||||
progresult = XMLLINT_ERR_SCHEMAPAT;
|
||||
pattern = NULL;
|
||||
}
|
||||
}
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
for (i = 1; i < argc ; i++) {
|
||||
if ((!strcmp(argv[i], "-encode")) ||
|
||||
(!strcmp(argv[i], "--encode"))) {
|
||||
@ -3406,13 +3236,6 @@ main(int argc, char **argv) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if ((!strcmp(argv[i], "-pattern")) ||
|
||||
(!strcmp(argv[i], "--pattern"))) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
#ifdef LIBXML_XPATH_ENABLED
|
||||
if ((!strcmp(argv[i], "-xpath")) ||
|
||||
(!strcmp(argv[i], "--xpath"))) {
|
||||
@ -3489,10 +3312,6 @@ main(int argc, char **argv) {
|
||||
if (wxschemas != NULL)
|
||||
xmlSchemaFree(wxschemas);
|
||||
xmlRelaxNGCleanupTypes();
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (patternc != NULL)
|
||||
xmlFreePattern(patternc);
|
||||
#endif
|
||||
xmlCleanupParser();
|
||||
xmlMemoryDump();
|
||||
|
@ -40,9 +40,6 @@
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
#include <libxml/xinclude.h>
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#include <libxml/pattern.h>
|
||||
#endif
|
||||
|
||||
#define MAX_ERR_MSG_SIZE 64000
|
||||
|
||||
@ -167,11 +164,6 @@ struct _xmlTextReader {
|
||||
const xmlChar * xinclude_name; /* the xinclude name from dict */
|
||||
xmlXIncludeCtxtPtr xincctxt; /* the xinclude context */
|
||||
int in_xinclude; /* counts for xinclude */
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
int patternNr; /* number of preserve patterns */
|
||||
int patternMax; /* max preserve patterns */
|
||||
xmlPatternPtr *patternTab; /* array of preserve patterns */
|
||||
#endif
|
||||
int preserves; /* level of preserves */
|
||||
int parserFlags; /* the set of options set */
|
||||
@ -1552,18 +1544,6 @@ node_found:
|
||||
}
|
||||
}
|
||||
#endif /* LIBXML_REGEXP_ENABLED */
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if ((reader->patternNr > 0) && (reader->state != XML_TEXTREADER_END) &&
|
||||
(reader->state != XML_TEXTREADER_BACKTRACK)) {
|
||||
int i;
|
||||
for (i = 0;i < reader->patternNr;i++) {
|
||||
if (xmlPatternMatch(reader->patternTab[i], reader->node) == 1) {
|
||||
xmlTextReaderPreserve(reader);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* LIBXML_PATTERN_ENABLED */
|
||||
#ifdef LIBXML_SCHEMAS_ENABLED
|
||||
if ((reader->validate == XML_TEXTREADER_VALIDATE_XSD) &&
|
||||
(reader->xsdValidErrors == 0) &&
|
||||
@ -2124,10 +2104,6 @@ xmlNewTextReader(xmlParserInputBufferPtr input, const char *URI) {
|
||||
ret->dict = ret->ctxt->dict;
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
ret->xinclude = 0;
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
ret->patternMax = 0;
|
||||
ret->patternTab = NULL;
|
||||
#endif
|
||||
return(ret);
|
||||
}
|
||||
@ -2200,16 +2176,6 @@ xmlFreeTextReader(xmlTextReaderPtr reader) {
|
||||
#ifdef LIBXML_XINCLUDE_ENABLED
|
||||
if (reader->xincctxt != NULL)
|
||||
xmlXIncludeFreeContext(reader->xincctxt);
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (reader->patternTab != NULL) {
|
||||
int i;
|
||||
for (i = 0;i < reader->patternNr;i++) {
|
||||
if (reader->patternTab[i] != NULL)
|
||||
xmlFreePattern(reader->patternTab[i]);
|
||||
}
|
||||
xmlFree(reader->patternTab);
|
||||
}
|
||||
#endif
|
||||
if (reader->faketext != NULL) {
|
||||
xmlFreeNode(reader->faketext);
|
||||
@ -3908,59 +3874,6 @@ xmlTextReaderPreserve(xmlTextReaderPtr reader) {
|
||||
return(cur);
|
||||
}
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
/**
|
||||
* xmlTextReaderPreservePattern:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
* @pattern: an XPath subset pattern
|
||||
* @namespaces: the prefix definitions, array of [URI, prefix] or NULL
|
||||
*
|
||||
* This tells the XML Reader to preserve all nodes matched by the
|
||||
* pattern. The caller must also use xmlTextReaderCurrentDoc() to
|
||||
* keep an handle on the resulting document once parsing has finished
|
||||
*
|
||||
* Returns a positive number in case of success and -1 in case of error
|
||||
*/
|
||||
int
|
||||
xmlTextReaderPreservePattern(xmlTextReaderPtr reader, const xmlChar *pattern,
|
||||
const xmlChar **namespaces)
|
||||
{
|
||||
xmlPatternPtr comp;
|
||||
|
||||
if ((reader == NULL) || (pattern == NULL))
|
||||
return(-1);
|
||||
|
||||
comp = xmlPatterncompile(pattern, reader->dict, 0, namespaces);
|
||||
if (comp == NULL)
|
||||
return(-1);
|
||||
|
||||
if (reader->patternMax <= 0) {
|
||||
reader->patternMax = 4;
|
||||
reader->patternTab = (xmlPatternPtr *) xmlMalloc(reader->patternMax *
|
||||
sizeof(reader->patternTab[0]));
|
||||
if (reader->patternTab == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlMalloc failed !\n");
|
||||
return (-1);
|
||||
}
|
||||
}
|
||||
if (reader->patternNr >= reader->patternMax) {
|
||||
xmlPatternPtr *tmp;
|
||||
reader->patternMax *= 2;
|
||||
tmp = (xmlPatternPtr *) xmlRealloc(reader->patternTab,
|
||||
reader->patternMax *
|
||||
sizeof(reader->patternTab[0]));
|
||||
if (tmp == NULL) {
|
||||
xmlGenericError(xmlGenericErrorContext, "xmlRealloc failed !\n");
|
||||
reader->patternMax /= 2;
|
||||
return (-1);
|
||||
}
|
||||
reader->patternTab = tmp;
|
||||
}
|
||||
reader->patternTab[reader->patternNr] = comp;
|
||||
return(reader->patternNr++);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* xmlTextReaderCurrentDoc:
|
||||
* @reader: the xmlTextReaderPtr used
|
||||
@ -5074,19 +4987,6 @@ xmlTextReaderSetup(xmlTextReaderPtr reader,
|
||||
reader->xinclude = 0;
|
||||
reader->in_xinclude = 0;
|
||||
#endif
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
if (reader->patternTab == NULL) {
|
||||
reader->patternNr = 0;
|
||||
reader->patternMax = 0;
|
||||
}
|
||||
while (reader->patternNr > 0) {
|
||||
reader->patternNr--;
|
||||
if (reader->patternTab[reader->patternNr] != NULL) {
|
||||
xmlFreePattern(reader->patternTab[reader->patternNr]);
|
||||
reader->patternTab[reader->patternNr] = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options & XML_PARSE_DTDVALID)
|
||||
reader->validate = XML_TEXTREADER_VALIDATE_DTD;
|
||||
|
@ -63,9 +63,6 @@
|
||||
#include <libxml/dict.h>
|
||||
#include <libxml/encoding.h>
|
||||
#include <libxml/xmlIO.h>
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#include <libxml/pattern.h>
|
||||
#endif
|
||||
#ifdef LIBXML_READER_ENABLED
|
||||
#include <libxml/xmlreader.h>
|
||||
#endif
|
||||
|
@ -48,13 +48,6 @@
|
||||
#include <libxml/xmlerror.h>
|
||||
#include <libxml/threads.h>
|
||||
#include <libxml/globals.h>
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#include <libxml/pattern.h>
|
||||
#endif
|
||||
|
||||
#ifdef LIBXML_PATTERN_ENABLED
|
||||
#define XPATH_STREAMING
|
||||
#endif
|
||||
|
||||
#define TODO \
|
||||
xmlGenericError(xmlGenericErrorContext, \
|
||||
@ -579,9 +572,6 @@ struct _xmlXPathCompExpr {
|
||||
int nb;
|
||||
xmlChar *string;
|
||||
#endif
|
||||
#ifdef XPATH_STREAMING
|
||||
xmlPatternPtr stream;
|
||||
#endif
|
||||
};
|
||||
|
||||
/************************************************************************
|
||||
@ -684,11 +674,6 @@ xmlXPathFreeCompExpr(xmlXPathCompExprPtr comp)
|
||||
if (comp->string != NULL) {
|
||||
xmlFree(comp->string);
|
||||
}
|
||||
#endif
|
||||
#ifdef XPATH_STREAMING
|
||||
if (comp->stream != NULL) {
|
||||
xmlFreePatternList(comp->stream);
|
||||
}
|
||||
#endif
|
||||
if (comp->expr != NULL) {
|
||||
xmlFree(comp->expr);
|
||||
@ -5310,12 +5295,6 @@ xmlXPathFreeParserContext(xmlXPathParserContextPtr ctxt) {
|
||||
xmlFree(ctxt->valueTab);
|
||||
}
|
||||
if (ctxt->comp != NULL) {
|
||||
#ifdef XPATH_STREAMING
|
||||
if (ctxt->comp->stream != NULL) {
|
||||
xmlFreePatternList(ctxt->comp->stream);
|
||||
ctxt->comp->stream = NULL;
|
||||
}
|
||||
#endif
|
||||
xmlXPathFreeCompExpr(ctxt->comp);
|
||||
}
|
||||
xmlFree(ctxt);
|
||||
@ -13208,232 +13187,6 @@ start:
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef XPATH_STREAMING
|
||||
/**
|
||||
* xmlXPathRunStreamEval:
|
||||
* @ctxt: the XPath parser context with the compiled expression
|
||||
*
|
||||
* Evaluate the Precompiled Streamable XPath expression in the given context.
|
||||
*/
|
||||
static int
|
||||
xmlXPathRunStreamEval(xmlXPathContextPtr ctxt, xmlPatternPtr comp,
|
||||
xmlXPathObjectPtr *resultSeq, int toBool)
|
||||
{
|
||||
int max_depth, min_depth;
|
||||
int from_root;
|
||||
int ret, depth;
|
||||
int eval_all_nodes;
|
||||
xmlNodePtr cur = NULL, limit = NULL;
|
||||
xmlStreamCtxtPtr patstream = NULL;
|
||||
|
||||
int nb_nodes = 0;
|
||||
|
||||
if ((ctxt == NULL) || (comp == NULL))
|
||||
return(-1);
|
||||
max_depth = xmlPatternMaxDepth(comp);
|
||||
if (max_depth == -1)
|
||||
return(-1);
|
||||
if (max_depth == -2)
|
||||
max_depth = 10000;
|
||||
min_depth = xmlPatternMinDepth(comp);
|
||||
if (min_depth == -1)
|
||||
return(-1);
|
||||
from_root = xmlPatternFromRoot(comp);
|
||||
if (from_root < 0)
|
||||
return(-1);
|
||||
#if 0
|
||||
printf("stream eval: depth %d from root %d\n", max_depth, from_root);
|
||||
#endif
|
||||
|
||||
if (! toBool) {
|
||||
if (resultSeq == NULL)
|
||||
return(-1);
|
||||
*resultSeq = xmlXPathCacheNewNodeSet(ctxt, NULL);
|
||||
if (*resultSeq == NULL)
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* handle the special cases of "/" amd "." being matched
|
||||
*/
|
||||
if (min_depth == 0) {
|
||||
if (from_root) {
|
||||
/* Select "/" */
|
||||
if (toBool)
|
||||
return(1);
|
||||
xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval,
|
||||
(xmlNodePtr) ctxt->doc);
|
||||
} else {
|
||||
/* Select "self::node()" */
|
||||
if (toBool)
|
||||
return(1);
|
||||
xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, ctxt->node);
|
||||
}
|
||||
}
|
||||
if (max_depth == 0) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (from_root) {
|
||||
cur = (xmlNodePtr)ctxt->doc;
|
||||
} else if (ctxt->node != NULL) {
|
||||
switch (ctxt->node->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_DOCUMENT_NODE:
|
||||
case XML_DOCUMENT_FRAG_NODE:
|
||||
case XML_HTML_DOCUMENT_NODE:
|
||||
cur = ctxt->node;
|
||||
break;
|
||||
case XML_ATTRIBUTE_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_ENTITY_REF_NODE:
|
||||
case XML_ENTITY_NODE:
|
||||
case XML_PI_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
case XML_NOTATION_NODE:
|
||||
case XML_DTD_NODE:
|
||||
case XML_DOCUMENT_TYPE_NODE:
|
||||
case XML_ELEMENT_DECL:
|
||||
case XML_ATTRIBUTE_DECL:
|
||||
case XML_ENTITY_DECL:
|
||||
case XML_NAMESPACE_DECL:
|
||||
case XML_XINCLUDE_START:
|
||||
case XML_XINCLUDE_END:
|
||||
break;
|
||||
}
|
||||
limit = cur;
|
||||
}
|
||||
if (cur == NULL) {
|
||||
return(0);
|
||||
}
|
||||
|
||||
patstream = xmlPatternGetStreamCtxt(comp);
|
||||
if (patstream == NULL) {
|
||||
/*
|
||||
* QUESTION TODO: Is this an error?
|
||||
*/
|
||||
return(0);
|
||||
}
|
||||
|
||||
eval_all_nodes = xmlStreamWantsAnyNode(patstream);
|
||||
|
||||
if (from_root) {
|
||||
ret = xmlStreamPush(patstream, NULL, NULL);
|
||||
if (ret < 0) {
|
||||
} else if (ret == 1) {
|
||||
if (toBool)
|
||||
goto return_1;
|
||||
xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur);
|
||||
}
|
||||
}
|
||||
depth = 0;
|
||||
goto scan_children;
|
||||
next_node:
|
||||
do {
|
||||
nb_nodes++;
|
||||
|
||||
switch (cur->type) {
|
||||
case XML_ELEMENT_NODE:
|
||||
case XML_TEXT_NODE:
|
||||
case XML_CDATA_SECTION_NODE:
|
||||
case XML_COMMENT_NODE:
|
||||
case XML_PI_NODE:
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
ret = xmlStreamPush(patstream, cur->name,
|
||||
(cur->ns ? cur->ns->href : NULL));
|
||||
} else if (eval_all_nodes)
|
||||
ret = xmlStreamPushNode(patstream, NULL, NULL, cur->type);
|
||||
else
|
||||
break;
|
||||
|
||||
if (ret < 0) {
|
||||
/* NOP. */
|
||||
} else if (ret == 1) {
|
||||
if (toBool)
|
||||
goto return_1;
|
||||
xmlXPathNodeSetAddUnique((*resultSeq)->nodesetval, cur);
|
||||
}
|
||||
if ((cur->children == NULL) || (depth >= max_depth)) {
|
||||
ret = xmlStreamPop(patstream);
|
||||
while (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
if ((cur->type != XML_ENTITY_DECL) &&
|
||||
(cur->type != XML_DTD_NODE))
|
||||
goto next_node;
|
||||
}
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
scan_children:
|
||||
if ((cur->children != NULL) && (depth < max_depth)) {
|
||||
/*
|
||||
* Do not descend on entities declarations
|
||||
*/
|
||||
if (cur->children->type != XML_ENTITY_DECL) {
|
||||
cur = cur->children;
|
||||
depth++;
|
||||
/*
|
||||
* Skip DTDs
|
||||
*/
|
||||
if (cur->type != XML_DTD_NODE)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (cur == limit)
|
||||
break;
|
||||
|
||||
while (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
if ((cur->type != XML_ENTITY_DECL) &&
|
||||
(cur->type != XML_DTD_NODE))
|
||||
goto next_node;
|
||||
}
|
||||
|
||||
do {
|
||||
cur = cur->parent;
|
||||
depth--;
|
||||
if ((cur == NULL) || (cur == limit))
|
||||
goto done;
|
||||
if (cur->type == XML_ELEMENT_NODE) {
|
||||
ret = xmlStreamPop(patstream);
|
||||
} else if ((eval_all_nodes) &&
|
||||
((cur->type == XML_TEXT_NODE) ||
|
||||
(cur->type == XML_CDATA_SECTION_NODE) ||
|
||||
(cur->type == XML_COMMENT_NODE) ||
|
||||
(cur->type == XML_PI_NODE)))
|
||||
{
|
||||
ret = xmlStreamPop(patstream);
|
||||
}
|
||||
if (cur->next != NULL) {
|
||||
cur = cur->next;
|
||||
break;
|
||||
}
|
||||
} while (cur != NULL);
|
||||
|
||||
} while ((cur != NULL) && (depth >= 0));
|
||||
|
||||
done:
|
||||
|
||||
#if 0
|
||||
printf("stream eval: checked %d nodes selected %d\n",
|
||||
nb_nodes, retObj->nodesetval->nodeNr);
|
||||
#endif
|
||||
|
||||
if (patstream)
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
return(0);
|
||||
|
||||
return_1:
|
||||
if (patstream)
|
||||
xmlFreeStreamCtxt(patstream);
|
||||
return(1);
|
||||
}
|
||||
#endif /* XPATH_STREAMING */
|
||||
|
||||
/**
|
||||
* xmlXPathRunEval:
|
||||
* @ctxt: the XPath parser context with the compiled expression
|
||||
@ -13462,40 +13215,6 @@ xmlXPathRunEval(xmlXPathParserContextPtr ctxt, int toBool)
|
||||
ctxt->value = NULL;
|
||||
ctxt->valueFrame = 0;
|
||||
}
|
||||
#ifdef XPATH_STREAMING
|
||||
if (ctxt->comp->stream) {
|
||||
int res;
|
||||
|
||||
if (toBool) {
|
||||
/*
|
||||
* Evaluation to boolean result.
|
||||
*/
|
||||
res = xmlXPathRunStreamEval(ctxt->context,
|
||||
ctxt->comp->stream, NULL, 1);
|
||||
if (res != -1)
|
||||
return(res);
|
||||
} else {
|
||||
xmlXPathObjectPtr resObj = NULL;
|
||||
|
||||
/*
|
||||
* Evaluation to a sequence.
|
||||
*/
|
||||
res = xmlXPathRunStreamEval(ctxt->context,
|
||||
ctxt->comp->stream, &resObj, 0);
|
||||
|
||||
if ((res != -1) && (resObj != NULL)) {
|
||||
valuePush(ctxt, resObj);
|
||||
return(0);
|
||||
}
|
||||
if (resObj != NULL)
|
||||
xmlXPathReleaseObject(ctxt->context, resObj);
|
||||
}
|
||||
/*
|
||||
* QUESTION TODO: This falls back to normal XPath evaluation
|
||||
* if res == -1. Is this intended?
|
||||
*/
|
||||
}
|
||||
#endif
|
||||
comp = ctxt->comp;
|
||||
if (comp->last < 0) {
|
||||
xmlGenericError(xmlGenericErrorContext,
|
||||
@ -13606,88 +13325,6 @@ xmlXPathEvaluatePredicateResult(xmlXPathParserContextPtr ctxt,
|
||||
return(0);
|
||||
}
|
||||
|
||||
#ifdef XPATH_STREAMING
|
||||
/**
|
||||
* xmlXPathTryStreamCompile:
|
||||
* @ctxt: an XPath context
|
||||
* @str: the XPath expression
|
||||
*
|
||||
* Try to compile the XPath expression as a streamable subset.
|
||||
*
|
||||
* Returns the compiled expression or NULL if failed to compile.
|
||||
*/
|
||||
static xmlXPathCompExprPtr
|
||||
xmlXPathTryStreamCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
|
||||
/*
|
||||
* Optimization: use streaming patterns when the XPath expression can
|
||||
* be compiled to a stream lookup
|
||||
*/
|
||||
xmlPatternPtr stream;
|
||||
xmlXPathCompExprPtr comp;
|
||||
xmlDictPtr dict = NULL;
|
||||
const xmlChar **namespaces = NULL;
|
||||
xmlNsPtr ns;
|
||||
int i, j;
|
||||
|
||||
if ((!xmlStrchr(str, '[')) && (!xmlStrchr(str, '(')) &&
|
||||
(!xmlStrchr(str, '@'))) {
|
||||
const xmlChar *tmp;
|
||||
|
||||
/*
|
||||
* We don't try to handle expressions using the verbose axis
|
||||
* specifiers ("::"), just the simplied form at this point.
|
||||
* Additionally, if there is no list of namespaces available and
|
||||
* there's a ":" in the expression, indicating a prefixed QName,
|
||||
* then we won't try to compile either. xmlPatterncompile() needs
|
||||
* to have a list of namespaces at compilation time in order to
|
||||
* compile prefixed name tests.
|
||||
*/
|
||||
tmp = xmlStrchr(str, ':');
|
||||
if ((tmp != NULL) &&
|
||||
((ctxt == NULL) || (ctxt->nsNr == 0) || (tmp[1] == ':')))
|
||||
return(NULL);
|
||||
|
||||
if (ctxt != NULL) {
|
||||
dict = ctxt->dict;
|
||||
if (ctxt->nsNr > 0) {
|
||||
namespaces = xmlMalloc(2 * (ctxt->nsNr + 1) * sizeof(xmlChar*));
|
||||
if (namespaces == NULL) {
|
||||
xmlXPathErrMemory(ctxt, "allocating namespaces array\n");
|
||||
return(NULL);
|
||||
}
|
||||
for (i = 0, j = 0; (j < ctxt->nsNr); j++) {
|
||||
ns = ctxt->namespaces[j];
|
||||
namespaces[i++] = ns->href;
|
||||
namespaces[i++] = ns->prefix;
|
||||
}
|
||||
namespaces[i++] = NULL;
|
||||
namespaces[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
stream = xmlPatterncompile(str, dict, XML_PATTERN_XPATH,
|
||||
&namespaces[0]);
|
||||
if (namespaces != NULL) {
|
||||
xmlFree((xmlChar **)namespaces);
|
||||
}
|
||||
if ((stream != NULL) && (xmlPatternStreamable(stream) == 1)) {
|
||||
comp = xmlXPathNewCompExpr();
|
||||
if (comp == NULL) {
|
||||
xmlXPathErrMemory(ctxt, "allocating streamable expression\n");
|
||||
return(NULL);
|
||||
}
|
||||
comp->stream = stream;
|
||||
comp->dict = dict;
|
||||
if (comp->dict)
|
||||
xmlDictReference(comp->dict);
|
||||
return(comp);
|
||||
}
|
||||
xmlFreePattern(stream);
|
||||
}
|
||||
return(NULL);
|
||||
}
|
||||
#endif /* XPATH_STREAMING */
|
||||
|
||||
static int
|
||||
xmlXPathCanRewriteDosExpression(xmlChar *expr)
|
||||
{
|
||||
@ -13756,12 +13393,6 @@ xmlXPathCtxtCompile(xmlXPathContextPtr ctxt, const xmlChar *str) {
|
||||
xmlXPathParserContextPtr pctxt;
|
||||
xmlXPathCompExprPtr comp;
|
||||
|
||||
#ifdef XPATH_STREAMING
|
||||
comp = xmlXPathTryStreamCompile(ctxt, str);
|
||||
if (comp != NULL)
|
||||
return(comp);
|
||||
#endif
|
||||
|
||||
xmlXPathInit();
|
||||
|
||||
pctxt = xmlXPathNewParserContext(str, ctxt);
|
||||
@ -13960,22 +13591,9 @@ xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp,
|
||||
*/
|
||||
void
|
||||
xmlXPathEvalExpr(xmlXPathParserContextPtr ctxt) {
|
||||
#ifdef XPATH_STREAMING
|
||||
xmlXPathCompExprPtr comp;
|
||||
#endif
|
||||
|
||||
if (ctxt == NULL) return;
|
||||
|
||||
#ifdef XPATH_STREAMING
|
||||
comp = xmlXPathTryStreamCompile(ctxt->context, ctxt->base);
|
||||
if (comp != NULL) {
|
||||
if (ctxt->comp != NULL)
|
||||
xmlXPathFreeCompExpr(ctxt->comp);
|
||||
ctxt->comp = comp;
|
||||
if (ctxt->cur != NULL)
|
||||
while (*ctxt->cur != 0) ctxt->cur++;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
xmlXPathCompileExpr(ctxt, 1);
|
||||
/*
|
||||
@ -14026,9 +13644,6 @@ xmlXPathEval(const xmlChar *str, xmlXPathContextPtr ctx) {
|
||||
"xmlXPathEval: evaluation failed\n");
|
||||
res = NULL;
|
||||
} else if ((*ctxt->cur != 0) && (ctxt->comp != NULL)
|
||||
#ifdef XPATH_STREAMING
|
||||
&& (ctxt->comp->stream == NULL)
|
||||
#endif
|
||||
) {
|
||||
xmlXPatherror(ctxt, __FILE__, __LINE__, XPATH_EXPR_ERROR);
|
||||
res = NULL;
|
||||
|
Loading…
Reference in New Issue
Block a user