* error.c (syserr_initialize): use Errno constants as default

errno for subclasses.  [ruby-dev:20241]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2003-05-20 08:18:16 +00:00
parent b614db0432
commit fdc0d3306c
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,8 @@
Tue May 20 17:15:55 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* error.c (syserr_initialize): use Errno constants as default
errno for subclasses. [ruby-dev:20241]
Tue May 20 15:26:25 2003 WATANABE Hirofumi <eban@ruby-lang.org>
* st.h: define ST_DATA_T_DEFINED for portability.
@ -20,7 +25,7 @@ Tue May 20 13:29:04 2003 NAKAMURA Usaku <usa@ruby-lang.org>
Tue May 20 10:51:26 2003 Nobuyoshi Nakada <nobu.nokada@softhome.net>
* eval.c (rb_f_missing): create exception instance by ordinal
method.
method. [ruby-dev:20033]
* error.c (rb_name_error, rb_sys_fail): ditto.

View File

@ -542,11 +542,17 @@ syserr_initialize(argc, argv, self)
char *err;
char *buf;
VALUE error, mesg;
VALUE klass = rb_obj_class(self);
if (rb_scan_args(argc, argv, "11", &mesg, &error) == 1 && FIXNUM_P(mesg)) {
rb_scan_args(argc, argv, klass == rb_eSystemCallError ? "11" : "02",
&mesg, &error);
if (argc == 1 && FIXNUM_P(mesg)) {
error = mesg;
mesg = Qnil;
}
if (klass != rb_eSystemCallError && NIL_P(error)) {
error = rb_const_get_at(klass, rb_intern("Errno"));
}
err = strerror(NUM2LONG(error));
if (!err) err = "Unknown error";
if (RTEST(mesg)) {