You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
632 B
C

24 years ago
#include "byte.h"
/* byte_chr returns the smallest integer i between 0 and len-1
19 years ago
* inclusive such that one[i] equals needle, or len if not found. */
size_t byte_chr(const void* haystack, size_t len, char needle) {
24 years ago
register char c=needle;
register const char* s=haystack;
register const char* t=s+len;
for (;;) {
if (s==t || *s==c) break;
++s;
if (s==t || *s==c) break;
++s;
if (s==t || *s==c) break;
++s;
if (s==t || *s==c) break;
++s;
24 years ago
}
return (size_t)(s-(const char*)haystack);
24 years ago
}