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.
This commit is contained in:
AnotherTest 2021-04-01 18:37:51 +04:30 committed by Andreas Kling
parent 6bbb26fdaf
commit 0f468a5013
Notes: sideshowbarker 2024-07-18 20:55:03 +09:00

View file

@ -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<ByteCodeValueType>(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<ByteCodeValueType>(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