diff options
author | Jean Boussier <jean.boussier@gmail.com> | 2020-11-18 13:57:01 +0100 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2020-11-30 17:33:28 +0900 |
commit | 6bef49427ab2a9d3bc338f1cffcd086153a59f44 (patch) | |
tree | 3324d63fd62c7a95420967fce546d7143293f1a7 /ext/-test-/string/rb_interned_str.c | |
parent | 930a135524382ddd80c0608a7593b6cdfceee846 (diff) |
Fix rb_interned_str_* functions to not assume static strings
Fixes [Feature #13381]
When passed a `fake_str`, `register_fstring` would create new strings
with `str_new_static`. That's not what was expected, and answer
almost no use cases.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/3786
Diffstat (limited to 'ext/-test-/string/rb_interned_str.c')
-rw-r--r-- | ext/-test-/string/rb_interned_str.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ext/-test-/string/rb_interned_str.c b/ext/-test-/string/rb_interned_str.c new file mode 100644 index 0000000..47643ec --- /dev/null +++ b/ext/-test-/string/rb_interned_str.c @@ -0,0 +1,14 @@ +#include "ruby.h" + +static VALUE +bug_rb_interned_str_dup(VALUE self, VALUE str) +{ + Check_Type(str, T_STRING); + return rb_interned_str(RSTRING_PTR(str), RSTRING_LEN(str)); +} + +void +Init_string_rb_interned_str(VALUE klass) +{ + rb_define_singleton_method(klass, "rb_interned_str_dup", bug_rb_interned_str_dup, 1); +} |