summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-13 08:05:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-01-13 08:05:07 +0000
commitbe61b2b12d89324256b414b402364e7c243ee660 (patch)
tree064e1722713ac7d7af76fd15142b0ecb24e5d079
parent22121544e16ce6ad127712a79d6b69ef785c222e (diff)
vm_eval.c: fstring format
* vm_eval.c (make_no_method_exception): make format string fstring. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--vm_eval.c18
-rw-r--r--vm_insnhelper.c3
-rw-r--r--vm_insnhelper.h2
3 files changed, 12 insertions, 11 deletions
diff --git a/vm_eval.c b/vm_eval.c
index b765ad6692..105e348509 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -680,15 +680,15 @@ rb_method_missing(int argc, const VALUE *argv, VALUE obj)
}
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, int argc, const VALUE *argv, VALUE obj,
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, int argc, const VALUE *argv, VALUE obj,
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 *argv, VALUE recv, call_type scope)
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);
}
diff --git a/vm_insnhelper.c b/vm_insnhelper.c
index 29bf2faab9..86f6c4b2be 100644
--- a/vm_insnhelper.c
+++ b/vm_insnhelper.c
@@ -1825,7 +1825,8 @@ vm_call_opt_send(rb_thread_t *th, rb_control_frame_t *reg_cfp, struct rb_calling
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);
diff --git a/vm_insnhelper.h b/vm_insnhelper.h
index fbd3a76728..f2a2a88c72 100644
--- a/vm_insnhelper.h
+++ b/vm_insnhelper.h
@@ -185,7 +185,7 @@ enum vm_regan_acttype {
#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 *