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. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5e294b7820
commit
72194a89da
7
string.c
7
string.c
@ -226,11 +226,13 @@ rb_fstring(VALUE str)
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user