mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
string.c: rb_fstring_cstr
* string.c (rb_fstring_cstr): new function to make a fstring from a string literal. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0161f79a12
commit
d3199656be
3 changed files with 20 additions and 1 deletions
|
@ -1,4 +1,7 @@
|
|||
Wed Jun 24 12:47:14 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
Wed Jun 24 12:49:11 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (rb_fstring_cstr): new function to make a fstring from
|
||||
a string literal.
|
||||
|
||||
* internal.h (rb_fstring_lit): new macro to make a fstring from a
|
||||
string literal.
|
||||
|
|
|
@ -1091,6 +1091,15 @@ VALUE rb_fstring(VALUE);
|
|||
VALUE rb_fstring_new(const char *ptr, long len);
|
||||
#define rb_fstring_lit(str) rb_fstring_new((str), rb_strlen_lit(str))
|
||||
#define rb_fstring_literal(str) rb_fstring_lit(str)
|
||||
VALUE rb_fstring_cstr(const char *str);
|
||||
#if defined(__GNUC__) && !defined(__PCC__)
|
||||
#define rb_fstring_cstr(str) __extension__ ( \
|
||||
{ \
|
||||
(__builtin_constant_p(str)) ? \
|
||||
rb_fstring_new((str), (long)strlen(str)) : \
|
||||
rb_fstring_cstr(str); \
|
||||
})
|
||||
#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);
|
||||
|
|
7
string.c
7
string.c
|
@ -46,6 +46,7 @@
|
|||
#undef rb_str_buf_cat2
|
||||
#undef rb_str_cat2
|
||||
#undef rb_str_cat_cstr
|
||||
#undef rb_fstring_cstr
|
||||
|
||||
static VALUE rb_str_clear(VALUE str);
|
||||
|
||||
|
@ -303,6 +304,12 @@ rb_fstring_new(const char *ptr, long len)
|
|||
return rb_fstring(setup_fake_str(&fake_str, ptr, len, ENCINDEX_US_ASCII));
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_fstring_cstr(const char *ptr)
|
||||
{
|
||||
return rb_fstring_new(ptr, strlen(ptr));
|
||||
}
|
||||
|
||||
static int
|
||||
fstring_set_class_i(st_data_t key, st_data_t val, st_data_t arg)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue