diff options
author | Mathias Gumz <akira@fluxbox.org> | 2015-05-02 12:04:50 (GMT) |
---|---|---|
committer | Mathias Gumz <akira@fluxbox.org> | 2015-05-02 12:04:50 (GMT) |
commit | 533c9a2aa57cf3fd2967b2a72016322902584986 (patch) | |
tree | bf2ddbc458a10597802e1d857f1046869547e49c | |
parent | e117f5acd6e531b6f77c41cab894d11560050e5c (diff) | |
download | fluxbox-533c9a2aa57cf3fd2967b2a72016322902584986.zip fluxbox-533c9a2aa57cf3fd2967b2a72016322902584986.tar.bz2 |
Fix bug in detecting text in MenuSearch
A bug sneaked into my implementation of Boyer-Moore-Horspool. This lead
to not finding certain patterns. Given the text 'abcdde' and the pattern
'dd', the faulty implementation would not find 'dd':
1. 'ab' does not match, skip 2 (length of pattern)
2. 'cd' does not match, skip 2 (length of pattern) <- the bug.
3. 'de' does not match, end of string
The bug in step 2 is to not use 'd' to detect how far to skip but to
use 'c' (which is not in the skip-table) and thus 2 bytes are skipped).
-rw-r--r-- | src/FbTk/MenuSearch.cc | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/FbTk/MenuSearch.cc b/src/FbTk/MenuSearch.cc index d87bfaf..7efd232 100644 --- a/src/FbTk/MenuSearch.cc +++ b/src/FbTk/MenuSearch.cc | |||
@@ -75,7 +75,7 @@ size_t search_str_bmh(const std::string& text, const std::string& pattern) { | |||
75 | return t+p; | 75 | return t+p; |
76 | } | 76 | } |
77 | } | 77 | } |
78 | t += skip[std::tolower(text[t+p])]; | 78 | t += skip[std::tolower(text[t+plast])]; |
79 | } | 79 | } |
80 | 80 | ||
81 | return std::string::npos; | 81 | return std::string::npos; |