Hello
This patch adds support for the 'eq' and 'neq' operators, in a way so that
they are just aliases for the '=' and '!=' operators.
This patch is really just a 'personal itch' kind of thing to handle the
needs of a customer.
Thanks for the great library,
Phillip Whelan
--- libxml2-2.6.27/xpath.c 2006-11-23 14:25:16.000000000 -0300
+++ libxml2-2.6.27-eq-xpath-patch/xpath.c 2007-01-11 13:10:24.000000000
-0300
@@ -10734,6 +10735,32 @@
}
}
+
+/**
+ * xmlXPathIsEqualityExpr;
+ * @ctxt: the XPath Parser context
+ *
+ * Test if an expresion is an equality expression.
+ *
+ */
+static int xmlXPathIsEqualityExpr(xmlXPathParserContextPtr ctxt)
+{
+ if ( CUR == '=' )
+ return 1;
+
+ if ((CUR == '!') && (NXT(1) == '='))
+ return 1;
+
+ if ((CUR == 'e') && (NXT(1) == 'q'))
+ return 1;
+
+ if ((CUR == 'n') && (NXT(1) == 'e') && (NXT(2) == 'q'))
+ return 1;
+
+ return 0;
+}
+
+
/**
* xmlXPathCompEqualityExpr:
* @ctxt: the XPath Parser context
@@ -10754,15 +10781,23 @@
xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) {
xmlXPathCompRelationalExpr(ctxt);
CHECK_ERROR;
- SKIP_BLANKS;
- while ((CUR == '=') || ((CUR == '!') && (NXT(1) == '='))) {
+ SKIP_BLANKS;
+ while (xmlXPathIsEqualityExpr(ctxt)) {
int eq;
int op1 = ctxt->comp->last;
-
- if (CUR == '=') eq = 1;
+
+ if ((CUR == '='))
+ eq = 1;
+ else if ((CUR == 'e') && (NXT(1) == 'q'))
+ eq = 1;
else eq = 0;
+
NEXT;
- if (!eq) NEXT;
+ if ((!eq) || (eq && CUR == 'q'))
+ NEXT;
+ if ((!eq) && (CUR == 'q'))
+ NEXT;
+
SKIP_BLANKS;
xmlXPathCompRelationalExpr(ctxt);
CHECK_ERROR;
_______________________________________________
xml mailing list, project page http://xmlsoft.org/
[email protected]
http://mail.gnome.org/mailman/listinfo/xml