[前][次][番号順一覧][スレッド一覧]

ruby-changes:43724

From: nobu <ko1@a...>
Date: Tue, 2 Aug 2016 12:37:07 +0900 (JST)
Subject: [ruby-changes:43724] nobu:r55797 (trunk): socket/option.c: inet_ntop

nobu	2016-08-02 12:37:02 +0900 (Tue, 02 Aug 2016)

  New Revision: 55797

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55797

  Log:
    socket/option.c: inet_ntop
    
    * ext/socket/option.c, ext/socket/rubysocket.h (inet_ntop): share
      the fallback definition.  [ruby-core:76646] [Bug #12645]

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/getnameinfo.c
    trunk/ext/socket/option.c
    trunk/ext/socket/rubysocket.h
Index: ext/socket/getnameinfo.c
===================================================================
--- ext/socket/getnameinfo.c	(revision 55796)
+++ ext/socket/getnameinfo.c	(revision 55797)
@@ -117,24 +117,6 @@ static struct afd { https://github.com/ruby/ruby/blob/trunk/ext/socket/getnameinfo.c#L117
 #define ENI_FAMILY	5
 #define ENI_SALEN	6
 
-#ifndef HAVE_INET_NTOP
-static const char *
-inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
-{
-#ifdef HAVE_INET_NTOA
-	struct in_addr in;
-	memcpy(&in.s_addr, addr, sizeof(in.s_addr));
-	snprintf(numaddr, numaddr_len, "%s", inet_ntoa(in));
-#else
-	unsigned long x = ntohl(*(unsigned long*)addr);
-	snprintf(numaddr, numaddr_len, "%d.%d.%d.%d",
-		 (int) (x>>24) & 0xff, (int) (x>>16) & 0xff,
-		 (int) (x>> 8) & 0xff, (int) (x>> 0) & 0xff);
-#endif
-	return numaddr;
-}
-#endif
-
 int
 getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, socklen_t hostlen, char *serv, socklen_t servlen, int flags)
 {
Index: ext/socket/rubysocket.h
===================================================================
--- ext/socket/rubysocket.h	(revision 55796)
+++ ext/socket/rubysocket.h	(revision 55797)
@@ -430,4 +430,12 @@ static inline void rsock_maybe_wait_fd(i https://github.com/ruby/ruby/blob/trunk/ext/socket/rubysocket.h#L430
 #  define MSG_DONTWAIT_RELIABLE 0
 #endif
 
+#if !defined HAVE_INET_NTOP && ! defined _WIN32
+const char *inet_ntop(int, const void *, char *, size_t);
+#elif defined __MINGW32__
+# define inet_ntop(f,a,n,l)      rb_w32_inet_ntop(f,a,n,l)
+#elif defined _MSC_VER && RUBY_MSVCRT_VERSION < 90
+const char *WSAAPI inet_ntop(int, const void *, char *, size_t);
+#endif
+
 #endif
Index: ext/socket/option.c
===================================================================
--- ext/socket/option.c	(revision 55796)
+++ ext/socket/option.c	(revision 55797)
@@ -645,7 +645,7 @@ inspect_timeval_as_interval(int level, i https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L645
  */
 
 #if !defined HAVE_INET_NTOP && ! defined _WIN32
-static const char *
+const char *
 inet_ntop(int af, const void *addr, char *numaddr, size_t numaddr_len)
 {
 #ifdef HAVE_INET_NTOA
@@ -660,10 +660,6 @@ inet_ntop(int af, const void *addr, char https://github.com/ruby/ruby/blob/trunk/ext/socket/option.c#L660
 #endif
     return numaddr;
 }
-#elif defined __MINGW32__
-# define inet_ntop(f,a,n,l)      rb_w32_inet_ntop(f,a,n,l)
-#elif defined _MSC_VER && RUBY_MSVCRT_VERSION < 90
-const char *WSAAPI inet_ntop(int, const void *, char *, size_t);
 #endif
 
 /* Although the buffer size needed depends on the prefixes, "%u" may generate "4294967295".  */
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 55796)
+++ ChangeLog	(revision 55797)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Tue Aug  2 12:37:00 2016  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/socket/option.c, ext/socket/rubysocket.h (inet_ntop): share
+	  the fallback definition.  [ruby-core:76646] [Bug #12645]
+
 Tue Aug  2 04:07:29 2016  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (set_pioinfo_extra): use more reliable way to search

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]