ruby-changes:17717
From: nobu <ko1@a...>
Date: Tue, 9 Nov 2010 07:30:29 +0900 (JST)
Subject: [ruby-changes:17717] Ruby:r29728 (trunk): * error.c (rb_syserr_new): new function to make SystemCallError
nobu 2010-11-09 07:30:20 +0900 (Tue, 09 Nov 2010) New Revision: 29728 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29728 Log: * error.c (rb_syserr_new): new function to make SystemCallError instance without errno. [EXPERIMENTAL] * error.c (rb_syserr_fail, rb_mod_syserr_fail): ditto. Modified files: trunk/ChangeLog trunk/error.c trunk/include/ruby/ruby.h Index: include/ruby/ruby.h =================================================================== --- include/ruby/ruby.h (revision 29727) +++ include/ruby/ruby.h (revision 29728) @@ -1152,6 +1152,9 @@ NORETURN(void rb_iter_break(void)); NORETURN(void rb_exit(int)); NORETURN(void rb_notimplement(void)); +VALUE rb_syserr_new(int, const char *); +NORETURN(void rb_syserr_fail(int, const char*)); +NORETURN(void rb_mod_syserr_fail(VALUE, int, const char*)); /* reports if `-W' specified */ PRINTF_ARGS(void rb_warning(const char*, ...), 1, 2); Index: ChangeLog =================================================================== --- ChangeLog (revision 29727) +++ ChangeLog (revision 29728) @@ -1,3 +1,10 @@ +Tue Nov 9 07:30:15 2010 Nobuyoshi Nakada <nobu@r...> + + * error.c (rb_syserr_new): new function to make SystemCallError + instance without errno. [EXPERIMENTAL] + + * error.c (rb_syserr_fail, rb_mod_syserr_fail): ditto. + Tue Nov 9 05:54:57 2010 Marc-Andre Lafortune <ruby-core@m...> * lib/*.rb: Remove unused variable warnings. Index: error.c =================================================================== --- error.c (revision 29727) +++ error.c (revision 29728) @@ -1532,18 +1532,29 @@ make_errno_exc(const char *mesg) { int n = errno; - VALUE arg; errno = 0; if (n == 0) { rb_bug("rb_sys_fail(%s) - errno == 0", mesg ? mesg : ""); } + return rb_syserr_new(n, mesg); +} +VALUE +rb_syserr_new(int n, const char *mesg) +{ + VALUE arg; arg = mesg ? rb_str_new2(mesg) : Qnil; return rb_class_new_instance(1, &arg, get_syserr(n)); } void +rb_syserr_fail(int e, const char *mesg) +{ + rb_exc_raise(rb_syserr_new(e, mesg)); +} + +void rb_sys_fail(const char *mesg) { rb_exc_raise(make_errno_exc(mesg)); @@ -1558,6 +1569,14 @@ } void +rb_mod_syserr_fail(VALUE mod, int e, const char *mesg) +{ + VALUE exc = rb_syserr_new(e, mesg); + rb_extend_object(exc, mod); + rb_exc_raise(exc); +} + +void rb_sys_warning(const char *fmt, ...) { char buf[BUFSIZ]; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/