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

ruby-changes:32418

From: nobu <ko1@a...>
Date: Sat, 4 Jan 2014 19:15:34 +0900 (JST)
Subject: [ruby-changes:32418] nobu:r44497 (trunk): socket.c: format flags

nobu	2014-01-04 19:15:31 +0900 (Sat, 04 Jan 2014)

  New Revision: 44497

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

  Log:
    socket.c: format flags
    
    * ext/socket/socket.c (rsock_syserr_fail_host_port): use format flags,
      '+' to inspect, ' ' to quote unprintables.
    * ext/socket/socket.c (rsock_syserr_fail_path): ditto.
    * ext/socket/socket.c (rsock_syserr_fail_raddrinfo): ditto.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 44496)
+++ ChangeLog	(revision 44497)
@@ -1,4 +1,11 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Sat Jan  4 19:13:34 2014  Nobuyoshi Nakada  <nobu@r...>
+Sat Jan  4 19:15:29 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* ext/socket/socket.c (rsock_syserr_fail_host_port): use format flags,
+	  '+' to inspect, ' ' to quote unprintables.
+
+	* ext/socket/socket.c (rsock_syserr_fail_path): ditto.
+
+	* ext/socket/socket.c (rsock_syserr_fail_raddrinfo): ditto.
 
 	* ext/socket/socket.c (rsock_syserr_fail_host_port): add errno
 	  argument version anduse rb_syserr_fail_str() instead of
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 44496)
+++ ext/socket/socket.c	(revision 44497)
@@ -23,10 +23,8 @@ rsock_syserr_fail_host_port(int err, con https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L23
 {
     VALUE message;
 
-    port = rb_String(port);
-
-    message = rb_sprintf("%s for \"%s\" port %s",
-	    mesg, StringValueCStr(host), StringValueCStr(port));
+    message = rb_sprintf("%s for %+"PRIsVALUE" port % "PRIsVALUE"",
+			 mesg, host, port);
 
     rb_syserr_fail_str(err, message);
 }
@@ -43,15 +41,7 @@ rsock_syserr_fail_path(int err, const ch https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L41
     VALUE message;
 
     if (RB_TYPE_P(path, T_STRING)) {
-        if (memchr(RSTRING_PTR(path), '\0', RSTRING_LEN(path))) {
-            path = rb_str_inspect(path);
-            message = rb_sprintf("%s for %s", mesg,
-                    StringValueCStr(path));
-        }
-        else {
-            message = rb_sprintf("%s for \"%s\"", mesg,
-                    StringValueCStr(path));
-        }
+	message = rb_sprintf("%s for % "PRIsVALUE"", mesg, path);
 	rb_syserr_fail_str(err, message);
     }
     else {
@@ -87,7 +77,7 @@ rsock_syserr_fail_raddrinfo(int err, con https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L77
     VALUE str, message;
 
     str = rsock_addrinfo_inspect_sockaddr(rai);
-    message = rb_sprintf("%s for %s", mesg, StringValueCStr(str));
+    message = rb_sprintf("%s for %"PRIsVALUE"", mesg, str);
 
     rb_syserr_fail_str(err, message);
 }

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

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