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

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

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

Free Pascal - Lazarus mailing list
Hi Lazarus team,

I found this during some error analysis. TMask uses the brackets as a
set indicatior in the mask string. In this case the FMask.MinLength and
FMask.MaxLength are set to 1. The brackets in the test string are not
treated in any special way and so the match fails as the length of the
test string is 3 (tested inside TMask.Matches).

I think that this isn't the expected behavior especially as [ and ] are
regular character for file and path names in windows.

Shall I open a bug report for this?

BR

Rolf Wetjen

(RolfW)



--
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 Sun, Mar 15, 2020 at 1:10 PM Rolf Wetjen via lazarus
<[hidden email]> wrote:

> I think that this isn't the expected behavior especially as [ and ] are
> regular character for file and path names in windows.

MatchesMask doesn;t have an Escape char AFAIK
If you have [[] in the mask, it will match a single [ I guess, but []]
isn't going to work for a single ]...

Please file a bugreport.
Somebody should test this behaviour against Delphi.

--
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 Sun, Mar 15, 2020 at 2:36 PM Bart <[hidden email]> wrote:

> Somebody should test this behaviour against Delphi.

PS. I can't since D7 (the only Delphi I have) doesn't have MatchesMask.

--
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
On Sun, Mar 15, 2020 at 1:10 PM Rolf Wetjen via lazarus
<[hidden email]> wrote:

> I found this during some error analysis.

'[[]x]' as a mask will match '[x]' as filename.
So at least there is a workaround.

--
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
On Sun, Mar 15, 2020 at 2:36 PM Bart <[hidden email]> wrote:

> Somebody should test this behaviour against Delphi.

I asked on the Dutch Delphi forum.

--
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,

sorry, this isn't a workaround if you get the filenames form
FindFirst/FindNext and want to test against a fixed mask.

My workaround for MatchesWindowsMask is quick' n'dirty too: Replace [
with #17 and ] with #18 in the mask and in the test string. Anyway,
let's wait for the info about Delphi.

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
On Sun, 15 Mar 2020 13:09:55 +0100
Rolf Wetjen via lazarus <[hidden email]> wrote:

> Hi Lazarus team,
>
> I found this during some error analysis. TMask uses the brackets as a
> set indicatior in the mask string. In this case the FMask.MinLength
> and FMask.MaxLength are set to 1. The brackets in the test string are
> not treated in any special way and so the match fails as the length
> of the test string is 3 (tested inside TMask.Matches).
>
> I think that this isn't the expected behavior especially as [ and ]
> are regular character for file and path names in windows.

IMO it should check for \[

Mattias
--
_______________________________________________
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 Sun, Mar 15, 2020 at 8:23 PM Mattias Gaertner via lazarus
<[hidden email]> wrote:

> IMO it should check for \[

Using \ as an escape character isn't really a good choice IMO, since
this function deals with filenames.
I would be more inclined to have an option to disable sets in the mask.

@Rolf: you can do a StringReplace on the filename, changing '[' into
'[[]'. That would do the trick.

Let's wait to hear what Delphi does (got no answer yet).
--
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 Sun, 15 Mar 2020 22:19:21 +0100
Bart via lazarus <[hidden email]> wrote:

> On Sun, Mar 15, 2020 at 8:23 PM Mattias Gaertner via lazarus
> <[hidden email]> wrote:
>
> > IMO it should check for \[  
>
> Using \ as an escape character isn't really a good choice IMO, since
> this function deals with filenames.

So? It is common practice on Unix since decades.

> I would be more inclined to have an option to disable sets in the
> mask.

1. Without backslashing you need sets for ? and * as well.
2. I guess this function exists only for Delphi compatibility. Regular
expression are more versatile anyway.

 
> @Rolf: you can do a StringReplace on the filename, changing '[' into
> '[[]'. That would do the trick.
>
> Let's wait to hear what Delphi does (got no answer yet).

I can't find MatchesWindowMask in Delphi 10.3. I found MatchesMask,
which works the same. It supports [] too and I can't find any other way
than [[].


Mattias
--
_______________________________________________
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

Op 2020-03-16 om 00:05 schreef Mattias Gaertner via lazarus:
>> Using \ as an escape character isn't really a good choice IMO, since
>> this function deals with filenames.
> So? It is common practice on Unix since decades.

Well, euhh, Unix doesn't use backslashes in paths? This would require
already existing code suddenly to escape.


--
_______________________________________________
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 Mon, 16 Mar 2020 00:21:55 +0100
Marco van de Voort via lazarus <[hidden email]> wrote:

> Op 2020-03-16 om 00:05 schreef Mattias Gaertner via lazarus:
> >> Using \ as an escape character isn't really a good choice IMO,
> >> since this function deals with filenames.  
> > So? It is common practice on Unix since decades.  
>
> Well, euhh, Unix doesn't use backslashes in paths? This would require
> already existing code suddenly to escape.

True. Since it exists only for Delphi compatibility it is better to
not change it.

Mattias

--
_______________________________________________
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

Bug #0036798 opened.

Rolf


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
In reply to this post by Free Pascal - Lazarus mailing list
On Mon, Mar 16, 2020 at 12:05 AM Mattias Gaertner via lazarus
<[hidden email]> wrote:

> I can't find MatchesWindowMask in Delphi 10.3. I found MatchesMask,
> which works the same. It supports [] too and I can't find any other way
> than [[].

I implemented that variation because MatchesMask treats wildcards like
*nix does: '*.*' doesn't match 'foo'.
Since this is counterintuitive to Windows users (and most likely not
Delphi comapitble) I implemented MatcesWindowsMask.
See the implementation to see how Windows handles wildcards different
in some (corner) cases.

--
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
On Mon, Mar 16, 2020 at 1:07 AM Mattias Gaertner via lazarus
<[hidden email]> wrote:

> True. Since it exists only for Delphi compatibility it is better to
> not change it.

To be honest, we've already improved our implementation so it can
treat the mask case-sensitve (Delphi doesn't have that option).
It defaults to False so that MatchesMask(Filename, Mask) is compatible
with Delphi.

We could implement a mechanisme to disable sets in the mask.
Either by adding yet another boolean parameter to MatchesMask, or by
having some sort of Options?

--
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 Lazarus team,

what's about to implement an additional completly new TMaskReg class
without sets but in addition with a regular expression option?

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 Tue, Mar 17, 2020 at 8:17 AM Rolf Wetjen via lazarus
<[hidden email]> wrote:

> what's about to implement an additional completly new TMaskReg class
> without sets but in addition with a regular expression option?

Feel free to implement such a thing.
However, if someone is familiar with RegEx's he/she probably won't need it.

--
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 Lazarus team,

seems that this isn't your favourite option.

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?

Can I help with a patch in this way?

BTW, where can I get some info how to update the help files?

Rolf


Am 17.03.2020 um 22:18 schrieb Bart via lazarus:
> On Tue, Mar 17, 2020 at 8:17 AM Rolf Wetjen via lazarus
> <[hidden email]> wrote:
>
>> what's about to implement an additional completly new TMaskReg class
>> without sets but in addition with a regular expression option?
> Feel free to implement such a thing.
> However, if someone is familiar with RegEx's he/she probably won't need it.
>

--
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

Op 19/03/2020 om 08:25 schreef Rolf Wetjen via lazarus:
>
> BTW, where can I get some info how to update the help files?
>

https://wiki.freepascal.org/How_To_Make_Lazarus_Docs

to rebuild:

Basically (on linux) I run the fixdocs.sh fpc docs repository, and 
build_lcl_chm.sh  in lazarus/lcl/docs.

The linux installation requires a texlive and a tex4ht installation iirc.

to change:

submit patch files for the documentation source files *.xml
(rtl,lcl,lazutils) or *.tex (prog,user,ref,fpdoc)

There might also be some more details in discussions on the forum.

Trunk (FPC+Lazarus) CHM's from january can be downloaded at
http://www.stack.nl/~marcov/doc-chmbeta.zip

--
_______________________________________________
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
Am 19.03.20 um 08:25 schrieb Rolf Wetjen via lazarus:
>
> BTW, where can I get some info how to update the help files?

This one should be enough, on Linux you would do:

New folder, change to new folder and then:

svn co https://svn.freepascal.org/svn/lazarus/binaries/docs/chm/

Then in Lazarus IDE set the path to checkout directory.

The URL should also be enough for tortoise or what you use on windows.

John

--
_______________________________________________
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
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.


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