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

ruby-changes:34852

From: charliesome <ko1@a...>
Date: Fri, 25 Jul 2014 13:18:01 +0900 (JST)
Subject: [ruby-changes:34852] charliesome:r46935 (trunk): * ext/socket/socket.c (sock_gethostname): Use NI_MAXHOST to support

charliesome	2014-07-25 13:17:50 +0900 (Fri, 25 Jul 2014)

  New Revision: 46935

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

  Log:
    * ext/socket/socket.c (sock_gethostname): Use NI_MAXHOST to support
      hostnames longer than 64 characters if the system supports it.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 46934)
+++ ChangeLog	(revision 46935)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Jul 25 13:18:00 2014  Will Farrington  <wfarrington@d...>
+
+	* ext/socket/socket.c (sock_gethostname): Use NI_MAXHOST to support
+	  hostnames longer than 64 characters if the system supports it.
+
 Fri Jul 25 12:21:11 2014  Santiago Pastorino  <santiago@w...>
 
 	* compile.c (defined_expr): make the condition if the receiver
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 46934)
+++ ext/socket/socket.c	(revision 46935)
@@ -1023,10 +1023,15 @@ sock_sysaccept(VALUE sock) https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L1023
 static VALUE
 sock_gethostname(VALUE obj)
 {
-#ifndef HOST_NAME_MAX
-#  define HOST_NAME_MAX 1024
+#if defined(NI_MAXHOST)
+#  define RUBY_MAX_HOST_NAME_LEN NI_MAXHOST
+#elif defined(HOST_NAME_MAX)
+#  define RUBY_MAX_HOST_NAME_LEN HOST_NAME_MAX
+#else
+#  define RUBY_MAX_HOST_NAME_LEN 1024
 #endif
-    char buf[HOST_NAME_MAX+1];
+
+    char buf[RUBY_MAX_HOST_NAME_LEN+1];
 
     rb_secure(3);
     if (gethostname(buf, (int)sizeof buf - 1) < 0)

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

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