file_systems/QueryParser: Only increment within the operators loop.

If we have a matching operator, we will replace the current item
with a new item, and we may need to process it again. For example,
in cases like "A||B||C", the first pass will turn this into "(A||B)||C",
and so we need to re-process the first item to get "((A||B)||C".

Fixes "Open with..." and some other things following the query parser
refactorings.
This commit is contained in:
Augustin Cavalier
2024-06-26 17:23:11 -04:00
parent eca86a00ae
commit 88911fe61c
+4 -2
View File
@@ -1285,10 +1285,12 @@ Expression<QueryPolicy>::Init(const char* expr, const char** position)
// Second & third passes: && and ||.
int32 nodes = currentExpr->CountItems();
for (ops op = OP_AND; op <= OP_OR; op = (ops)(op + 1)) {
for (int32 i = 0; i < (currentExpr->CountItems() - 1); i++) {
for (int32 i = 0; i < (currentExpr->CountItems() - 1); ) {
ExpressionNode* left = currentExpr->Array() + i;
if (left->op != op)
if (left->op != op) {
i++;
continue;
}
// Find the right-hand expression (may have to jump over now-unused nodes.)
ExpressionNode* right = NULL;