summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-04 10:15:31 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-04 10:15:31 +0000
commit5b0fb1aaddad03e111606e0d0eaf8ed9c9f7b0b6 (patch)
tree7fbf8d5a9225cd64b39683fcbc7bc29a0aacfb7b
parenta3f2fe4e4def0d9e616b0107bf619e3eaf0d788a (diff)
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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog9
-rw-r--r--ext/socket/socket.c18
2 files changed, 12 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 4176a62..8e60e30 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,11 @@
-Sat Jan 4 19:13:34 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Sat Jan 4 19:15:29 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * 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
diff --git a/ext/socket/socket.c b/ext/socket/socket.c
index c7fc5b7..ca256b6 100644
--- a/ext/socket/socket.c
+++ b/ext/socket/socket.c
@@ -23,10 +23,8 @@ rsock_syserr_fail_host_port(int err, const char *mesg, VALUE host, VALUE port)
{
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 char *mesg, VALUE path)
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, const char *mesg, VALUE rai)
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);
}