diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-05-12 09:07:57 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-05-12 09:07:57 +0000 |
commit | 9da4f78db46764be6dae5e7e83ff48cbecb3fb23 (patch) | |
tree | c0805e6c95d6396e28e6129d88905c4dee085f4e /ext | |
parent | 014f2164ed7031a1c31604b290d2ab0cf1deacdc (diff) |
2000-05-12
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r-- | ext/etc/etc.c | 5 | ||||
-rw-r--r-- | ext/md5/depend | 2 | ||||
-rw-r--r-- | ext/socket/socket.c | 20 | ||||
-rw-r--r-- | ext/socket/sockport.h | 2 |
4 files changed, 21 insertions, 8 deletions
diff --git a/ext/etc/etc.c b/ext/etc/etc.c index e5f69f9285..049b94ec8f 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -10,6 +10,11 @@ #include "ruby.h" +#include <sys/types.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #ifdef HAVE_GETPWENT #include <pwd.h> #endif diff --git a/ext/md5/depend b/ext/md5/depend index c99f78ee90..14427861f8 100644 --- a/ext/md5/depend +++ b/ext/md5/depend @@ -1,2 +1,2 @@ -md5c.o: md5c.c md5.h +md5c.o: md5c.c md5.h $(topdir)/config.h md5init.o: md5init.c $(hdrdir)/ruby.h $(topdir)/config.h $(hdrdir)/defines.h md5.h diff --git a/ext/socket/socket.c b/ext/socket/socket.c index bbd5057741..cadadd2b6c 100644 --- a/ext/socket/socket.c +++ b/ext/socket/socket.c @@ -15,6 +15,11 @@ #include "rubysig.h" #include <stdio.h> #include <sys/types.h> + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + #ifndef NT #include <sys/socket.h> #include <netinet/in.h> @@ -538,7 +543,7 @@ ip_addrsetup(host, port) portp = 0; } else if (FIXNUM_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port)); portp = pbuf; } else { @@ -726,7 +731,7 @@ open_inet(class, h, serv, type) host = NULL; } if (FIXNUM_P(serv)) { - snprintf(pbuf, sizeof(pbuf), "%d", FIX2UINT(serv)); + snprintf(pbuf, sizeof(pbuf), "%ld", FIX2UINT(serv)); portp = pbuf; } else { @@ -1748,7 +1753,7 @@ sock_s_getaddrinfo(argc, argv) pptr = NULL; } else if (FIXNUM_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", FIX2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", FIX2INT(port)); pptr = pbuf; } else { @@ -1788,7 +1793,7 @@ sock_s_getnameinfo(argc, argv) int argc; VALUE *argv; { - VALUE sa, af, host, port, flags; + VALUE sa, af = Qnil, host = Qnil, port = Qnil, flags; static char hbuf[1024], pbuf[1024]; char *hptr, *pptr; int fl; @@ -1824,6 +1829,10 @@ sock_s_getnameinfo(argc, argv) host = RARRAY(sa)->ptr[2]; } } + else { + rb_raise(rb_eArgError, "array size should be 3 or 4, %d given", + RARRAY(sa)->len); + } if (NIL_P(host)) { hptr = NULL; } @@ -1837,7 +1846,7 @@ sock_s_getnameinfo(argc, argv) pptr = NULL; } else if (!NIL_P(port)) { - snprintf(pbuf, sizeof(pbuf), "%d", NUM2INT(port)); + snprintf(pbuf, sizeof(pbuf), "%ld", NUM2INT(port)); pptr = pbuf; } else { @@ -1872,7 +1881,6 @@ sock_s_getnameinfo(argc, argv) fl = NUM2INT(flags); } - gotsap: error = getnameinfo(sap, SA_LEN(sap), hbuf, sizeof(hbuf), pbuf, sizeof(pbuf), fl); if (error) { diff --git a/ext/socket/sockport.h b/ext/socket/sockport.h index 99bec91a1a..1639fcf828 100644 --- a/ext/socket/sockport.h +++ b/ext/socket/sockport.h @@ -37,7 +37,7 @@ # define SET_SIN_LEN(si,len) (si)->sin_len = (len) #else # define SIN_LEN(si) sizeof(struct sockaddr_in) -# define SET_SIN_LEN(si,len) (len) +# define SET_SIN_LEN(si,len) #endif #endif |