mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/socket/option.c (inspect_errno): new function.
(sockopt_inspect): use inspect_errno for SO_ERROR. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
af7d8584c5
commit
c160c6e59e
2 changed files with 22 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Feb 22 18:40:04 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* ext/socket/option.c (inspect_errno): new function.
|
||||
(sockopt_inspect): use inspect_errno for SO_ERROR.
|
||||
|
||||
Sun Feb 22 15:11:51 2009 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (Init_Regexp): define Regexp::FIXEDENCODING. [ruby-dev:38066]
|
||||
|
|
|
@ -233,6 +233,22 @@ inspect_int(int level, int optname, VALUE data, VALUE ret)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
inspect_errno(int level, int optname, VALUE data, VALUE ret)
|
||||
{
|
||||
if (RSTRING_LEN(data) == sizeof(int)) {
|
||||
int i;
|
||||
char *err;
|
||||
memcpy((char*)&i, RSTRING_PTR(data), sizeof(int));
|
||||
err = strerror(i);
|
||||
rb_str_catf(ret, " %s (%d)", err, i);
|
||||
return 1;
|
||||
}
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(IPV6_MULTICAST_IF) || defined(IPV6_MULTICAST_LOOP)
|
||||
static int
|
||||
inspect_uint(int level, int optname, VALUE data, VALUE ret)
|
||||
|
@ -429,7 +445,7 @@ sockopt_inspect(VALUE self)
|
|||
case SO_DEBUG: inspected = inspect_int(level, optname, data, ret); break;
|
||||
# endif
|
||||
# if defined(SO_ERROR) /* POSIX */
|
||||
case SO_ERROR: inspected = inspect_int(level, optname, data, ret); break;
|
||||
case SO_ERROR: inspected = inspect_errno(level, optname, data, ret); break;
|
||||
# endif
|
||||
# if defined(SO_TYPE) /* POSIX */
|
||||
case SO_TYPE: inspected = inspect_socktype(level, optname, data, ret); break;
|
||||
|
|
Loading…
Reference in a new issue