summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-03-04 19:17:45 +0100
committerCarlos Garnacho <carlosg@gnome.org>2020-03-04 20:24:17 +0100
commitd478d391ad00ffff772f65e61c418b80ca9dc6fe (patch)
treec97bb65d305035a0fd2cf00644172e069553353c
parente0e55febc595a2f2f080ed8748e0af43349e19e9 (diff)
downloadtracker-d478d391ad00ffff772f65e61c418b80ca9dc6fe.tar.gz
libtracker-data: Make parser check more assertive
Besides the standard: 'SELECT' '(' Expression 'AS' Var ')' we support the non-standard: 'SELECT' Expression 'AS' Var And tried to handle both in the same piece of code. The incongruence was that we would use _accept(')') on both, in order to catch the former, but still go through silently on the latter. Change this code so it's clearer that we do _expect() the closing parens in the first case. This is merely reassuring as the parser tree generation stage would catch the real syntax error, but makes code more in line with the actual intent.
-rw-r--r--src/libtracker-data/tracker-sparql.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index 9c5bde454..84130b916 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2438,8 +2438,14 @@ translate_SelectClause (TrackerSparql *sparql,
}
tracker_sparql_swap_builder (sparql, old);
- } else if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OPEN_PARENS) ||
- _check_in_rule (sparql, NAMED_RULE_Expression)) {
+ } else {
+ gboolean parens = FALSE;
+
+ if (_accept (sparql, RULE_TYPE_LITERAL, LITERAL_OPEN_PARENS))
+ parens = TRUE;
+ else if (!_check_in_rule (sparql, NAMED_RULE_Expression))
+ break;
+
if (!first)
_append_string (sparql, ", ");
@@ -2460,9 +2466,9 @@ translate_SelectClause (TrackerSparql *sparql,
}
tracker_sparql_swap_builder (sparql, old);
- _accept (sparql, RULE_TYPE_LITERAL, LITERAL_CLOSE_PARENS);
- } else {
- break;
+
+ if (parens)
+ _expect (sparql, RULE_TYPE_LITERAL, LITERAL_CLOSE_PARENS);
}
first = FALSE;