- Byte const * end_haystack = haystack + haystack_len - needle_len;
- Byte const * end_needle = needle + needle_len ;
-
- /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation
- is the spice of life */
- while (haystack < end_haystack) {
- Byte const *subneedle_l = needle;
- Byte const *subhaystack_l = haystack;
- while (subneedle_l < end_needle) {
- if (*subneedle_l++ != *subhaystack_l++)
- goto next; // yeah. I should be prosecuted.
- }
-
- // completed the needle. Gotcha.
- return (char*) haystack;
- next:
- haystack++;
+ unsigned char const *end_haystack = haystack + haystack_len - needle_len + 1;
+ unsigned char const *end_needle = needle + needle_len;
+
+ /* Ahhh ... Some minimal lowlevel stuff. This *is* nice; Varation
+ is the spice of life */
+ while (haystack < end_haystack)
+ {
+ unsigned char const *subneedle = needle;
+ unsigned char const *subhaystack = haystack;
+ while (subneedle < end_needle)
+ if (*subneedle++ != *subhaystack++)
+ goto next;
+
+ /* Completed the needle. Gotcha. */
+ return (unsigned char *) haystack;
+next:
+ haystack++;