@@ -479,6 +479,15 @@ static VALUE string_spec_rb_sprintf6(VALUE self, VALUE width, VALUE precision, V
479
479
return rb_sprintf ("Result: %*.*" PRIsVALUE "." , FIX2INT (width ), FIX2INT (precision ), str );
480
480
}
481
481
482
+ static VALUE string_spec_rb_sprintf7 (VALUE self , VALUE str , VALUE obj ) {
483
+ VALUE results = rb_ary_new ();
484
+ rb_ary_push (results , rb_sprintf (RSTRING_PTR (str ), obj ));
485
+ char cstr [256 ];
486
+ int len = snprintf (cstr , 256 , RSTRING_PTR (str ), obj );
487
+ rb_ary_push (results , rb_str_new (cstr , len ));
488
+ return results ;
489
+ }
490
+
482
491
PRINTF_ARGS (static VALUE string_spec_rb_vsprintf_worker (char * fmt , ...), 1 , 2 );
483
492
static VALUE string_spec_rb_vsprintf_worker (char * fmt , ...) {
484
493
va_list varargs ;
@@ -638,6 +647,7 @@ void Init_string_spec(void) {
638
647
rb_define_method (cls , "rb_sprintf4" , string_spec_rb_sprintf4 , 1 );
639
648
rb_define_method (cls , "rb_sprintf5" , string_spec_rb_sprintf5 , 3 );
640
649
rb_define_method (cls , "rb_sprintf6" , string_spec_rb_sprintf6 , 3 );
650
+ rb_define_method (cls , "rb_sprintf7" , string_spec_rb_sprintf7 , 2 );
641
651
rb_define_method (cls , "rb_vsprintf" , string_spec_rb_vsprintf , 4 );
642
652
rb_define_method (cls , "rb_str_equal" , string_spec_rb_str_equal , 2 );
643
653
rb_define_method (cls , "rb_usascii_str_new" , string_spec_rb_usascii_str_new , 2 );
0 commit comments