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

ruby-changes:28098

From: akr <ko1@a...>
Date: Sat, 6 Apr 2013 11:50:18 +0900 (JST)
Subject: [ruby-changes:28098] akr:r40150 (trunk): * ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect if the

akr	2013-04-06 11:50:08 +0900 (Sat, 06 Apr 2013)

  New Revision: 40150

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

  Log:
    * ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect if the
      path contains a NUL.

  Modified files:
    trunk/ChangeLog
    trunk/ext/socket/socket.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 40149)
+++ ChangeLog	(revision 40150)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat Apr  6 11:49:35 2013  Tanaka Akira  <akr@f...>
+
+	* ext/socket/socket.c (rsock_sys_fail_path): Use rb_str_inspect if the
+	  path contains a NUL.
+
 Sat Apr  6 11:39:19 2013  Tanaka Akira  <akr@f...>
 
 	* ext/socket: Improve socket exception message to show socket address.
Index: ext/socket/socket.c
===================================================================
--- ext/socket/socket.c	(revision 40149)
+++ ext/socket/socket.c	(revision 40150)
@@ -28,9 +28,16 @@ rsock_sys_fail_host_port(const char *mes https://github.com/ruby/ruby/blob/trunk/ext/socket/socket.c#L28
 void
 rsock_sys_fail_path(const char *mesg, VALUE path)
 {
-    VALUE message = rb_sprintf("%s for \"%s\"",
-	    mesg, StringValueCStr(path));
-
+    VALUE message;
+    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));
+    }
     rb_sys_fail_str(message);
 }
 

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

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