diff --git a/CHANGES b/CHANGES index 3dcd6db..dda84a9 100644 --- a/CHANGES +++ b/CHANGES @@ -5,6 +5,7 @@ extended uudecode test. See comment at top for details. fix #include in ndelay*.3 (Hynek Schlawack) add stralloc_diff and stralloc_diffs (my invention) + scan_ip6 returned 1 for "::" (Uwe Ohse) 0.14: avoid bus errors in byte_copy diff --git a/iopause.h2 b/iopause.h2 index 2cf5cf8..4347f01 100644 --- a/iopause.h2 +++ b/iopause.h2 @@ -5,7 +5,7 @@ #define IOPAUSE_POLL #include -#include +#include typedef struct pollfd iopause_fd; #define IOPAUSE_READ POLLIN diff --git a/socket/scan_ip6.c b/socket/scan_ip6.c index 3b64eaf..ad81284 100644 --- a/socket/scan_ip6.c +++ b/socket/scan_ip6.c @@ -27,13 +27,13 @@ unsigned int scan_ip6(const char *s,char ip[16]) for (i=0; i<16; i++) ip[i]=0; for (;;) { if (*s == ':') { - len++; - if (s[1] == ':') { /* Found "::", skip to part 2 */ - s+=2; - len++; + ++len; + ++s; + if (*s == ':') { /* Found "::", skip to part 2 */ + ++len; + ++s; break; } - s++; } i = scan_xlong(s,&u); if (!i) return 0; @@ -59,11 +59,12 @@ unsigned int scan_ip6(const char *s,char ip[16]) break; s++; len++; - } else if (suffixlen!=0) + } else if (suffixlen) break; i = scan_xlong(s,&u); if (!i) { - len--; + if (suffixlen) + --len; break; } if (suffixlen+prefixlen<=12 && s[i]=='.') { diff --git a/t.c b/t.c index f4b2775..c0fdd1d 100644 --- a/t.c +++ b/t.c @@ -7,6 +7,7 @@ #include "socket.h" #include "buffer.h" #include "ip4.h" +#include "ip6.h" #include "mmap.h" #include "open.h" #include "byte.h" @@ -22,6 +23,12 @@ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") int main(int argc,char* argv[]) { + char ip[16]; + char buf[32]; + printf("%d (expect 2)\n",scan_ip6("::",ip)); + printf("%d (expect 3)\n",scan_ip6("::1",ip)); + printf("%d (expect 16)\n",scan_ip6("fec0:0:0:ffff::1/0",ip)); + printf("%.*s\n",fmt_ip6(buf,ip),buf); #if 0 static stralloc s,t; stralloc_copys(&s,"fnord"); @@ -31,6 +38,7 @@ int main(int argc,char* argv[]) { stralloc_copys(&t,"fnordh"); printf("%d\n",stralloc_diff(&s,&t)); stralloc_copys(&t,"hausen"); printf("%d\n",stralloc_diff(&s,&t)); #endif +#if 0 static stralloc s; stralloc_copys(&s,"fnord"); printf("%d\n",stralloc_diffs(&s,"abc")); @@ -38,6 +46,7 @@ int main(int argc,char* argv[]) { printf("%d\n",stralloc_diffs(&s,"fnord")); printf("%d\n",stralloc_diffs(&s,"fnordh")); printf("%d\n",stralloc_diffs(&s,"hausen")); +#endif #if 0 printf("%d\n",case_starts("fnordhausen","FnOrD")); printf("%d\n",case_starts("fnordhausen","blah"));