use sys/poll.h instead of poll.h for iopause

scan_ip6 returned 1 for "::"
master
leitner 22 years ago
parent 98c7cda40a
commit 92594f480b

@ -5,6 +5,7 @@
extended uudecode test. See comment at top for details. extended uudecode test. See comment at top for details.
fix #include in ndelay*.3 (Hynek Schlawack) fix #include in ndelay*.3 (Hynek Schlawack)
add stralloc_diff and stralloc_diffs (my invention) add stralloc_diff and stralloc_diffs (my invention)
scan_ip6 returned 1 for "::" (Uwe Ohse)
0.14: 0.14:
avoid bus errors in byte_copy avoid bus errors in byte_copy

@ -5,7 +5,7 @@
#define IOPAUSE_POLL #define IOPAUSE_POLL
#include <sys/types.h> #include <sys/types.h>
#include <poll.h> #include <sys/poll.h>
typedef struct pollfd iopause_fd; typedef struct pollfd iopause_fd;
#define IOPAUSE_READ POLLIN #define IOPAUSE_READ POLLIN

@ -27,13 +27,13 @@ unsigned int scan_ip6(const char *s,char ip[16])
for (i=0; i<16; i++) ip[i]=0; for (i=0; i<16; i++) ip[i]=0;
for (;;) { for (;;) {
if (*s == ':') { if (*s == ':') {
len++; ++len;
if (s[1] == ':') { /* Found "::", skip to part 2 */ ++s;
s+=2; if (*s == ':') { /* Found "::", skip to part 2 */
len++; ++len;
++s;
break; break;
} }
s++;
} }
i = scan_xlong(s,&u); i = scan_xlong(s,&u);
if (!i) return 0; if (!i) return 0;
@ -59,11 +59,12 @@ unsigned int scan_ip6(const char *s,char ip[16])
break; break;
s++; s++;
len++; len++;
} else if (suffixlen!=0) } else if (suffixlen)
break; break;
i = scan_xlong(s,&u); i = scan_xlong(s,&u);
if (!i) { if (!i) {
len--; if (suffixlen)
--len;
break; break;
} }
if (suffixlen+prefixlen<=12 && s[i]=='.') { if (suffixlen+prefixlen<=12 && s[i]=='.') {

9
t.c

@ -7,6 +7,7 @@
#include "socket.h" #include "socket.h"
#include "buffer.h" #include "buffer.h"
#include "ip4.h" #include "ip4.h"
#include "ip6.h"
#include "mmap.h" #include "mmap.h"
#include "open.h" #include "open.h"
#include "byte.h" #include "byte.h"
@ -22,6 +23,12 @@
__asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx")
int main(int argc,char* argv[]) { 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 #if 0
static stralloc s,t; static stralloc s,t;
stralloc_copys(&s,"fnord"); 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,"fnordh"); printf("%d\n",stralloc_diff(&s,&t));
stralloc_copys(&t,"hausen"); printf("%d\n",stralloc_diff(&s,&t)); stralloc_copys(&t,"hausen"); printf("%d\n",stralloc_diff(&s,&t));
#endif #endif
#if 0
static stralloc s; static stralloc s;
stralloc_copys(&s,"fnord"); stralloc_copys(&s,"fnord");
printf("%d\n",stralloc_diffs(&s,"abc")); 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,"fnord"));
printf("%d\n",stralloc_diffs(&s,"fnordh")); printf("%d\n",stralloc_diffs(&s,"fnordh"));
printf("%d\n",stralloc_diffs(&s,"hausen")); printf("%d\n",stralloc_diffs(&s,"hausen"));
#endif
#if 0 #if 0
printf("%d\n",case_starts("fnordhausen","FnOrD")); printf("%d\n",case_starts("fnordhausen","FnOrD"));
printf("%d\n",case_starts("fnordhausen","blah")); printf("%d\n",case_starts("fnordhausen","blah"));

Loading…
Cancel
Save