| 1 |
#include "ruby.h" |
| 2 |
#include "ruby/encoding.h" |
| 3 |
#include "internal/string.h" |
| 4 |
|
| 5 |
VALUE rb_fstring(VALUE str); |
| 6 |
|
| 7 |
VALUE |
| 8 |
bug_s_fstring(VALUE self, VALUE str) |
| 9 |
{ |
| 10 |
return rb_fstring(str); |
| 11 |
} |
| 12 |
|
| 13 |
VALUE |
| 14 |
bug_s_fstring_fake_str(VALUE self) |
| 15 |
{ |
| 16 |
static const char literal[] = "abcdefghijklmnopqrstuvwxyz"; |
| 17 |
struct RString fake_str; |
| 18 |
return rb_fstring(rb_setup_fake_str(&fake_str, literal, sizeof(literal) - 1, 0)); |
| 19 |
} |
| 20 |
|
| 21 |
VALUE |
| 22 |
bug_s_rb_enc_interned_str(VALUE self, VALUE encoding) |
| 23 |
{ |
| 24 |
return rb_enc_interned_str("foo", 3, NIL_P(encoding) ? NULL : RDATA(encoding)->data); |
| 25 |
} |
| 26 |
|
| 27 |
VALUE |
| 28 |
bug_s_rb_enc_str_new(VALUE self, VALUE encoding) |
| 29 |
{ |
| 30 |
return rb_enc_str_new("foo", 3, NIL_P(encoding) ? NULL : RDATA(encoding)->data); |
| 31 |
} |
| 32 |
|
| 33 |
void |
| 34 |
Init_string_fstring(VALUE klass) |
| 35 |
{ |
| 36 |
rb_define_singleton_method(klass, "fstring", bug_s_fstring, 1); |
| 37 |
rb_define_singleton_method(klass, "fstring_fake_str", bug_s_fstring_fake_str, 0); |
| 38 |
rb_define_singleton_method(klass, "rb_enc_interned_str", bug_s_rb_enc_interned_str, 1); |
| 39 |
rb_define_singleton_method(klass, "rb_enc_str_new", bug_s_rb_enc_str_new, 1); |
| 40 |
} |