Dear community:
http://teminian.tumblr.com/post/35031097964I humbly introduce PosBMH unit, my personal implementation of Boyer-Moore-Horspool string search algorithm, which is de facto standard for string search. Most of the Pascal implementations I found on the Internet were broken themselves so I made it myself.
To use, create a TPosBMH object, call PosBMH() for doing initial search, and PosBMHNext() for next occurrence. It'll return nil if there's no occurrence. For substring and parameter the function accepts string, but internal operation and return values are always PChar for further operation or manipulation.
Because currently I use only Tumblr myself, I posted the full source code to the posting itself. Just copy and paste the source code to new pas file and use at your convenience.
Basically, the license is the same as LCL(=modified LGPL) so you don't have to worry about licensing issues, but please let me know or write in your introduction of the application you have used "PosBMH from Robert Teminian" and I'll be happy sharing my humble codes.
Hope you like it. Happy coding!
Robert Teminian, a.k.a. T.Robin
http://teminian.tumblr.comUpdate:
I didn't recognize I can attach a file in the posting here. For your convenience, I've attached unit file in this posting so feel free to get the source in either way.
Of course, stopping by and saying hello in my Tumblr page is always welcome.
Also, there was some trivial grammar error in the source code that howardpc pointed out. The error is fixed in both my Tumblr posting and the attachment here.