Browse Source

fix byte_rchr return value (Marcus Winkler)

master
Felix von Leitner 18 years ago
parent
commit
b80507032e
  1. 1
      CHANGES
  2. 10
      byte/byte_rchr.c
  3. 7
      t.c

1
CHANGES

@ -4,6 +4,7 @@
io_trywrite and io_waitwrite not ignore SIGPIPE
add man pages for libio, safemult
fix possible signal race in io_tryread and io_trywrite (Scott Lamb)
fix byte_rchr return value (Marcus Winkler)
0.18:
make libowfat compile on BSD again (sorry, and thanks to everyone who

10
byte/byte_rchr.c

@ -7,10 +7,10 @@ unsigned long byte_rchr(const void* haystack,unsigned long len,char 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;
--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 t-s;
return len;
}

7
t.c

@ -24,6 +24,12 @@
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
int main(int argc,char* argv[]) {
char buf[100]="/usr/bin/sh";
int len=str_len(buf);
assert(byte_rchr(buf,len,'/')==8);
assert(byte_rchr(buf,len,'@')==len);
assert(byte_rchr(buf,len,'h')==len-1);
#if 0
char buf[IP6_FMT+100];
int i;
char ip[16];
@ -39,6 +45,7 @@ int main(int argc,char* argv[]) {
scan_ip6("2001:7d0:0:f015:0:0:0:1",ip);
buffer_put(buffer_1,buf,fmt_ip6(buf,ip));
buffer_putnlflush(buffer_1);
#endif
#if 0
char buf[100];
int i;

Loading…
Cancel
Save