@@ -1103,6 +1103,7 @@ enumerator_rewind(VALUE obj)
11031103
11041104static struct generator * generator_ptr (VALUE obj );
11051105static VALUE append_method (VALUE obj , VALUE str , ID default_method , VALUE default_args );
1106+ static VALUE append_method_args (VALUE obj , VALUE str , VALUE default_args );
11061107
11071108static VALUE
11081109inspect_enumerator (VALUE obj , VALUE dummy , int recur )
@@ -1175,7 +1176,7 @@ kwd_append(VALUE key, VALUE val, VALUE str)
11751176static VALUE
11761177append_method (VALUE obj , VALUE str , ID default_method , VALUE default_args )
11771178{
1178- VALUE method , eargs ;
1179+ VALUE method ;
11791180
11801181 method = rb_attr_get (obj , id_method );
11811182 if (method != Qfalse ) {
@@ -1189,6 +1190,13 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
11891190 rb_str_buf_cat2 (str , ":" );
11901191 rb_str_buf_append (str , method );
11911192 }
1193+ return append_method_args (obj , str , default_args );
1194+ }
1195+
1196+ static VALUE
1197+ append_method_args (VALUE obj , VALUE str , VALUE default_args )
1198+ {
1199+ VALUE eargs ;
11921200
11931201 eargs = rb_attr_get (obj , id_arguments );
11941202 if (NIL_P (eargs )) {
@@ -1218,7 +1226,7 @@ append_method(VALUE obj, VALUE str, ID default_method, VALUE default_args)
12181226 if (!NIL_P (kwds )) {
12191227 rb_hash_foreach (kwds , kwd_append , str );
12201228 }
1221- rb_str_set_len (str , RSTRING_LEN (str )- 2 );
1229+ rb_str_set_len (str , RSTRING_LEN (str )- 2 ); /* drop the last ", " */
12221230 rb_str_buf_cat2 (str , ")" );
12231231 }
12241232 }
@@ -4341,7 +4349,7 @@ static VALUE
43414349arith_seq_inspect (VALUE self )
43424350{
43434351 struct enumerator * e ;
4344- VALUE eobj , str , eargs ;
4352+ VALUE eobj , str ;
43454353 int range_p ;
43464354
43474355 TypedData_Get_Struct (self , struct enumerator , & enumerator_data_type , e );
@@ -4355,40 +4363,7 @@ arith_seq_inspect(VALUE self)
43554363 str = rb_sprintf ("(%s%" PRIsVALUE "%s." , range_p ? "(" : "" , eobj , range_p ? ")" : "" );
43564364
43574365 rb_str_buf_append (str , rb_id2str (e -> meth ));
4358-
4359- eargs = rb_attr_get (eobj , id_arguments );
4360- if (NIL_P (eargs )) {
4361- eargs = e -> args ;
4362- }
4363- if (eargs != Qfalse ) {
4364- long argc = RARRAY_LEN (eargs );
4365- const VALUE * argv = RARRAY_CONST_PTR (eargs ); /* WB: no new reference */
4366-
4367- if (argc > 0 ) {
4368- VALUE kwds = Qnil ;
4369-
4370- rb_str_buf_cat2 (str , "(" );
4371-
4372- if (RB_TYPE_P (argv [argc - 1 ], T_HASH )) {
4373- int all_key = TRUE;
4374- rb_hash_foreach (argv [argc - 1 ], key_symbol_p , (VALUE )& all_key );
4375- if (all_key ) kwds = argv [-- argc ];
4376- }
4377-
4378- while (argc -- ) {
4379- VALUE arg = * argv ++ ;
4380-
4381- rb_str_append (str , rb_inspect (arg ));
4382- rb_str_buf_cat2 (str , ", " );
4383- }
4384- if (!NIL_P (kwds )) {
4385- rb_hash_foreach (kwds , kwd_append , str );
4386- }
4387- rb_str_set_len (str , RSTRING_LEN (str )- 2 ); /* drop the last ", " */
4388- rb_str_buf_cat2 (str , ")" );
4389- }
4390- }
4391- RB_GC_GUARD (eargs );
4366+ append_method_args (eobj , str , e -> args );
43924367
43934368 rb_str_buf_cat2 (str , ")" );
43944369
0 commit comments