diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-19 05:53:05 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-09-19 05:53:05 +0000 |
commit | eb0e3fe78fa5338299fde5e5263121df1a64493c (patch) | |
tree | a7245817207c59ea774339f873b67417b23073e2 | |
parent | abac84856448e8a15e941cce8c1e48f891e83a3c (diff) | |
download | ruby-eb0e3fe78fa5338299fde5e5263121df1a64493c.tar.gz |
intern.h: rb_str_new_literal
* include/ruby/intern.h (rb_str_new_literal): make ruby string
from literal C-string. incorporated from mruby.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | README.EXT | 19 | ||||
-rw-r--r-- | README.EXT.ja | 16 | ||||
-rw-r--r-- | include/ruby/intern.h | 4 |
3 files changed, 39 insertions, 0 deletions
diff --git a/README.EXT b/README.EXT index f4e4a20d14..9f5c1a83fc 100644 --- a/README.EXT +++ b/README.EXT @@ -184,6 +184,10 @@ rb_str_new_cstr(const char *ptr) :: Creates a new Ruby string from a C string. This is equivalent to rb_str_new(ptr, strlen(ptr)). +rb_str_new_literal(const char *ptr) :: + + Creates a new Ruby string from a C string literal. + rb_tainted_str_new(const char *ptr, long len) :: Creates a new tainted Ruby string. Strings from external data @@ -226,16 +230,31 @@ rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc) :: Creates a new Ruby string with the specified encoding. +rb_enc_str_new_literal(const char *ptr) :: + + Creates a new Ruby string from a C string literal with the specified + encoding. + rb_usascii_str_new(const char *ptr, long len) :: rb_usascii_str_new_cstr(const char *ptr) :: Creates a new Ruby string with encoding US-ASCII. +rb_usascii_str_new_literal(const char *ptr) :: + + Creates a new Ruby string from a C string literal with encoding + US-ASCII. + rb_utf8_str_new(const char *ptr, long len) :: rb_utf8_str_new_cstr(const char *ptr) :: Creates a new Ruby string with encoding UTF-8. +rb_utf8_str_new_literal(const char *ptr) :: + + Creates a new Ruby string from a C string literal with encoding + UTF-8. + rb_str_resize(VALUE str, long len) :: Resizes Ruby string to len bytes. If str is not modifiable, this diff --git a/README.EXT.ja b/README.EXT.ja index 8027512c6a..447b21c2a0 100644 --- a/README.EXT.ja +++ b/README.EXT.ja @@ -209,6 +209,10 @@ rb_str_new_cstr(const char *ptr) Cの文字列からRubyの文字列を生成する.この関数の機能は rb_str_new(ptr, strlen(ptr))と同等である. +rb_str_new_literal(const char *ptr) + + Cのリテラル文字列からRubyの文字列を生成する. + rb_tainted_str_new(const char *ptr, long len) 汚染マークが付加された新しいRubyの文字列を生成する.外部 @@ -252,16 +256,28 @@ rb_enc_str_new_cstr(const char *ptr, rb_encoding *enc) 指定されたエンコーディングでRubyの文字列を生成する. +rb_enc_str_new_literal(const char *ptr) + + Cのリテラル文字列から指定されたエンコーディングでRubyの文字列を生成する. + rb_usascii_str_new(const char *ptr, long len) rb_usascii_str_new_cstr(const char *ptr) エンコーディングがUS-ASCIIのRubyの文字列を生成する. +rb_usascii_str_new_literal(const char *ptr) + + Cのリテラル文字列からエンコーディングがUS-ASCIIのRubyの文字列を生成する. + rb_utf8_str_new(const char *ptr, long len) rb_utf8_str_new_cstr(const char *ptr) エンコーディングがUTF-8のRubyの文字列を生成する. +rb_usascii_str_new_literal(const char *ptr) + + Cのリテラル文字列からエンコーディングがUTF-8のRubyの文字列を生成する. + rb_str_resize(VALUE str, long len) Rubyの文字列のサイズをlenバイトに変更する.strの長さは前 diff --git a/include/ruby/intern.h b/include/ruby/intern.h index b8377bc5b2..41f256722e 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -818,6 +818,10 @@ VALUE rb_str_scrub(VALUE, VALUE); rb_utf8_str_new_static((str), (long)strlen(str)) : \ rb_utf8_str_new_cstr(str); \ }) +#define rb_str_new_literal(str) rb_str_new_static((str), sizeof(str)-1) +#define rb_usascii_str_new_literal(str) rb_usascii_str_new_static((str), sizeof(str)-1) +#define rb_utf8_str_new_literal(str) rb_utf8_str_new_static((str), sizeof(str)-1) +#define rb_enc_str_new_literal(str, enc) rb_enc_str_new_static((str), sizeof(str)-1, (enc)) #define rb_external_str_new_cstr(str) __extension__ ( \ { \ (__builtin_constant_p(str)) ? \ |