mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 17:39:23 +02:00
Masks: rename TMask.Compile to TMask.PrepareCompile and make it set fMaskIsCompiled to False.
TMaskUTF8.Compile is now the base method for compiling the mask. Add a comment about fMaskIsCompiled. Reasons: - TMask.Compile did not really compile anything. - fMaskIsCompiled should only be set to True if (real) compilation of the mask is succesfull
This commit is contained in:
parent
11a35ff5e6
commit
3b1bba21ff
@ -194,7 +194,7 @@ type
|
|||||||
fMaskOpcodesAllowed: TMaskOpCodes;
|
fMaskOpcodesAllowed: TMaskOpCodes;
|
||||||
// EscapeChar forces next char to be a literal one, not a wildcard.
|
// EscapeChar forces next char to be a literal one, not a wildcard.
|
||||||
fMaskEscapeChar: Char;
|
fMaskEscapeChar: Char;
|
||||||
procedure Compile; virtual;
|
procedure PrepareCompile;
|
||||||
class procedure Exception_InvalidCharMask(const aMaskChar: string; aOffset: integer=-1); static;
|
class procedure Exception_InvalidCharMask(const aMaskChar: string; aOffset: integer=-1); static;
|
||||||
class procedure Exception_MissingCloseChar(const aMaskChar: string; aOffset: integer=-1); static;
|
class procedure Exception_MissingCloseChar(const aMaskChar: string; aOffset: integer=-1); static;
|
||||||
class procedure Exception_IncompleteMask(); static;
|
class procedure Exception_IncompleteMask(); static;
|
||||||
@ -250,7 +250,7 @@ type
|
|||||||
constructor Create(const aMask: String; aOptions: TMaskOptions); overload;
|
constructor Create(const aMask: String; aOptions: TMaskOptions); overload;
|
||||||
deprecated 'Use Create with TMaskOpCodes params.'; // in Lazarus 2.3, remove in 2.5.
|
deprecated 'Use Create with TMaskOpCodes params.'; // in Lazarus 2.3, remove in 2.5.
|
||||||
|
|
||||||
procedure Compile; override;
|
procedure Compile; virtual;
|
||||||
function Matches(const aStringToMatch: String): Boolean; virtual;
|
function Matches(const aStringToMatch: String): Boolean; virtual;
|
||||||
function MatchesWindowsMask(const AFileName: String): Boolean;
|
function MatchesWindowsMask(const AFileName: String): Boolean;
|
||||||
deprecated 'Create with TMaskWindows.Create, then call Matches.'; // in Lazarus 2.3, remove in 2.5.
|
deprecated 'Create with TMaskWindows.Create, then call Matches.'; // in Lazarus 2.3, remove in 2.5.
|
||||||
@ -669,12 +669,12 @@ begin
|
|||||||
Add(P^+aValue);
|
Add(P^+aValue);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMaskBase.Compile;
|
procedure TMaskBase.PrepareCompile;
|
||||||
begin
|
begin
|
||||||
fMaskCompiled := nil;
|
fMaskCompiled := nil;
|
||||||
fMaskCompiledAllocated := 0;
|
fMaskCompiledAllocated := 0;
|
||||||
fMaskCompiledIndex := 0;
|
fMaskCompiledIndex := 0;
|
||||||
fMaskIsCompiled:=true;
|
fMaskIsCompiled:=False;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TMaskBase.Exception_InvalidCharMask(const aMaskChar: string;
|
class procedure TMaskBase.Exception_InvalidCharMask(const aMaskChar: string;
|
||||||
@ -1037,10 +1037,7 @@ end;
|
|||||||
|
|
||||||
procedure TMaskUTF8.Compile;
|
procedure TMaskUTF8.Compile;
|
||||||
begin
|
begin
|
||||||
inherited Compile;
|
PrepareCompile;
|
||||||
//if Compile fails and a new call to Matches is made and Mask is unchanged
|
|
||||||
//then Matches simply returns False, when raising the exception again would be more appropriate IMO (BB)
|
|
||||||
fMaskIsCompiled:=False;
|
|
||||||
if fCaseSensitive then
|
if fCaseSensitive then
|
||||||
fMask:=fOriginalMask
|
fMask:=fOriginalMask
|
||||||
else
|
else
|
||||||
@ -1072,6 +1069,11 @@ begin
|
|||||||
|
|
||||||
SetLength(fMaskCompiled,fMaskCompiledIndex);
|
SetLength(fMaskCompiled,fMaskCompiledIndex);
|
||||||
fMaskCompiledLimit:=fMaskCompiledIndex-1;
|
fMaskCompiledLimit:=fMaskCompiledIndex-1;
|
||||||
|
{
|
||||||
|
fMaskIsCompiled Indicates that Compile was succesfull
|
||||||
|
If you override this method make sure that it is only set to True if
|
||||||
|
the overridden method also succeeds!
|
||||||
|
}
|
||||||
fMaskIsCompiled:=True;
|
fMaskIsCompiled:=True;
|
||||||
|
|
||||||
//writeln('Compile end.');
|
//writeln('Compile end.');
|
||||||
|
Loading…
Reference in New Issue
Block a user