[Lazarus] TMask revisited
José Mejuto
joshyfun at gmail.com
Tue Oct 26 13:37:46 CEST 2021
El 24/10/2021 a las 15:48, Bart via lazarus escribió:
>> It looks like escaping does not work as advertised?
> Seems like escaping is NOT supported in ranges or sets, but only outside them?
> If that is the case (and by design) then, with [mocRange] enabled, you
> can only have '-' in a range if the range starts with '-'?
Hello,
You found a bug, there is a missing check in the Compile procedure, just
in the last lines of the function, where if every previous check fails
it assumes a "CharInASet" (OptionalChar) and it must check if
OptionalChars are allowed and if they are not add it as literal. The fix
is quite easy:
-------------------------
end else begin
if (lMask[j]=FMaskEscapeChar) and
(eMaskOpcodeEscapeChar in FMaskOpcodesAllowed) then begin
// next is optional char in set or literal
inc(j,lCPLength);
if j<=cMaskLimit then begin
lCPLength:=UTF8Length(@lMask[j]);
end else begin
Exception_IncompleteMask();
end;
end;
//FIX
if eMaskOpcodeOptionalChar in FMaskOpcodesAllowed
then begin
Add(TMaskOpCode.OptionalChar);
Add(lCPLength, at lMask[j]);
lLast:=TMaskOpCode.OptionalChar;
end else begin
Add(TMaskOpCode.Literal);
Add(lCPLength, at lMask[j]);
inc(cMatchMinimumLiteralBytes,lCPLength);
if
cMatchMaximumLiteralBytes<High(cMatchMaximumLiteralBytes) then
inc(cMatchMaximumLiteralBytes,lCPLength);
lLast:=TMaskOpCode.Literal;
end;
//FIX-END
end;
inc(j,lCPLength);
--------------------------
Anyway it should be more clear in the GitHub repo when push the update.
--
More information about the lazarus
mailing list