Browse Source

fix byte_rchr return value (Marcus Winkler)

master
Felix von Leitner 16 years ago
parent
commit
b80507032e
3 changed files with 13 additions and 5 deletions
  1. +1
    -0
      CHANGES
  2. +5
    -5
      byte/byte_rchr.c
  3. +7
    -0
      t.c

+ 1
- 0
CHANGES View File

@@ -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


+ 5
- 5
byte/byte_rchr.c View File

@@ -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
- 0
t.c View File

@@ -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