[Lazarus] TMask revisited

Bart bartjunk64 at gmail.com
Tue Oct 26 18:48:18 CEST 2021

On Tue, Oct 26, 2021 at 1:38 PM José Mejuto via lazarus
<lazarus at lists.lazarus-ide.org> wrote:

> You found a bug,

I thought about it some more.
Inside a range everything is treated as a literal, the only exceptions are:
1. [?]
2. '!' as the first char in a range when [mocNegateGroup] is enabled.
3. '-' if it is NOT the first char (or the first after the negating
!), it is then the indicator for a range

So, even '*' is taken as a literal.
Since '*' as a wildchar in a range would make no sense at all, to me
this sounds OK.
A '?' in a range is forbidden (EMaskError: Invalid character "?" in
mask), except for the [?].
Having '?' interpreted as a wildcard in a range would also make no sense.
The only things one could possibly imagine to have to escape in a range are:
1. ? for a literal ?: currently forbidden
2. * for a literal *: currently * works as a literal
3. - for a literal -: solvable by having -  as the first char in a range.
4. The EscapeChar itself.

Given this, I would think that:
1. escaping inside a range is not necessary: everything in a range is
literal except for the 3 cases outlined above.
2. having a '?' could also be accepted as long as it is not the first
character in the range specification, even [!?] could be allowed: any
char but not a '?'.
Point 2 would need (probably a minor) change to the CompileRange method.

It would then be simply a matter of documenting this.


More information about the lazarus mailing list