aboutsummaryrefslogtreecommitdiffstats
path: root/object.c
diff options
context:
space:
mode:
author卜部昌平 <shyouhei@ruby-lang.org>2019-08-28 18:19:11 +0900
committer卜部昌平 <shyouhei@ruby-lang.org>2019-08-29 18:34:09 +0900
commit7bcfd9189a6a0b2ad58fed988faaf795a4987893 (patch)
tree219f0c172e038ea6be1e103db11f7457dc703328 /object.c
parent7b6fde4258e700c0e0292bb091aa84a5e473342e (diff)
downloadruby-7bcfd9189a6a0b2ad58fed988faaf795a4987893.tar.gz
drop-in type check for rb_define_global_function
We can check the function pointer passed to rb_define_global_function like we do so in rb_define_method. It turns out that almost anybody is misunderstanding the API.
Diffstat (limited to 'object.c')
-rw-r--r--object.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/object.c b/object.c
index 28b393d051..14cc409f2e 100644
--- a/object.c
+++ b/object.c
@@ -4048,6 +4048,12 @@ rb_obj_dig(int argc, VALUE *argv, VALUE obj, VALUE notfound)
return obj;
}
+static VALUE
+f_sprintf(int c, const VALUE *v, VALUE _)
+{
+ return rb_f_sprintf(c, v);
+}
+
/*
* Document-class: Class
*
@@ -4299,8 +4305,8 @@ InitVM_Object(void)
rb_define_method(rb_mKernel, "is_a?", rb_obj_is_kind_of, 1);
rb_define_method(rb_mKernel, "tap", rb_obj_tap, 0);
- rb_define_global_function("sprintf", rb_f_sprintf, -1); /* in sprintf.c */
- rb_define_global_function("format", rb_f_sprintf, -1); /* in sprintf.c */
+ rb_define_global_function("sprintf", f_sprintf, -1);
+ rb_define_global_function("format", f_sprintf, -1);
rb_define_global_function("Integer", rb_f_integer, -1);
rb_define_global_function("Float", rb_f_float, -1);