From 0f468a5013f125c467e491cf58e74f769efc96e1 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Thu, 1 Apr 2021 18:37:51 +0430 Subject: [PATCH] LibRegex: Test alternatives in the expected order That is, first try to match the left side of the alternation, and then the right side. Fixes part of #6042. --- Userland/Libraries/LibRegex/RegexByteCode.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Userland/Libraries/LibRegex/RegexByteCode.h b/Userland/Libraries/LibRegex/RegexByteCode.h index d8021adf20..150b67c0aa 100644 --- a/Userland/Libraries/LibRegex/RegexByteCode.h +++ b/Userland/Libraries/LibRegex/RegexByteCode.h @@ -334,26 +334,26 @@ public: { // FORKJUMP _ALT - // REGEXP ALT1 + // REGEXP ALT2 // JUMP _END // LABEL _ALT - // REGEXP ALT2 + // REGEXP ALT1 // LABEL _END ByteCode byte_code; empend(static_cast(OpCodeId::ForkJump)); - empend(left.size() + 2); // Jump to the _ALT label + empend(right.size() + 2); // Jump to the _ALT label - for (auto& op : left) + for (auto& op : right) append(move(op)); empend(static_cast(OpCodeId::Jump)); - empend(right.size()); // Jump to the _END label + empend(left.size()); // Jump to the _END label // LABEL _ALT = bytecode.size() + 2 - for (auto& op : right) + for (auto& op : left) append(move(op)); // LABEL _END = alterantive_bytecode.size