[Lazarus] MatchesWindowsMask('[x]','[x]') return False

classic Classic list List threaded Threaded
30 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
On Thu, Mar 19, 2020 at 6:37 PM Bart <[hidden email]> wrote:

> It's on my ToDo list (as long as other devels don't object to this.
> I intend to have an Options property for that, with for now
> moCaseSensitive and moDisableSets.

Attached is a rough version of the intended patch.
The MatchesMaskList() functions needed several overloads to make all
previously possible calls (2,3, or 4 parameters) work as before.

Please test.

--
Bart

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

masks.disablesets.diff (16K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
On Thu, Mar 19, 2020 at 10:40 PM Bart <[hidden email]> wrote:

> Please test.

By that I mean that
MatchesMask('[x]','[x]',[moDisableSets]) should return True now.

--
Bart
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list

Hi Bart,

I did something similar yesterday:

TMask.InitMaskString(const AValue: String; const CaseSensitive: Boolean; const UseSets: Boolean = True);
TMask.Create(const AValue: String; const CaseSensitive: Boolean = False; const UseSets: Boolean = True);
TMaskList.Create(const AValue: String; ASeparator: Char = ';'; const CaseSensitive: Boolean = False; const UseSets: Boolean = True);

function MatchesMask(const FileName, Mask: String; const CaseSensitive: Boolean = False; const UseSets: Boolean = True): Boolean;
function MatchesWindowsMask(const FileName, Mask: String; const CaseSensitive: Boolean = False; const UseSets: Boolean = False): Boolean;
function MatchesMaskList(const FileName, Mask: String; Separator: Char = ';'; const CaseSensitive: Boolean = False; const UseSets: Boolean = True): Boolean;
function MatchesWindowsMaskList(const FileName, Mask: String; Separator: Char = ';'; const CaseSensitive: Boolean = False; const UseSets: Boolean = False): Boolean;

The only code change is in TMask.InitMaskString
-      '[': AddCharSet;
+      '[': if fUseSets then
+             AddCharSet
+           else
+             AddChar;

This works fine.

Easy to implement it as Options.

Regards,

Rolf

Am 19.03.2020 um 18:37 schrieb Bart via lazarus:
On Thu, Mar 19, 2020 at 8:25 AM Rolf Wetjen via lazarus
[hidden email] wrote:

seems that this isn't your favourite option.
Without any context, I cannot comment on this.

Ok, what's about an additional TMask property to control the useage of
sets (default should be true for Delphi compatibility) and additional
options for the MatchesMask and MatchesWindowsMask functions?
It's on my ToDo list (as long as other devels don't object to this.
I intend to have an Options property for that, with for now
moCaseSensitive and moDisableSets.
There will be an overloaded constructor TMask,Create((const AValue:
String; ASeparator: Char = ';'; const Options: TMaskOptions = []);
(By default CaseSensitive and DisableSets must be off for backwards
compatibility)

It will only be for trunk and the next stable major release (so it
won't go into fixes branch) anyhow.



Virenfrei. www.avast.com

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus

masks.pas.patch (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list

Same change in code as I used for my patch.

So, yes: working.

Rolf

Am 19.03.2020 um 22:40 schrieb Bart via lazarus:
On Thu, Mar 19, 2020 at 6:37 PM Bart [hidden email] wrote:

It's on my ToDo list (as long as other devels don't object to this.
I intend to have an Options property for that, with for now
moCaseSensitive and moDisableSets.
Attached is a rough version of the intended patch.
The MatchesMaskList() functions needed several overloads to make all
previously possible calls (2,3, or 4 parameters) work as before.

Please test.



Virenfrei. www.avast.com

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
On Fri, Mar 20, 2020 at 9:12 AM Rolf Wetjen via lazarus
<[hidden email]> wrote:

> Same change in code as I used for my patch.
>
> So, yes: working.

OK.
I prefer the Options parameter over another Boolean, mainly because
you never know if another use-case might raise the need for yet
another parameter.


--
Bart
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
On Fri, Mar 20, 2020 at 10:47 AM Bart <[hidden email]> wrote:

> I prefer the Options parameter over another Boolean, mainly because
> you never know if another use-case might raise the need for yet
> another parameter.

Committed in r62782
--
Bart
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
Hi Bart,

I'm just looking for an other error in the implementation when sets are
used:

Helloworld / He[lo]?orld - False
Helloworld / He[lo]*orld - True
Helloworld / He[lo]world - False

So, it's not the final patch but not that importand as I don't think
that sets are used so much.

Regards

Rolf


--
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
On Sat, Mar 21, 2020 at 12:07 PM Rolf Wetjen via lazarus
<[hidden email]> wrote:

> Helloworld / He[lo]?orld - False
The mask only caters for either Hel?world or Heo?world, so that is correct

> Helloworld / He[lo]*orld - True
The mask only caters for either Hel*world or Heo*world, so that is
correct (the first one matches)

> Helloworld / He[lo]world - False
The mask only caters for either Helworld or Heoworld, so that is correct

No bug here.

Note that sets don't work like a RegEx where you can specify e.g. n
times either 'l' or 'o'.

--
Bart
--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
My misunderstanding of a set here.

I'm looking for a better documentation. So, a set compares to only one
charcter in the filename.

Thanks,

Rolf


--
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
Reply | Threaded
Open this post in threaded view
|

Re: [Lazarus] MatchesWindowsMask('[x]','[x]') return False

Free Pascal - Lazarus mailing list
In reply to this post by Free Pascal - Lazarus mailing list
Hi Bart,

I've uploaded a patch for the TMask documentation
(https://bugs.freepascal.org/view.php?id=36798)

Regards

Rolf

Am 20.03.2020 um 19:08 schrieb Bart via lazarus:
> On Fri, Mar 20, 2020 at 10:47 AM Bart <[hidden email]> wrote:
>
>> I prefer the Options parameter over another Boolean, mainly because
>> you never know if another use-case might raise the need for yet
>> another parameter.
> Committed in r62782

--
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus

--
_______________________________________________
lazarus mailing list
[hidden email]
https://lists.lazarus-ide.org/listinfo/lazarus
12