summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-03 13:03:54 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-09-03 13:03:54 +0000
commit5669902126ec202d2cb482e6d15c0c28bc6025cd (patch)
tree3512b669204ad8c6fcd5255fbff0e2278a61b241 /include
parentad6731b0f9a3e41fac176f90ed5c2cbb43618433 (diff)
string.c: rb_enc_str_new_cstr
* string.c (rb_enc_str_new_cstr): new function to create a string from the C-string pointer with the specified encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'include')
-rw-r--r--include/ruby/encoding.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h
index ebd9cfd262..e0dc66dec7 100644
--- a/include/ruby/encoding.h
+++ b/include/ruby/encoding.h
@@ -89,6 +89,7 @@ VALUE rb_enc_associate(VALUE, rb_encoding*);
void rb_enc_copy(VALUE dst, VALUE src);
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
+VALUE rb_enc_str_new_cstr(const char*, rb_encoding*);
VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
@@ -103,6 +104,15 @@ VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts);
+#if defined(__GNUC__) && !defined(__PCC__)
+#define rb_enc_str_new_cstr(str, enc) __extension__ ( \
+{ \
+ (__builtin_constant_p(str)) ? \
+ rb_enc_str_new((str), (long)strlen(str), (enc)) : \
+ rb_enc_str_new_cstr((str), (enc)); \
+})
+#endif
+
PRINTF_ARGS(NORETURN(void rb_enc_raise(rb_encoding *, VALUE, const char*, ...)), 3, 4);
/* index -> rb_encoding */