ruby-changes:40414
From: nobu <ko1@a...>
Date: Sun, 8 Nov 2015 16:46:48 +0900 (JST)
Subject: [ruby-changes:40414] nobu:r52495 (trunk): symbol.c: rb_cstr_intern
nobu 2015-11-08 16:46:39 +0900 (Sun, 08 Nov 2015) New Revision: 52495 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52495 Log: symbol.c: rb_cstr_intern * symbol.c (rb_cstr_intern): new function to make Symbol object like as rb_str_intern() but from pointer to the name, its length and its encoding. Modified files: trunk/internal.h trunk/symbol.c Index: symbol.c =================================================================== --- symbol.c (revision 52494) +++ symbol.c (revision 52495) @@ -1013,6 +1013,14 @@ rb_check_symbol_cstr(const char *ptr, lo https://github.com/ruby/ruby/blob/trunk/symbol.c#L1013 return Qnil; } +VALUE +rb_cstr_intern(const char *ptr, long len, rb_encoding *enc) +{ + struct RString fake_str; + const VALUE name = rb_setup_fake_str(&fake_str, ptr, len, enc); + return rb_str_intern(name); +} + static ID attrsetname_to_attr_id(VALUE name) { Index: internal.h =================================================================== --- internal.h (revision 52494) +++ internal.h (revision 52495) @@ -1129,6 +1129,11 @@ size_t rb_str_memsize(VALUE); https://github.com/ruby/ruby/blob/trunk/internal.h#L1129 VALUE rb_sym_proc_call(VALUE args, VALUE sym, int argc, const VALUE *argv, VALUE passed_proc); VALUE rb_sym_to_proc(VALUE sym); +/* symbol.c */ +#ifdef RUBY_ENCODING_H +VALUE rb_cstr_intern(const char *ptr, long len, rb_encoding *enc); +#endif + /* struct.c */ VALUE rb_struct_init_copy(VALUE copy, VALUE s); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/