ruby-changes:41451
From: nobu <ko1@a...>
Date: Wed, 13 Jan 2016 17:04:42 +0900 (JST)
Subject: [ruby-changes:41451] nobu:r53525 (trunk): vm_eval.c: fstring format
nobu 2016-01-13 17:05:07 +0900 (Wed, 13 Jan 2016) New Revision: 53525 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=53525 Log: vm_eval.c: fstring format * vm_eval.c (make_no_method_exception): make format string fstring. Modified files: trunk/vm_eval.c trunk/vm_insnhelper.c trunk/vm_insnhelper.h Index: vm_eval.c =================================================================== --- vm_eval.c (revision 53524) +++ vm_eval.c (revision 53525) @@ -680,15 +680,15 @@ rb_method_missing(int argc, const VALUE https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L680 } static VALUE -make_no_method_exception(VALUE exc, const char *format, VALUE obj, int argc, const VALUE *argv) +make_no_method_exception(VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv) { int n = 0; VALUE args[3]; if (!format) { - format = "undefined method `%s' for %s%s%s"; + format = rb_fstring_cstr("undefined method `%s' for %s%s%s"); } - args[n++] = rb_name_err_mesg_new(rb_str_new_cstr(format), obj, argv[0]); + args[n++] = rb_name_err_mesg_new(format, obj, argv[0]); args[n++] = argv[0]; if (exc == rb_eNoMethodError) { args[n++] = rb_ary_new4(argc - 1, argv + 1); @@ -701,7 +701,7 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L701 enum method_missing_reason last_call_status) { VALUE exc = rb_eNoMethodError; - const char *format = 0; + VALUE format = 0; if (UNLIKELY(argc == 0)) { rb_raise(rb_eArgError, "no method name given"); @@ -715,17 +715,17 @@ raise_method_missing(rb_thread_t *th, in https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L715 stack_check(); if (last_call_status & MISSING_PRIVATE) { - format = "private method `%s' called for %s%s%s"; + format = rb_fstring_cstr("private method `%s' called for %s%s%s"); } else if (last_call_status & MISSING_PROTECTED) { - format = "protected method `%s' called for %s%s%s"; + format = rb_fstring_cstr("protected method `%s' called for %s%s%s"); } else if (last_call_status & MISSING_VCALL) { - format = "undefined local variable or method `%s' for %s%s%s"; + format = rb_fstring_cstr("undefined local variable or method `%s' for %s%s%s"); exc = rb_eNameError; } else if (last_call_status & MISSING_SUPER) { - format = "super: no superclass method `%s' for %s%s%s"; + format = rb_fstring_cstr("super: no superclass method `%s' for %s%s%s"); } { @@ -920,7 +920,7 @@ send_internal(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/vm_eval.c#L920 id = rb_check_id(&vid); if (!id) { if (rb_method_basic_definition_p(CLASS_OF(recv), idMethodMissing)) { - VALUE exc = make_no_method_exception(rb_eNoMethodError, NULL, + VALUE exc = make_no_method_exception(rb_eNoMethodError, 0, recv, argc, argv); rb_exc_raise(exc); } Index: vm_insnhelper.c =================================================================== --- vm_insnhelper.c (revision 53524) +++ vm_insnhelper.c (revision 53525) @@ -1825,7 +1825,8 @@ vm_call_opt_send(rb_thread_t *th, rb_con https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L1825 if (!(ci->mid = rb_check_id(&sym))) { if (rb_method_basic_definition_p(CLASS_OF(calling->recv), idMethodMissing)) { - VALUE exc = make_no_method_exception(rb_eNoMethodError, NULL, calling->recv, rb_long2int(calling->argc), &TOPN(i)); + VALUE exc = make_no_method_exception(rb_eNoMethodError, 0, calling->recv, + rb_long2int(calling->argc), &TOPN(i)); rb_exc_raise(exc); } TOPN(i) = rb_str_intern(sym); Index: vm_insnhelper.h =================================================================== --- vm_insnhelper.h (revision 53524) +++ vm_insnhelper.h (revision 53525) @@ -185,7 +185,7 @@ enum vm_regan_acttype { https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.h#L185 #define GET_GLOBAL_CONSTANT_STATE() (ruby_vm_global_constant_state) #define INC_GLOBAL_CONSTANT_STATE() (++ruby_vm_global_constant_state) -static VALUE make_no_method_exception(VALUE exc, const char *format, +static VALUE make_no_method_exception(VALUE exc, VALUE format, VALUE obj, int argc, const VALUE *argv); static inline struct vm_throw_data * -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/