43 void Bs2BmBadchars(
const uint8_t *needle, uint16_t needle_len, uint8_t *badchars)
52 for (i = 0; i < needle_len; i++)
53 badchars[needle[i]] = 0;
69 uint8_t *
Bs2Bm(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle,
70 uint16_t needle_len,
const uint8_t badchars[])
73 const uint8_t *hmax = haystack + haystack_len;
74 const uint8_t *nmax = needle + needle_len;
76 if (needle_len == 0 || needle_len > haystack_len)
79 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
80 if (*haystack != *n) {
85 return (uint8_t *)haystack;
87 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
89 if (badchars[*h] == 1) {
97 return (uint8_t *)haystack;
119 uint8_t *
Bs2BmNocase(
const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle,
120 uint16_t needle_len,
const uint8_t badchars[])
122 const uint8_t *h, *n;
123 const uint8_t *hmax = haystack + haystack_len;
124 const uint8_t *nmax = needle + needle_len;
126 if (needle_len == 0 || needle_len > haystack_len)
129 for (n = needle; nmax - n <= hmax - haystack; haystack++) {
135 return (uint8_t *)haystack;
137 for (h = haystack+1, n++; nmax - n <= hmax - haystack; h++, n++) {
147 return (uint8_t *)haystack;