mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
fstring_enc_new
* string.c (rb_fstring_enc_new, rb_fstring_enc_cstr): functions to make fstring with encoding. * re.c (rb_reg_initialize): make fstring without copying. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
10ff672a30
commit
94c70c7d72
4 changed files with 36 additions and 1 deletions
|
@ -1,3 +1,10 @@
|
|||
Thu Feb 4 15:35:29 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_fstring_enc_new, rb_fstring_enc_cstr): functions to
|
||||
make fstring with encoding.
|
||||
|
||||
* re.c (rb_reg_initialize): make fstring without copying.
|
||||
|
||||
Thu Feb 4 14:42:29 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* common.mk: Added Unicode data file SpecialCasing.txt to be additionally
|
||||
|
|
14
internal.h
14
internal.h
|
@ -1135,6 +1135,20 @@ VALUE rb_fstring_cstr(const char *str);
|
|||
rb_fstring_cstr(str); \
|
||||
})
|
||||
#endif
|
||||
#ifdef RUBY_ENCODING_H
|
||||
VALUE rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc);
|
||||
#define rb_fstring_enc_lit(str, enc) rb_fstring_enc_new((str), rb_strlen_lit(str), (enc))
|
||||
#define rb_fstring_enc_literal(str, enc) rb_fstring_enc_lit(str, enc)
|
||||
VALUE rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc);
|
||||
#if defined(__GNUC__) && !defined(__PCC__)
|
||||
#define rb_fstring_enc_cstr(str, enc) __extension__ ( \
|
||||
{ \
|
||||
(__builtin_constant_p(str)) ? \
|
||||
rb_fstring_enc_new((str), (long)strlen(str), (enc)) : \
|
||||
rb_fstring_enc_cstr(str, enc); \
|
||||
})
|
||||
#endif
|
||||
#endif
|
||||
int rb_str_buf_cat_escaped_char(VALUE result, unsigned int c, int unicode_p);
|
||||
int rb_str_symname_p(VALUE);
|
||||
VALUE rb_str_quote_unprintable(VALUE);
|
||||
|
|
2
re.c
2
re.c
|
@ -2580,7 +2580,7 @@ rb_reg_initialize(VALUE obj, const char *s, long len, rb_encoding *enc,
|
|||
options & ARG_REG_OPTION_MASK, err,
|
||||
sourcefile, sourceline);
|
||||
if (!re->ptr) return -1;
|
||||
RB_OBJ_WRITE(obj, &re->src, rb_fstring(rb_enc_str_new(s, len, enc)));
|
||||
RB_OBJ_WRITE(obj, &re->src, rb_fstring_enc_new(s, len, enc));
|
||||
RB_GC_GUARD(unescaped);
|
||||
return 0;
|
||||
}
|
||||
|
|
14
string.c
14
string.c
|
@ -49,6 +49,7 @@
|
|||
#undef rb_str_cat2
|
||||
#undef rb_str_cat_cstr
|
||||
#undef rb_fstring_cstr
|
||||
#undef rb_fstring_enc_cstr
|
||||
|
||||
static VALUE rb_str_clear(VALUE str);
|
||||
|
||||
|
@ -359,12 +360,25 @@ rb_fstring_new(const char *ptr, long len)
|
|||
return register_fstring(setup_fake_str(&fake_str, ptr, len, ENCINDEX_US_ASCII));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_fstring_enc_new(const char *ptr, long len, rb_encoding *enc)
|
||||
{
|
||||
struct RString fake_str;
|
||||
return register_fstring(rb_setup_fake_str(&fake_str, ptr, len, enc));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_fstring_cstr(const char *ptr)
|
||||
{
|
||||
return rb_fstring_new(ptr, strlen(ptr));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_fstring_enc_cstr(const char *ptr, rb_encoding *enc)
|
||||
{
|
||||
return rb_fstring_enc_new(ptr, strlen(ptr), enc);
|
||||
}
|
||||
|
||||
static int
|
||||
fstring_set_class_i(st_data_t key, st_data_t val, st_data_t arg)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue