From 64c09eee7ba3f1c811c06b46e060fe22b98b8276 Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Tue, 14 Oct 2014 09:16:09 +0200 Subject: [PATCH] frontend/grammar: Added (limited) support for attribute values in expressions. This is not fully supported yet as expressions may not be used in all places yet. --- src/core/store_lookup.c | 5 ++--- src/frontend/grammar.y | 7 +++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/core/store_lookup.c b/src/core/store_lookup.c index 6aa4095..0c9d361 100644 --- a/src/core/store_lookup.c +++ b/src/core/store_lookup.c @@ -1007,9 +1007,8 @@ sdb_store_matcher_parse_cmp(const char *obj_type, const char *attr, if (! expr) return NULL; - if (sdb_store_expr_eval(expr, NULL, &value)) - return NULL; - if (value.type != SDB_TYPE_STRING) { + if (sdb_store_expr_eval(expr, NULL, &value) || + (value.type != SDB_TYPE_STRING)) { sdb_data_free_datum(&value); if (type != SDB_ATTRIBUTE) return NULL; diff --git a/src/frontend/grammar.y b/src/frontend/grammar.y index 93616ac..0f01bd3 100644 --- a/src/frontend/grammar.y +++ b/src/frontend/grammar.y @@ -495,6 +495,13 @@ expression: $$ = sdb_store_expr_fieldvalue(field); } | + IDENTIFIER '[' IDENTIFIER ']' + { + $$ = sdb_store_expr_attrvalue($3); + free($1); $1 = NULL; + free($3); $3 = NULL; + } + | data { $$ = sdb_store_expr_constvalue(&$1); -- 2.30.2