Re: Fast string search
bearophile Wrote: Look better at the code, Oh, now I see. Then this is not correct translation to D. C++ returns correct results. I've fixed bug, but not the one that you see. You can verify this by running C++ version.
Re: Fast string search
Thanks for bug report! Code is very new. Bug manifests itself when substring is in 0 position. Fix: diff --git a/volnitsky.h b/volnitsky.h index a7dbc1f..62d686d 100644 -- a/volnitsky.h +++ b/volnitsky.h @@ -26,7 +26,7 @@ const char* volnitsky(const char* S, const char* Se, const char* SS, con // step through text -for (const char* p = S+step; p = Se-W_size; p+=step) { +for (const char* p = S+step-W_size; p = Se-W_size; p+=step) {
Re: Fast string search
36 - is correct. When not found volnitsky() return pointer to next byte after last byte of s1 (same as std::search()). 24 - I don't know D to tell what it is (use of ptr past end of s1?)