From a9457c2f2bd1412ef2c8ed9dc7e468eff6453bf4 Mon Sep 17 00:00:00 2001 From: Bart <9132501-flyingsheep@users.noreply.gitlab.com> Date: Sat, 1 Jan 2022 13:20:27 +0100 Subject: [PATCH] LazUtils: Masks: if mocSet, mocRange of mocAnyCharOrNone is enabled an unescaped '[' must always start such a construct and cannot be a literal. --- components/lazutils/masks.pas | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/components/lazutils/masks.pas b/components/lazutils/masks.pas index 8a7f574559..03922f32c7 100644 --- a/components/lazutils/masks.pas +++ b/components/lazutils/masks.pas @@ -938,15 +938,15 @@ begin begin if ([mocSet,mocRange, mocAnyCharOrNone] * fMaskOpcodesAllowed <> []) - and not - ( - ([mocSet,mocRange]*fMaskOpCodesAllowed = []) //only mocAnyCharOrNone enabled - and - (fMaskInd'?')// next char is not '?', so basically then the '[' is a literal - ) + //in this case the '[' always mus be the start of a Range, a Set or AnyCharOrNone then - CompileRange - else begin //either mocSet,MocRange and mocAnyCharOrNone are all disabled, or only mocAnyCharOrNone is enabled and the '[' is not followed by a '?' + begin //it's just a bit easier later on if we handle this before we call CompileRange + if ([mocSet,mocRange]*fMaskOpCodesAllowed = []) {only mocAnyCharOrNone enabled} + and (fMaskInd'?') {next char is not '?'} then + Exception_InvalidCharMask(fMask[fMaskInd+1], fMaskInd+1); + CompileRange; + end + else begin //mocSet,MocRange and mocAnyCharOrNone are all disabled { if (fMask[fMaskInd]=FMaskEscapeChar) and (mocEscapeChar in FMaskOpcodesAllowed) then begin //DEAD CODE? //This codepath could only be chosen if, at this point '[' is the escapechar