Bug in find-all

Started by tomcatmandu, March 25, 2009, 07:51:34 AM

Previous topic - Next topic

tomcatmandu

I am using Windows XP SP3.  I have read a file into string for searching.

Here are the first few characters of that file printed on the screen with a string slice.  String name is a.





"Rar!260700207144s0000r"



find seems to work ok, but using find-all works a little different.



(find-all "2607" a) will return a lot of hits for "2607" (as it should).



(find-all "260700207144" a) also returns a lot of hits for "2607".

It should be returning a lot of hits for the original search string:

"260700207144".

I am wondering if it is really finding that number of search strings or if the the 00 value in the string is messing up the the returned list.

newdep

#1
I think you have to double quote the find string

(find-all "\000\000\003" data)



or use {000003}
-- (define? (Cornflakes))

tomcatmandu

#2
(find "xxxxxx" data) works just fine without doubling up on the inverse slashes.



If I put double slashes in find-all, it returns an empty list.  If I use left and right braces instead of the double quotation marks, it also returns an empty list. If I use braces and double inverse slashes, it returns an empty list.



The only way I can get it to return anything but the empty list is this:

(find-all "xxxxxx00xxx" data)



Then it chops off the list elements beginnin with the null byte.



I am using version 10.0.2.  I also tried using the UTF-8 version.  Things got really nasty then.  Thanks for you quick reply.

Lutz

#3
In PRCE (Perl Compatible Regular Expressions) a binary zero ends the search pattern. See http://www.newlisp.org/downloads/pcrepattern.html">http://www.newlisp.org/downloads/pcrepattern.html .



But you can have 0's in the searched string:


> (set 's "010202000102" )
"010202000102"
> (find-all "01" s)
("01" "01")
> (find-all "02" s)
("02" "02" "02")
> (find-all "02|01" s)
("01" "02" "02" "01" "02")
> (find-all "0102" s)
("0102" "0102")
>


ps: With 'find-all' all searches are regular expression searches. With 'find' the search is a plain search if no options number is given (see manual).

Lutz

#4
... and the plain search with 'find' may have binary zeros in the search pattern.

tomcatmandu

#5
Thank you guys for your help.



I used the new function "search" that scans file content in an open file.

I believe it will do what I want it to do.



However, the manual states that after a search the file pointer is positioned

to the end of the search string by default.  Incorrect.  The file pointer is

positioned to the beginning of the search string.



I used a bool-flag of true in the third parameter to have it position the

file pointer to the end of the search string.