summaryrefslogtreecommitdiff
path: root/ext/socket/socket.c
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 /ext/socket/socket.c
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
Diffstat (limited to 'ext/socket/socket.c')
-rw-r--r--ext/socket/socket.c18
1 files changed, 4 insertions, 14 deletions
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);
}