From 068e1f43584b39e2044ff44c7491c7047d05f202 Mon Sep 17 00:00:00 2001 From: liestrela Date: Sun, 27 Oct 2024 16:07:53 -0300 Subject: [PATCH] Fix if_match comparison for string operands containing operator symbols (#1988) --- src/algebra.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/algebra.cc b/src/algebra.cc index 3e69294e..c3ac1e21 100644 --- a/src/algebra.cc +++ b/src/algebra.cc @@ -40,9 +40,15 @@ * returns the index of the first op character or -1 on error */ int find_match_op(const char *expr) { - unsigned int idx; + unsigned int idx = 0; - for (idx = 0; idx < strlen(expr); idx++) { + /* if first operand is a string, skip it */ + if (expr[idx] == '"') { + for (idx=1; expr[idx] && expr[idx] != '"'; idx++); + idx++; + } + + for (; idx < strlen(expr); idx++) { switch (expr[idx]) { case '=': case '!':