Regex bug in internal viewer

Discussion of bugs and problems found in Altap Salamander. In your reports, please be as descriptive as possible, and report one incident per report. Do not post crash reports here, send us the generated bug report by email instead, please.
User avatar
mdruiter
Posts: 263
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Regex bug in internal viewer

Post by mdruiter »

I encountered a weird bug when searching for a regular expression in the internal viewer.

Try this:
- save this (or enclosed) file:

Code: Select all

1 XXXXXX_CCCCCCCCCC

3 XXXXXX_AAAAAAAA
4 XXXXXX_BBBBBBBB

6 XXXXXX_AAAAAAAA XXXXXX_BBBBBBBB
- open it in the internal viewer
- search for this regular expression (forward, not whole word, case insensitive):

Code: Select all

XXXXXX_AAAAAAAA|XXXXXX_BBBBBBBB|XXXXXX_CCCCCCCCCC|YYY_DDDDDDDDDD|YYY_EEEEEEEEEE|YYY_FFFFFFFF|YYY_GGGGGGGGGGG|YYY_HHHHHHHH|ZZZ_YYY_IIIIIIII|YYY_JJJJJJJJJ|YYY_KKKKKKKKK|YYY_LLLL|YYY_MMMMMMMMMM
- press F3 to find the next occurrence
- press F3 to find the next occurrence

After finding line 1, line 4 is found and highlighted, and then the last part of line 6 (both XXXXXX_BBBBBBBB. :?
I would expect to find XXXXXX_AAAAAAAA as well, in lines 3 and 6! :(

If I press Shift+F3 to search backwards, all occurrences are found.
Attachments
regexbug.txt
Test file
(311 Bytes) Downloaded 305 times
User avatar
Ether
Posts: 1471
Joined: 10 May 2007, 16:08
Location: Czech Republic
Contact:

Re: Regex bug in internal viewer

Post by Ether »

I can confirm this, though I have no idea what causes this. The bug seems to manifest only when all the alternatives contain an underscore and only when the expression is of certain length or longer.
Ελληνικά rulez.
Petr Solin
ALTAP Staff
ALTAP Staff
Posts: 1112
Joined: 08 Dec 2005, 09:13
Location: Novy Bor, Czech Republic
Contact:

Re: Regex bug in internal viewer

Post by Petr Solin »

Thanks for finding this bug! I have fixed it and we will it in next beta version. I expect it is not critical.

It was in operators precedence (+ is above &):
original: #define NEXT(p) (((*((p)+1)&0377)<<8) + *((p)+2)&0377)
fixed: #define NEXT(p) (((*((p)+1)&0377)<<8) + (*((p)+2)&0377))
(original NEXT cannot never give result over 255 which was neccessary it this case)
User avatar
mdruiter
Posts: 263
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Regex bug in Find too

Post by mdruiter »

I found a very similar thing in Find Files and Directories.

Try this:
- save this (or enclosed) file:

Code: Select all

1 N_PL
- in that directory, press Ctrl+F
- search for files containing this regular expression (not whole word, case insensitive):

Code: Select all

XXXXXXXX|XXXX|XXXXXX|N_PL|XXXXXXX|XXXXXXX|XXXXX|XXXXXXXXXXXXX|XXXXXXXXXXXXX|XXXXXX|XXXXXXXXXXX|XXXXXXXXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXX|XXXXXXXXX|XXXXXXXX|XXXXXXXX|XXXXXXXX
The file will not be found! :(
If I remove the last character of the regular expression, the file is found as expected.

I think not finding files is a little more critical than not finding parts in a file.
Attachments
findthis.txt
Example file
(208 Bytes) Downloaded 323 times
Petr Solin
ALTAP Staff
ALTAP Staff
Posts: 1112
Joined: 08 Dec 2005, 09:13
Location: Novy Bor, Czech Republic
Contact:

Re: Regex bug in internal viewer

Post by Petr Solin »

Thanks for report! Find uses the same library, so it is fixed too. I have found this library also in Renamer and FTP Search plugins, but this bug has already been fixed there (unfortunately this fix has not been propagated back to Salamander).
User avatar
mdruiter
Posts: 263
Joined: 22 Feb 2006, 15:33
Location: Amsterdam, The Netherlands
Contact:

Re: Regex bug in internal viewer

Post by mdruiter »

Great! I'll wait! :-)
Post Reply