PM Bart wroteI renamed mocOptionaChar to mocSet and added some comments in the code.
@José: are these comments correct?
I'm still strugling with the difference between mocRange and mocSet (previously mocOptionalChar).
Consider the following mask: [a-c]
With [mocRange] this matches 'a', 'b', or 'c', but not '-'. With [mocSet] this matches 'a', '-' or 'c', but not 'b'. That's clear to me.
Mask [ac]
[mocRange]: matches 'a' or 'c'.
[mocSet]: matches 'a' or 'c'.
To me this seems as [mocRange] is equivalent to [mocRange,mocSet] So, only mocSet without mocRange has a special meaning. Or they should be mutually exclusive: if you enable mocSet, mocRange should be disabled and vice versa (the latter does not cause any functional change).
Now we take into account the mocEscapeChar and things get a little confusing. IIUC then if mocEscapeChar is eneabled, then EscapeChar+SomeChar is interpreted as just a literal SomeChar.
By default EscapeChar = '\' so '\*' is a literal '*' and '\\' is a literal '\'. And '\-' should mean a literal '-'.
In the following examples RangeAutoReverse is set to FALSE.
Opcodes : [mocRange]
Mask : [a\-]
Filename: -
EMaskError: Missing closing character "]" in mask (offset 5). This is to be expected.
Opcodes : [mocRange,mocEscapeChar]
Mask : [a\-]
Filename: -
EMaskError: Missing closing character "]" in mask (offset 5). ********** ? Escaping the '-' should mean that the mask should match 'a' or '-'
Opcodes : [mocSet]
Mask : [a\-]
Filename: \
Matches
This is expected
Opcodes : [mocSet,mocEscapeChar]
Mask : [a\-]
Filename: \
Matches
Since mocEscapeChar is enabled the sequence '\-' should be interpreted as a literal '-' and it should therefore not match '\'.
Some more oddities:
Opcodes : [mocRange]
Mask : [$\-&]
Filename: $
Matches
Opcodes : [mocRange]
Mask : [$\-&]
Filename: %
Does NOT match
Opcodes : [mocRange]
Mask : [$\-&]
Filename: &
Does NOT match
Actually OK, since the range '\-&' is not reversed and therefore empty (took me a while to realize that)
Opcodes : [mocRange]
Mask : [$\-&]
Filename: -
Does NOT match
Opcodes : [mocRange]
Mask : [$\-&]
Filename: \
Does NOT match
Opcodes : [mocRange,mocEscapeChar]
Mask : [$\-&]
Filename: $
Matches
Opcodes : [mocRange,mocEscapeChar]
Mask : [$\-&]
Filename: %
Does NOT match
Opcodes : [mocRange,mocEscapeChar]
Mask : [$\-&]
Filename: &
Does NOT match ************ ?
Looks like '\-&' is interpreted as an (empty) range, but '\-' should be interpreted as a literal '-', so not a range but a set, and it should match
Opcodes : [mocRange,mocEscapeChar]
Mask : [$\-&]
Filename: -
Does NOT match ************ ?
Same argument as above
Opcodes : [mocRange,mocEscapeChar]
Mask : [$\-&]
Filename: \
Does NOT match
With [mocSet] instead of [mocRange]
Opcodes : [mocSet]
Mask : [$\-&]
Filename: \
Matches
Opcodes : [mocSet,mocEscapeChar]
Mask : [$\-&]
Filename: \
Matches ************ ?
Here enabling mocEscapeChar makes no difference at all. (Checked the same filenames as with mocRange)
Finally this:
Opcodes : [mocRange]
Mask : [\a-c]
Filename: \
Matches
Opcodes : [mocRange,mocEscapeChar]
Mask : [\a-c]
Filename: \
Matches ************ ?
It should not.
It looks like escaping does not work as advertised?
Bart