Permalink
Browse files

add a rb_str_catf() as CRuby API.

  • Loading branch information...
1 parent 04af3bb commit da7a6cdf18a052e75fff32f0eaac7c3f4dfb1e00 @Watson1978 Watson1978 committed Dec 19, 2011
Showing with 12 additions and 0 deletions.
  1. +1 −0 include/ruby/intern.h
  2. +11 −0 sprintf.c
View
@@ -473,6 +473,7 @@ void ruby_default_signal(int);
VALUE rb_f_sprintf(int, const VALUE*);
PRINTF_ARGS(VALUE rb_sprintf(const char*, ...), 1, 2);
VALUE rb_vsprintf(const char*, va_list);
+PRINTF_ARGS(VALUE rb_str_catf(VALUE, const char*, ...), 2, 3);
VALUE rb_str_format(int, const VALUE *, VALUE);
/* string.c */
View
@@ -313,6 +313,17 @@ rb_sprintf(const char *format, ...)
return result;
}
+VALUE
+rb_str_catf(VALUE str, const char *format, ...)
+{
+ va_list ap;
+ va_start(ap, format);
+ VALUE result = rb_vsprintf(format, ap);
+ va_end(ap);
+ rb_str_concat(str, result);
+ return str;
+}
+
#define IS_NEG(num) RBIGNUM_NEGATIVE_P(num)
#define REL_REF 1
#define ABS_REF 2

0 comments on commit da7a6cd

Please sign in to comment.