[augeas-devel] augeas: master - * src/pathx.c: allow '=' and '!=' of numbers
David Lutterkort
lutter at fedoraproject.org
Thu Feb 19 20:05:41 UTC 2009
Gitweb: http://git.fedorahosted.org/git/augeas.git?p=augeas.git;a=commitdiff;h=3c4112d49ea97556721dfcff1d0aca4d8ab549e3
Commit: 3c4112d49ea97556721dfcff1d0aca4d8ab549e3
Parent: af81d90ab149b0990bba12fc67e7d0d365600342
Author: David Lutterkort <lutter at redhat.com>
AuthorDate: Wed Feb 18 11:18:52 2009 -0800
Committer: David Lutterkort <lutter at redhat.com>
CommitterDate: Wed Feb 18 14:58:44 2009 -0800
* src/pathx.c: allow '=' and '!=' of numbers
---
src/pathx.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/src/pathx.c b/src/pathx.c
index ccb7509..b2872eb 100644
--- a/src/pathx.c
+++ b/src/pathx.c
@@ -478,6 +478,11 @@ static void eval_eq(struct state *state, int neq) {
res = calc_eq_nodeset_string(l->nodeset, r->string, neq);
} else if (r->tag == T_NODESET) {
res = calc_eq_nodeset_string(r->nodeset, l->string, neq);
+ } else if (l->tag == T_NUMBER && r->tag == T_NUMBER) {
+ if (neq)
+ res = (l->number != r->number);
+ else
+ res = (l->number == r->number);
} else {
assert(l->tag == T_STRING);
assert(r->tag == T_STRING);
@@ -744,6 +749,7 @@ static void check_app(struct expr *expr, struct state *state) {
* '=', '!=' : T_NODESET -> T_NODESET -> T_BOOLEAN
* T_STRING -> T_NODESET -> T_BOOLEAN
* T_NODESET -> T_STRING -> T_BOOLEAN
+ * T_NUMBER -> T_NUMBER -> T_BOOLEAN
*
* '+', '-', '*': T_NUMBER -> T_NUMBER -> T_NUMBER
*
@@ -762,7 +768,8 @@ static void check_binary(struct expr *expr, struct state *state) {
case OP_EQ:
case OP_NEQ:
ok = ((l == T_NODESET || l == T_STRING)
- && (r == T_NODESET || r == T_STRING));
+ && (r == T_NODESET || r == T_STRING))
+ || (l == T_NUMBER && r == T_NUMBER);;
res = T_BOOLEAN;
break;
case OP_PLUS:
More information about the augeas-devel
mailing list