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.
 
 
 
 

16 lines
531 B

#include "byte.h"
/* byte_rchr returns the largest integer i between 0 and len-1 inclusive
* such that one[i] equals needle, or len if not found. */
unsigned long byte_rchr(const void* haystack,unsigned long len,char needle) {
register char c=needle;
register const char* s=haystack;
register const char* t=s+len;
for (;;) {
--t; if (s>=t) break; if (*t==c) break;
--t; if (s>=t) break; if (*t==c) break;
--t; if (s>=t) break; if (*t==c) break;
--t; if (s>=t) break; if (*t==c) break;
}
return t-s;
}