diff options
author | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-08-27 11:16:52 +0900 |
---|---|---|
committer | 卜部昌平 <shyouhei@ruby-lang.org> | 2019-08-27 15:52:26 +0900 |
commit | ae2dc3f217ba9f181471f39a7e5ce72a28b27c2a (patch) | |
tree | e506115b9dd5c2adb07946763506a5b46d36b5f0 /re.c | |
parent | 78628618da98236fc1bf702079185b36ed394e2a (diff) |
rb_define_hooked_variable now free from ANYARGS
After 5e86b005c0f2ef30df2f9906c7e2f3abefe286a2, I now think ANYARGS is
dangerous and should be extinct. This commit uses rb_gvar_getter_t /
rb_gvar_setter_t for rb_define_hooked_variable /
rb_define_virtual_variable which revealed lots of function prototype
inconsistencies. Some of them were literally decades old, going back
to dda5dc00cff334cac373096d444a0fd59e716124.
Diffstat (limited to 're.c')
-rw-r--r-- | re.c | 26 |
1 files changed, 16 insertions, 10 deletions
@@ -1824,25 +1824,25 @@ rb_reg_match_last(VALUE match) } static VALUE -last_match_getter(void) +last_match_getter(ID _x, VALUE *_y) { return rb_reg_last_match(rb_backref_get()); } static VALUE -prematch_getter(void) +prematch_getter(ID _x, VALUE *_y) { return rb_reg_match_pre(rb_backref_get()); } static VALUE -postmatch_getter(void) +postmatch_getter(ID _x, VALUE *_y) { return rb_reg_match_post(rb_backref_get()); } static VALUE -last_paren_match_getter(void) +last_paren_match_getter(ID _x, VALUE *_y) { return rb_reg_match_last(rb_backref_get()); } @@ -3919,27 +3919,27 @@ rb_reg_regsub(VALUE str, VALUE src, struct re_registers *regs, VALUE regexp) } static VALUE -kcode_getter(void) +kcode_getter(ID _x, VALUE *_y) { rb_warn("variable $KCODE is no longer effective"); return Qnil; } static void -kcode_setter(VALUE val, ID id) +kcode_setter(VALUE val, ID id, VALUE *_) { rb_warn("variable $KCODE is no longer effective; ignored"); } static VALUE -ignorecase_getter(void) +ignorecase_getter(ID _x, VALUE *_y) { rb_warn("variable $= is no longer effective"); return Qfalse; } static void -ignorecase_setter(VALUE val, ID id) +ignorecase_setter(VALUE val, ID id, VALUE *_) { rb_warn("variable $= is no longer effective; ignored"); } @@ -3954,8 +3954,14 @@ match_getter(void) return match; } +static VALUE +get_$LAST_MATCH_INFO(ID _x, VALUE *_y) +{ + return match_getter(); +} + static void -match_setter(VALUE val) +match_setter(VALUE val, ID _x, VALUE *_y) { if (!NIL_P(val)) { Check_Type(val, T_MATCH); @@ -4042,7 +4048,7 @@ Init_Regexp(void) onig_set_warn_func(re_warn); onig_set_verb_warn_func(re_warn); - rb_define_virtual_variable("$~", match_getter, match_setter); + rb_define_virtual_variable("$~", get_$LAST_MATCH_INFO, match_setter); rb_define_virtual_variable("$&", last_match_getter, 0); rb_define_virtual_variable("$`", prematch_getter, 0); rb_define_virtual_variable("$'", postmatch_getter, 0); |