mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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
1 changed files with 4 additions and 3 deletions
7
string.c
7
string.c
|
@ -226,11 +226,13 @@ rb_fstring(VALUE str)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
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;
|
fake_str->basic.flags = T_STRING|RSTRING_NOEMBED|ELTS_SHARED;
|
||||||
/* SHARED to be allocated by the callback */
|
/* SHARED to be allocated by the callback */
|
||||||
|
|
||||||
|
ENCODING_SET_INLINED((VALUE)fake_str, encidx);
|
||||||
|
|
||||||
RBASIC_SET_CLASS((VALUE)fake_str, rb_cString);
|
RBASIC_SET_CLASS((VALUE)fake_str, rb_cString);
|
||||||
fake_str->as.heap.len = len;
|
fake_str->as.heap.len = len;
|
||||||
fake_str->as.heap.ptr = (char *)name;
|
fake_str->as.heap.ptr = (char *)name;
|
||||||
|
@ -242,8 +244,7 @@ VALUE
|
||||||
rb_fstring_new(const char *ptr, long len)
|
rb_fstring_new(const char *ptr, long len)
|
||||||
{
|
{
|
||||||
struct RString fake_str;
|
struct RString fake_str;
|
||||||
|
return rb_fstring(setup_fake_str(&fake_str, ptr, len, ENCINDEX_US_ASCII));
|
||||||
return rb_fstring(setup_fake_str(&fake_str, ptr, len));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue