diff --git a/include/ruby/intern.h b/include/ruby/intern.h index b10c9c6467..00474a739b 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -234,10 +234,12 @@ VALUE rb_enumeratorize_with_size(VALUE, VALUE, int, const VALUE *, rb_enumerator #define rb_enumeratorize_with_size(obj, id, argc, argv, size_fn) \ rb_enumeratorize_with_size(obj, id, argc, argv, (rb_enumerator_size_func *)(size_fn)) #endif +#define SIZED_ENUMERATOR(obj, argc, argv, size_fn) \ + rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()), \ + (argc), (argv), (size_fn)) #define RETURN_SIZED_ENUMERATOR(obj, argc, argv, size_fn) do { \ if (!rb_block_given_p()) \ - return rb_enumeratorize_with_size((obj), ID2SYM(rb_frame_this_func()),\ - (argc), (argv), (size_fn)); \ + return SIZED_ENUMERATOR(obj, argc, argv, size_fn); \ } while (0) #define RETURN_ENUMERATOR(obj, argc, argv) RETURN_SIZED_ENUMERATOR(obj, argc, argv, 0) /* error.c */ diff --git a/string.c b/string.c index 4a0df2aecb..88185cfb0b 100644 --- a/string.c +++ b/string.c @@ -6810,7 +6810,7 @@ rb_str_enumerate_chars(VALUE str, int wantarray) if (wantarray) ary = rb_ary_new_capa(str_strlen(str, enc)); /* str's enc*/ else - RETURN_SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); + return SIZED_ENUMERATOR(str, 0, 0, rb_str_each_char_size); } switch (ENC_CODERANGE(str)) {