[augeas-devel] augeas: master - * src/pathx.c: allow '(' Expr ')'
David Lutterkort
lutter at fedoraproject.org
Thu Feb 19 20:05:55 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=c53f5d8586b709242b91c47ead51f768a126188b
Commit: c53f5d8586b709242b91c47ead51f768a126188b
Parent: 568860264e88e688e85832a94b545eb4d155f3d4
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Wed Feb 18 13:25:14 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Feb 18 14:58:45 2009 -0800
* src/pathx.c: allow '(' Expr ')'
---
src/internal.h | 1 +
src/pathx.c | 13 +++++++++++--
tests/xpath.tests | 3 +++
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/src/internal.h b/src/internal.h
index 5cd8605..582cbd4 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -363,6 +363,7 @@ typedef enum {
PATHX_ENOEQUAL,
PATHX_ENOMEM,
PATHX_EPRED,
+ PATHX_EPAREN,
PATHX_ESLASH,
PATHX_EINTERNAL,
PATHX_ETYPE
diff --git a/src/pathx.c b/src/pathx.c
index b68085d..25446e5 100644
--- a/src/pathx.c
+++ b/src/pathx.c
@@ -35,7 +35,8 @@ static const char *const errcodes[] = {
"string missing ending ' or \"",
"expected '='",
"allocation failed",
- "unmatched ']'",
+ "unmatched '['",
+ "unmatched '('",
"expected a '/'",
"internal error", /* PATHX_EINTERNAL */
"type error" /* PATHX_ETYPE */
@@ -1353,7 +1354,7 @@ static void parse_function_call(struct state *state) {
} while (match(state, ','));
if (! match(state, ')')) {
- STATE_ERROR(state, PATHX_EDELIM);
+ STATE_ERROR(state, PATHX_EPAREN);
return;
}
}
@@ -1384,6 +1385,7 @@ static void parse_function_call(struct state *state) {
* PrimaryExpr ::= Literal
* | Number
* | FunctionCall
+ * | '(' Expr ')'
*
*/
static void parse_primary_expr(struct state *state) {
@@ -1391,6 +1393,13 @@ static void parse_primary_expr(struct state *state) {
parse_literal(state);
} else if (peek(state, "0123456789")) {
parse_number(state);
+ } else if (match(state, '(')) {
+ parse_expr(state);
+ CHECK_ERROR;
+ if (! match(state, ')')) {
+ STATE_ERROR(state, PATHX_EPAREN);
+ return;
+ }
} else {
parse_function_call(state);
}
diff --git a/tests/xpath.tests b/tests/xpath.tests
index e4c6fa2..8f89f3c 100644
--- a/tests/xpath.tests
+++ b/tests/xpath.tests
@@ -157,3 +157,6 @@ test number-gt /files/etc/hosts/*[count(alias) > 2]
test pred-or /files/etc/hosts/*[canonical = 'localhost' or alias = 'localhost']
/files/etc/hosts/1
+
+test pred-and-or /files/etc/hosts/*[(canonical = 'localhost' or alias = 'localhost') and ipaddr = '127.0.0.1']
+ /files/etc/hosts/1
More information about the augeas-devel
mailing list