ruby-changes:24125
From: nobu <ko1@a...>
Date: Fri, 22 Jun 2012 14:22:55 +0900 (JST)
Subject: [ruby-changes:24125] nobu:r36176 (trunk): marshal.c: io_needed
nobu 2012-06-22 14:22:46 +0900 (Fri, 22 Jun 2012) New Revision: 36176 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36176 Log: marshal.c: io_needed * marshal.c (io_needed): extract from marshal_dump and marshal_load. Modified files: trunk/marshal.c Index: marshal.c =================================================================== --- marshal.c (revision 36175) +++ marshal.c (revision 36176) @@ -865,6 +865,13 @@ } } +NORETURN(static inline void io_needed(void)); +static inline void +io_needed(void) +{ + rb_raise(rb_eTypeError, "instance of IO needed"); +} + /* * call-seq: * dump( obj [, anIO] , limit=-1 ) -> anIO @@ -911,12 +918,12 @@ rb_scan_args(argc, argv, "12", &obj, &a1, &a2); if (argc == 3) { if (!NIL_P(a2)) limit = NUM2INT(a2); - if (NIL_P(a1)) goto type_error; + if (NIL_P(a1)) io_needed(); port = a1; } else if (argc == 2) { if (FIXNUM_P(a1)) limit = FIX2INT(a1); - else if (NIL_P(a1)) goto type_error; + else if (NIL_P(a1)) io_needed(); else port = a1; } wrapper = TypedData_Make_Struct(rb_cData, struct dump_arg, &dump_arg_data, arg); @@ -929,8 +936,7 @@ arg->str = rb_str_buf_new(0); if (!NIL_P(port)) { if (!rb_respond_to(port, s_write)) { - type_error: - rb_raise(rb_eTypeError, "instance of IO needed"); + io_needed(); } arg->dest = port; if (rb_respond_to(port, s_binmode)) { @@ -1783,7 +1789,7 @@ infection = (int)(FL_TAINT | FL_TEST(port, FL_UNTRUSTED)); } else { - rb_raise(rb_eTypeError, "instance of IO needed"); + io_needed(); } wrapper = TypedData_Make_Struct(rb_cData, struct load_arg, &load_arg_data, arg); arg->infection = infection; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/