summaryrefslogtreecommitdiff
path: root/chromium/third_party/libxslt/src/libxslt/pattern.c
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/libxslt/src/libxslt/pattern.c')
-rw-r--r--chromium/third_party/libxslt/src/libxslt/pattern.c73
1 files changed, 50 insertions, 23 deletions
diff --git a/chromium/third_party/libxslt/src/libxslt/pattern.c b/chromium/third_party/libxslt/src/libxslt/pattern.c
index 7d660192ac8..c6496732a6b 100644
--- a/chromium/third_party/libxslt/src/libxslt/pattern.c
+++ b/chromium/third_party/libxslt/src/libxslt/pattern.c
@@ -113,7 +113,6 @@ struct _xsltCompMatch {
xmlNsPtr *nsList; /* the namespaces in scope */
int nsNr; /* the number of namespaces in scope */
xsltStepOpPtr steps; /* ops for computation */
- int novar; /* doesn't contain variables */
};
typedef struct _xsltParserContext xsltParserContext;
@@ -342,20 +341,14 @@ xsltCompMatchAdd(xsltParserContextPtr ctxt, xsltCompMatchPtr comp,
xsltAllocateExtra(ctxt->style);
}
if (op == XSLT_OP_PREDICATE) {
- xmlXPathContextPtr xctxt;
+ int flags = 0;
- if (ctxt->style != NULL)
- xctxt = xmlXPathNewContext(ctxt->style->doc);
- else
- xctxt = xmlXPathNewContext(NULL);
#ifdef XML_XPATH_NOVAR
if (novar != 0)
- xctxt->flags = XML_XPATH_NOVAR;
+ flags = XML_XPATH_NOVAR;
#endif
- if (ctxt->style != NULL)
- xctxt->dict = ctxt->style->dict;
- comp->steps[comp->nbStep].comp = xmlXPathCtxtCompile(xctxt, value);
- xmlXPathFreeContext(xctxt);
+ comp->steps[comp->nbStep].comp = xsltXPathCompileFlags(ctxt->style,
+ value, flags);
if (comp->steps[comp->nbStep].comp == NULL) {
xsltTransformError(NULL, ctxt->style, ctxt->elem,
"Failed to compile predicate\n");
@@ -595,8 +588,7 @@ xsltTestCompMatchDirect(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp,
}
ix = 0;
- if ((parent == NULL) || (node->doc == NULL) || isRVT ||
- (comp->novar == 0))
+ if ((parent == NULL) || (node->doc == NULL) || isRVT)
nocache = 1;
if (nocache == 0) {
@@ -1251,6 +1243,34 @@ xsltTestCompMatchList(xsltTransformContextPtr ctxt, xmlNodePtr node,
return(0);
}
+/**
+ * xsltCompMatchClearCache:
+ * @ctxt: a XSLT process context
+ * @comp: the precompiled pattern list
+ *
+ * Clear pattern match cache.
+ */
+void
+xsltCompMatchClearCache(xsltTransformContextPtr ctxt, xsltCompMatchPtr comp) {
+ xsltStepOpPtr sel;
+ xmlXPathObjectPtr list;
+
+ if ((ctxt == NULL) || (comp == NULL))
+ return;
+
+ sel = &comp->steps[0];
+ list = (xmlXPathObjectPtr) XSLT_RUNTIME_EXTRA_LST(ctxt, sel->lenExtra);
+
+ if (list != NULL) {
+ xmlXPathFreeObject(list);
+
+ XSLT_RUNTIME_EXTRA_LST(ctxt, sel->lenExtra) = NULL;
+ XSLT_RUNTIME_EXTRA(ctxt, sel->previousExtra, ptr) = NULL;
+ XSLT_RUNTIME_EXTRA(ctxt, sel->indexExtra, ival) = 0;
+ XSLT_RUNTIME_EXTRA_FREE(ctxt, sel->lenExtra) = NULL;
+ }
+}
+
/************************************************************************
* *
* Dedicated parser for templates *
@@ -1795,9 +1815,7 @@ xsltCompileRelativePathPattern(xsltParserContextPtr ctxt, xmlChar *token, int no
PUSH(XSLT_OP_PARENT, NULL, NULL, novar);
NEXT;
SKIP_BLANKS;
- if ((CUR != 0) && (CUR != '|')) {
- xsltCompileRelativePathPattern(ctxt, NULL, novar);
- }
+ xsltCompileStepPattern(ctxt, NULL, novar);
} else {
ctxt->error = 1;
}
@@ -1862,6 +1880,8 @@ xsltCompileLocationPathPattern(xsltParserContextPtr ctxt, int novar) {
xsltCompileIdKeyPattern(ctxt, name, 1, novar, 0);
xmlFree(name);
name = NULL;
+ if (ctxt->error)
+ return;
if ((CUR == '/') && (NXT(1) == '/')) {
PUSH(XSLT_OP_ANCESTOR, NULL, NULL, novar);
NEXT;
@@ -1972,7 +1992,6 @@ xsltCompilePatternInternal(const xmlChar *pattern, xmlDocPtr doc,
j++;
}
element->nsNr = j;
- element->novar = novar;
#ifdef WITH_XSLT_DEBUG_PATTERN
@@ -2137,8 +2156,15 @@ xsltAddTemplate(xsltStylesheetPtr style, xsltTemplatePtr cur,
xmlHashAddEntry2(style->namedTemplates, cur->name, cur->nameURI, cur);
}
- if (cur->match == NULL)
+ if (cur->match == NULL) {
+ if (cur->name == NULL) {
+ xsltTransformError(NULL, style, cur->elem,
+ "xsl:template: need to specify match or name attribute\n");
+ style->errors++;
+ return(-1);
+ }
return(0);
+ }
priority = cur->priority;
pat = xsltCompilePatternInternal(cur->match, style->doc, cur->elem,
@@ -2364,6 +2390,7 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
case XML_ELEMENT_NODE:
if (node->name[0] == ' ')
break;
+ /* Intentional fall-through */
case XML_ATTRIBUTE_NODE:
case XML_PI_NODE:
name = node->name;
@@ -2401,7 +2428,7 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
list = NULL;
while (list != NULL) {
if (xsltTestCompMatch(ctxt, list, node,
- ctxt->mode, ctxt->modeURI)) {
+ ctxt->mode, ctxt->modeURI) == 1) {
ret = list->template;
priority = list->priority;
break;
@@ -2470,7 +2497,7 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
while ((list != NULL) &&
((ret == NULL) || (list->priority > priority))) {
if (xsltTestCompMatch(ctxt, list, node,
- ctxt->mode, ctxt->modeURI)) {
+ ctxt->mode, ctxt->modeURI) == 1) {
ret = list->template;
priority = list->priority;
break;
@@ -2487,7 +2514,7 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
while ((list != NULL) &&
((ret == NULL) || (list->priority > priority))) {
if (xsltTestCompMatch(ctxt, list, node,
- ctxt->mode, ctxt->modeURI)) {
+ ctxt->mode, ctxt->modeURI) == 1) {
ret = list->template;
priority = list->priority;
break;
@@ -2500,7 +2527,7 @@ xsltGetTemplate(xsltTransformContextPtr ctxt, xmlNodePtr node,
while ((list != NULL) &&
((ret == NULL) || (list->priority > priority))) {
if (xsltTestCompMatch(ctxt, list, node,
- ctxt->mode, ctxt->modeURI)) {
+ ctxt->mode, ctxt->modeURI) == 1) {
ret = list->template;
priority = list->priority;
break;
@@ -2515,7 +2542,7 @@ keyed_match:
while ((list != NULL) &&
((ret == NULL) || (list->priority > priority))) {
if (xsltTestCompMatch(ctxt, list, node,
- ctxt->mode, ctxt->modeURI)) {
+ ctxt->mode, ctxt->modeURI) == 1) {
ret = list->template;
priority = list->priority;
break;