Thanks for your comment. By the way, I tried some text searching algorithms 
(some Boyer-Moore, Tuned Boyer-Moore and Quicksearch variations and a normal 
brute force caseless strstr). None of them was as fast as the Palm 
StrStr+StrToLower, the best Boyer-Moore variation was about 1.5 times slower 
than StrStr, the caseless brute force strstr was several times slower compared 
to Palms StrStr (didn't take a exact time on this one, I guess it was about 4 
times slower). The code wasn't optimized, but it's quite interesting that the 
unoptimized Boyer-Moore was significantly faster compared to the also 
unoptimized strstr.

Benjamin



Roger Stringer wrote:

>
>> Subject: Position of first match in text
>> From: "Stadin, Benjamin" <[EMAIL PROTECTED]>
>> Date: Sat, 19 Mar 2005 06:40:09 -0000
>>
>> I'm using StrStr to compute the position of the first match in a text string 
>> (TxtGlueFindString and FindStrInStr don't give the correct Position if the 
>> string doesn't start with the searched string, although they find a 
>> match...).
>>
>> My problem is that I get only the last text match, but I want the first. The 
>> Palm docs say StrStr "Returns a pointer to the first occurrence of token in 
>> str or NULL if not found". Do I miss something or are the docs wrong?
>>
>> Does anybody know a another way to get the first match?
>>
>> That's what I currently do:
>>
>>   Char* strPos;
>>   strPos = StrStr (out, CurrentFilter);
>>   outPos = (UInt32)(strPos) - (UInt32)(out);
>
>
> You should always handle a NULL return from functions such as StrStr()
>
>         Char * strPos = StrStr (out, CurrentFilter);
>         if (strPos == NULL) outPos = -1L; // some default value
>         else outPos = strPos - out;  // pointer arithmetic doesn't need a cast
>
> It would have been very nice if Palm had built an optimized API function
>         StrStrCaseless(...)
>
> Roger Stringer
> Marietta Systems, Inc. (www.rf-tp.com)
>
>


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to