diff options
| author | Soikk | 2022-08-13 19:12:50 +0200 |
|---|---|---|
| committer | Soikk | 2022-08-13 19:12:50 +0200 |
| commit | b30b33d598039b2f708783271e8c2f65613a24d4 (patch) | |
| tree | 566d943c18111888ceaf53113879e725371b6621 /src/bm.c | |
| parent | 4b721332d570f53719894af922c22b7cba146b18 (diff) | |
| download | soikk-DB-b30b33d598039b2f708783271e8c2f65613a24d4.tar.xz soikk-DB-b30b33d598039b2f708783271e8c2f65613a24d4.tar.zst | |
Got rid of old functionalities (strnatcmp, BM).
Diffstat (limited to 'src/bm.c')
| -rw-r--r-- | src/bm.c | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/bm.c b/src/bm.c deleted file mode 100644 index d2afb0a..0000000 --- a/src/bm.c +++ /dev/null @@ -1,44 +0,0 @@ -#include "db.h" - -/* - Implementation of the tuned Boyer-Moore string search algorithm, - as defined here: - http://www-igm.univ-mlv.fr/~lecroq/string/tunedbm.html#SECTION00195 - and here: - http://www-igm.univ-mlv.fr/~lecroq/string/node14.html#SECTION00140 -*/ - -#define ASIZE 128 // alphabet size, need to include most ascii characters - -static void preBmBc(char *x, int m, int bmBc[]){ - for(int i = 0; i < ASIZE; ++i) - bmBc[i] = m; - for(int i = 0; i < m - 1; ++i) - bmBc[x[i]] = m - i - 1; -} - -// x is the needle, y is the haystack -// Should be called TUNEDBM, called BM for simplicity -ssize_t BM(char *x, int m, char *y, int n){ - int j, k, shift, bmBc[ASIZE]; - - /* Preprocessing */ - preBmBc(x, m, bmBc); - shift = bmBc[x[m-1]]; - bmBc[x[m-1]] = 0; - - /* Searching */ - j = 0; - while(j < n){ - k = bmBc[y[j + m -1]]; - while(k != 0){ - j += k; k = bmBc[y[j + m - 1]]; - j += k; k = bmBc[y[j + m - 1]]; - j += k; k = bmBc[y[j + m - 1]]; - } - if(memcmp(x, y + j, m) == 0 && j < n) - return j; - j += shift; /* shift */ - } - return -1; -} |
