ruby-changes:34608
From: nobu <ko1@a...>
Date: Fri, 4 Jul 2014 15:32:50 +0900 (JST)
Subject: [ruby-changes:34608] nobu:r46689 (trunk): string.c: rb_fstring_new assumes US-ASCII
nobu 2014-07-04 15:32:44 +0900 (Fri, 04 Jul 2014) New Revision: 46689 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=46689 Log: string.c: rb_fstring_new assumes US-ASCII * string.c (rb_fstring_new): make US-ASCII string. another function may be used for non-ASCII strings. Modified files: trunk/string.c Index: string.c =================================================================== --- string.c (revision 46688) +++ string.c (revision 46689) @@ -226,11 +226,13 @@ rb_fstring(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L226 } static VALUE -setup_fake_str(struct RString *fake_str, const char *name, long len) +setup_fake_str(struct RString *fake_str, const char *name, long len, int encidx) { fake_str->basic.flags = T_STRING|RSTRING_NOEMBED|ELTS_SHARED; /* SHARED to be allocated by the callback */ + ENCODING_SET_INLINED((VALUE)fake_str, encidx); + RBASIC_SET_CLASS((VALUE)fake_str, rb_cString); fake_str->as.heap.len = len; fake_str->as.heap.ptr = (char *)name; @@ -242,8 +244,7 @@ VALUE https://github.com/ruby/ruby/blob/trunk/string.c#L244 rb_fstring_new(const char *ptr, long len) { struct RString fake_str; - - return rb_fstring(setup_fake_str(&fake_str, ptr, len)); + return rb_fstring(setup_fake_str(&fake_str, ptr, len, ENCINDEX_US_ASCII)); } static int -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/