ruby-changes:63621
From: Jean <ko1@a...>
Date: Tue, 17 Nov 2020 09:39:47 +0900 (JST)
Subject: [ruby-changes:63621] ef19fb111a (master): Expose the rb_interned_str_* family of functions
https://git.ruby-lang.org/ruby.git/commit/?id=ef19fb111a From ef19fb111a8c8bf1a71d46e6fcf34b227e086845 Mon Sep 17 00:00:00 2001 From: Jean Boussier <jean.boussier@g...> Date: Fri, 25 Sep 2020 14:46:59 +0200 Subject: Expose the rb_interned_str_* family of functions Fixes [Feature #13381] diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 01cbf8b..07e6c9a 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -127,6 +127,8 @@ void rb_enc_copy(VALUE dst, VALUE src); https://github.com/ruby/ruby/blob/trunk/include/ruby/encoding.h#L127 VALUE rb_enc_str_new(const char*, long, rb_encoding*); VALUE rb_enc_str_new_cstr(const char*, rb_encoding*); VALUE rb_enc_str_new_static(const char*, long, rb_encoding*); +VALUE rb_enc_interned_str(const char *, long, rb_encoding *); +VALUE rb_enc_interned_str_cstr(const char *, rb_encoding *); VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int); PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3); VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list); diff --git a/include/ruby/internal/intern/string.h b/include/ruby/internal/intern/string.h index f2f563e..a590b20 100644 --- a/include/ruby/internal/intern/string.h +++ b/include/ruby/internal/intern/string.h @@ -74,6 +74,9 @@ VALUE rb_utf8_str_new_cstr(const char*); https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/intern/string.h#L74 VALUE rb_str_new_static(const char *ptr, long len); VALUE rb_usascii_str_new_static(const char *ptr, long len); VALUE rb_utf8_str_new_static(const char *ptr, long len); +VALUE rb_str_to_interned_str(VALUE); +VALUE rb_interned_str(const char *, long); +VALUE rb_interned_str_cstr(const char *); void rb_str_free(VALUE); void rb_str_shared_replace(VALUE, VALUE); VALUE rb_str_buf_append(VALUE, VALUE); diff --git a/string.c b/string.c index 3dc9aa6..a60add6 100644 --- a/string.c +++ b/string.c @@ -11402,6 +11402,36 @@ sym_all_symbols(VALUE _) https://github.com/ruby/ruby/blob/trunk/string.c#L11402 return rb_sym_all_symbols(); } +VALUE +rb_str_to_interned_str(VALUE str) +{ + return rb_fstring(str); +} + +VALUE +rb_interned_str(const char *ptr, long len) +{ + return rb_fstring_new(ptr, len); +} + +VALUE +rb_interned_str_cstr(const char *ptr) +{ + return rb_fstring_cstr(ptr); +} + +VALUE +rb_enc_interned_str(const char *ptr, long len, rb_encoding *enc) +{ + return rb_fstring_enc_new(ptr, len, enc); +} + +VALUE +rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc) +{ + return rb_fstring_enc_new(ptr, strlen(ptr), enc); +} + /* * A String object holds and manipulates an arbitrary sequence of * bytes, typically representing characters. String objects may be created -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/