From 88911fe61c6fec614837ad56f3a6c9df998ccc9c Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 26 Jun 2024 17:23:11 -0400 Subject: [PATCH] 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. --- headers/private/file_systems/QueryParser.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/headers/private/file_systems/QueryParser.h b/headers/private/file_systems/QueryParser.h index 5fcb90d3e6..bcc6a29616 100644 --- a/headers/private/file_systems/QueryParser.h +++ b/headers/private/file_systems/QueryParser.h @@ -1285,10 +1285,12 @@ Expression::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;