fix another case in byte_rchr
This commit is contained in:
parent
b65d281e53
commit
a9c687dec6
@ -7,10 +7,10 @@ unsigned long byte_rchr(const void* haystack,unsigned long len,char needle) {
|
|||||||
register const char* s=haystack;
|
register const char* s=haystack;
|
||||||
register const char* t=s+len;
|
register const char* t=s+len;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
--t; if (s>=t) break; if (*t==c) return t-s;
|
--t; if (s>t) break; if (*t==c) return t-s;
|
||||||
--t; if (s>=t) break; if (*t==c) return t-s;
|
--t; if (s>t) break; if (*t==c) return t-s;
|
||||||
--t; if (s>=t) break; if (*t==c) return t-s;
|
--t; if (s>t) break; if (*t==c) return t-s;
|
||||||
--t; if (s>=t) break; if (*t==c) return t-s;
|
--t; if (s>t) break; if (*t==c) return t-s;
|
||||||
}
|
}
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
1
t.c
1
t.c
@ -29,6 +29,7 @@ int main(int argc,char* argv[]) {
|
|||||||
assert(byte_rchr(buf,len,'/')==8);
|
assert(byte_rchr(buf,len,'/')==8);
|
||||||
assert(byte_rchr(buf,len,'@')==len);
|
assert(byte_rchr(buf,len,'@')==len);
|
||||||
assert(byte_rchr(buf,len,'h')==len-1);
|
assert(byte_rchr(buf,len,'h')==len-1);
|
||||||
|
printf("%d\n",byte_rchr("x",1,'x'));
|
||||||
#if 0
|
#if 0
|
||||||
char buf[IP6_FMT+100];
|
char buf[IP6_FMT+100];
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user