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!\026\007\000\207\144s\000\000\r"
find seems to work ok, but using find-all works a little different.
(find-all "\026\007" a) will return a lot of hits for "\026\007" (as it should).
(find-all "\026\007\000\207\144" a) also returns a lot of hits for "\026\007".
It should be returning a lot of hits for the original search string:
"\026\007\000\207\144".
I am wondering if it is really finding that number of search strings or if the the \000 value in the string is messing up the the returned list.
Bug in find-all
-
- Posts: 3
- Joined: Fri May 23, 2008 9:24 pm
- Location: Birmingham, AL
(find "\xxx\xxx" 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 "\xxx\xxx\000\xxx" 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.
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 "\xxx\xxx\000\xxx" 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.
In PRCE (Perl Compatible Regular Expressions) a binary zero ends the search pattern. See http://www.newlisp.org/downloads/pcrepattern.html .
But you can have 0's in the searched string:
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).
But you can have 0's in the searched string:
Code: Select all
> (set 's "\001\002\002\000\001\002" )
"\001\002\002\000\001\002"
> (find-all "\001" s)
("\001" "\001")
> (find-all "\002" s)
("\002" "\002" "\002")
> (find-all "\002|\001" s)
("\001" "\002" "\002" "\001" "\002")
> (find-all "\001\002" s)
("\001\002" "\001\002")
>
-
- Posts: 3
- Joined: Fri May 23, 2008 9:24 pm
- Location: Birmingham, AL
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.
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.