Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

17 lines
552 B

  1. #include "byte.h"
  2. /* byte_chr returns the smallest integer i between 0 and len-1
  3. * inclusive such that one[i] equals needle, or len it not found. */
  4. unsigned long byte_chr(const void* haystack, unsigned long len, char needle) {
  5. register char c=needle;
  6. register const char* s=haystack;
  7. register const char* t=s+len;
  8. for (;;) {
  9. if (s==t) break; if (*s==c) break; ++s;
  10. if (s==t) break; if (*s==c) break; ++s;
  11. if (s==t) break; if (*s==c) break; ++s;
  12. if (s==t) break; if (*s==c) break; ++s;
  13. }
  14. return s-(const char*)haystack;
  15. }