diff options
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | ext/socket/socket.c | 19 | ||||
-rw-r--r-- | io.c | 14 | ||||
-rw-r--r-- | lib/.document | 1 | ||||
-rw-r--r-- | lib/net/.document | 8 |
5 files changed, 40 insertions, 8 deletions
@@ -13,6 +13,12 @@ Thu Jun 24 01:25:21 2004 Shugo Maeda <shugo@ruby-lang.org> * version.h: added declarations of ruby_version, ruby_release_date, ruby_platform. +Thu Jun 24 01:07:15 2004 Yukihiro Matsumoto <matz@ruby-lang.org> + + * ext/socket/socket.c (sock_sockaddr): Socket#gethostbyname() + should give us packed address, not struct sockaddr. + [ruby-core:03053] + Wed Jun 23 22:19:10 2004 Dave Thomas <dave@pragprog.com> * ext/socket/socket.c (sock_s_gethostbyaddr): Work around problem diff --git a/ext/socket/socket.c b/ext/socket/socket.c index 42c4938c6d..0f4ffdd2b2 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -2095,7 +2095,24 @@ sock_sockaddr(addr, len) struct sockaddr *addr; size_t len; { - return rb_str_new((char*)addr, len); + char *ptr; + + switch (addr->sa_family) { + case AF_INET: + ptr = (char*)&((struct sockaddr_in*)addr)->sin_addr.s_addr; + len = sizeof(((struct sockaddr_in*)addr)->sin_addr.s_addr); + break; +#ifdef INET6 + case AF_INET6: + ptr = (char*)&((struct sockaddr_in6*)addr)->sin6_addr.s6_addr; + len = sizeof(((struct sockaddr_in6*)addr)->sin6_addr.s6_addr); + break; +#endif + default: + rb_raise(rb_eSocket, "unknown socket family:%d", addr->sa_family); + break; + } + return rb_str_new(ptr, len); } static VALUE @@ -644,7 +644,7 @@ rb_io_set_pos(io, offset) GetOpenFile(io, fptr); pos = io_seek(fptr, NUM2OFFT(offset), SEEK_SET); - if (pos != 0) rb_sys_fail(fptr->path); + if (pos < 0) rb_sys_fail(fptr->path); clearerr(fptr->f); return OFFT2NUM(pos); @@ -671,7 +671,7 @@ rb_io_rewind(io) OpenFile *fptr; GetOpenFile(io, fptr); - if (io_seek(fptr, 0L, 0) != 0) rb_sys_fail(fptr->path); + if (io_seek(fptr, 0L, 0) < 0) rb_sys_fail(fptr->path); clearerr(fptr->f); if (io == current_file) { gets_lineno -= fptr->lineno; @@ -1937,7 +1937,7 @@ rb_io_close_read(io) fptr->mode &= ~FMODE_READABLE; fptr->f = fptr->f2; fptr->f2 = 0; - if (n != 0) rb_sys_fail(fptr->path); + if (n < 0) rb_sys_fail(fptr->path); return Qnil; } @@ -1981,7 +1981,7 @@ rb_io_close_write(io) n = fclose(fptr->f2); fptr->f2 = 0; fptr->mode &= ~FMODE_WRITABLE; - if (n != 0) rb_sys_fail(fptr->path); + if (n < 0) rb_sys_fail(fptr->path); return Qnil; } @@ -2381,7 +2381,7 @@ rb_fopen(fname, mode) } } #ifdef USE_SETVBUF - if (setvbuf(file, NULL, _IOFBF, 0) != 0) + if (setvbuf(file, NULL, _IOFBF, 0) < 0) rb_warn("setvbuf() can't be honoured for %s", fname); #endif #ifdef __human68k__ @@ -2424,7 +2424,7 @@ rb_fdopen(fd, mode) } #ifdef USE_SETVBUF - if (setvbuf(file, NULL, _IOFBF, 0) != 0) + if (setvbuf(file, NULL, _IOFBF, 0) < 0) rb_warn("setvbuf() can't be honoured (fd=%d)", fd); #endif return file; @@ -3278,7 +3278,7 @@ rb_io_reopen(argc, argv, file) rb_sys_fail(fptr->path); } #ifdef USE_SETVBUF - if (setvbuf(fptr->f, NULL, _IOFBF, 0) != 0) + if (setvbuf(fptr->f, NULL, _IOFBF, 0) < 0) rb_warn("setvbuf() can't be honoured for %s", RSTRING(fname)->ptr); #endif diff --git a/lib/.document b/lib/.document index e93b0e63e2..989f6c0ffb 100644 --- a/lib/.document +++ b/lib/.document @@ -19,6 +19,7 @@ find.rb generator.rb logger.rb matrix.rb +net observer.rb optionparser.rb pathname.rb diff --git a/lib/net/.document b/lib/net/.document new file mode 100644 index 0000000000..6332bb9e7e --- /dev/null +++ b/lib/net/.document @@ -0,0 +1,8 @@ +ftp.rb +http.rb +https.rb +imap.rb +pop.rb +smtp.rb +smtps.rb +telnet.rb |