[TC10.00] Searching in files to be always successful in finding nothing

Bug reports will be moved here when the described bug has been fixed

Moderators: white, Hacker, petermad, Stefan2

Post Reply
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

[TC10.00] Searching in files to be always successful in finding nothing

Post by *white »

HISTORY.TXT wrote: 31.03.21 Fixed: Find files, find text: If "RegEx (2)" is checked, accept empty text, and search as .* (32/64)
This is similar to going to the supermarket when you have little time and you know you are not going to buy anything and you check every item for sail in the first aisle.

If the Find text field is empty you should internally pretend the Find text check mark is not checked.

Why would you want to slow down your program by opening every found file and checking every character on the first line (which may be the whole file)?

If you want to persist in going to the supermarket to be successful in buying nothing, I want to suggest to check only the first item in the first aisle:

Code: Select all

.?
A?
Or check nothing at all at the first aisle:

Code: Select all

(?:)
A{0}
()
Or check the beginning of the aisle before the first item.

Code: Select all

^
\A  - Doesn't work correctly.


Bug with \A

Searching for ^ and searching for \A should result in the same files. However when searching for \A, files with only empty lines in them are not found.

(this doesn't happen with older versions of Total Commander)



Bug with empty files (zero-byte files)

It seems like an exception was programmed for empty files to always fail when the find text field is not empty. This is of course correct when searching for normal text. This is not correct for non-empty regular expressions because regular expressions are capable of matching nothing.

When searching the contents of files with regular expression .* , empty files are not found. Same for the alternative regular expressions mentioned above.

Searching for nothing normal text (empty string) should result in the same files when searching for regular expression nothing (for example A{0}).

(in addition, folders are also not found in contrast with when searching with the Find text field empty)



Nothing more to say. I'm off to the supermarket to buy you know what ;)
User avatar
Hacker
Moderator
Moderator
Posts: 13052
Joined: 2003-02-06, 14:56 UTC
Location: Bratislava, Slovakia

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *Hacker »

white,
I'm off to the supermarket to buy you know what ;)
Nothing? ;)

Roman
Mal angenommen, du drückst Strg+F, wählst die FTP-Verbindung (mit gespeichertem Passwort), klickst aber nicht auf Verbinden, sondern fällst tot um.
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *white »

Hacker wrote: 2022-03-13, 11:05 UTC white,
I'm off to the supermarket to buy you know what ;)
Nothing? ;)

Roman
Exactly :D
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *white »

white wrote: 2022-03-13, 10:26 UTC Bug with \A

Searching for ^ and searching for \A should result in the same files. However when searching for \A, files with only empty lines in them are not found.

(this doesn't happen with older versions of Total Commander)
This problem is fixed in TC10.50b3.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *ghisler(Author) »

That must be because I updated to the latest version of the RegEx library, which was also about finding zero length matches:
https://www.ghisler.ch/board/viewtopic.php?t=76139
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *white »

2ghisler(Author)
HISTORY.TXT wrote: 31.03.21 Fixed: Find files, find text: If "RegEx (2)" is checked, accept empty text, and search as .* (32/64)
Testing this again with TC10 and looking at the performance, I think you already fixed this in later changes of TC10.00.

That leaves one issue:
  • TC10.50b4 is still skipping empty files (zero-byte files) when searching the contents of files with non empty regular expressions.
You won't change that behavior?
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *ghisler(Author) »

You won't change that behavior?
I think it's rather pointless to search with a regular expression finding nothing, because it would find all files.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *white »

ghisler(Author) wrote: 2022-05-10, 14:21 UTC
You won't change that behavior?
I think it's rather pointless to search with a regular expression finding nothing, because it would find all files.
Then why doesn't it find all files?

Users may make errors when constructing regular expressions resulting in an expression that also finds nothing. Your program should return the correct results or else they could be fooled and make wrong decisions.

Perhaps someone is working on a complex regular expression and temporarily want to find al files and then adjust it.

I think it's rather pointless to judge people for doing things in a certain way. Your program should work correctly no matter how people use it.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *ghisler(Author) »

I have checked it in the debugger - actually TC also searches in empty files. However, the regular expression function isn't called on an empty string, so regular expressions matching nothing didn't find 0 byte files. I only need to change a < to a <= check, so I will try it.
Author of Total Commander
https://www.ghisler.com
User avatar
white
Power Member
Power Member
Posts: 4594
Joined: 2003-11-19, 08:16 UTC
Location: Netherlands

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *white »

Tested OK using TC10.50b5 32-bit and 64bit.
User avatar
ghisler(Author)
Site Admin
Site Admin
Posts: 48021
Joined: 2003-02-04, 09:46 UTC
Location: Switzerland
Contact:

Re: [TC10.00] Searching in files to be always successful in finding nothing

Post by *ghisler(Author) »

Please let me know if this causes any other problems with RegEx searches!
Author of Total Commander
https://www.ghisler.com
Post Reply