summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-17 05:22:57 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-04-17 05:22:57 (GMT)
commit37dffb599de6ad056c686f41881e9967dee4418e (patch)
tree1861c6ed6f8c594d0aa1916c1798efa06a67e249
parent3d69324be300fce437536f7b7ac5f3d5c8c54d7d (diff)
string.c: rb_str_cat_cstr
* string.c (rb_str_cat): make non-buf version main. * string.c (rb_str_cat_cstr): rename from rb_str_cat2. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--NEWS2
-rw-r--r--README.EXT1
-rw-r--r--README.EXT.ja1
-rw-r--r--include/ruby/intern.h14
-rw-r--r--string.c11
5 files changed, 17 insertions, 12 deletions
diff --git a/NEWS b/NEWS
index acf414c..f1f7e66 100644
--- a/NEWS
+++ b/NEWS
@@ -105,3 +105,5 @@ with all sufficient information, see the ChangeLog file.
* struct RSymbol added. This represents a dynamic symbol as object in
Ruby's heaps.
+
+* rb_str_cat_cstr() added. This is same as `rb_str_cat2()`.
diff --git a/README.EXT b/README.EXT
index b362737..6ba0e6f 100644
--- a/README.EXT
+++ b/README.EXT
@@ -208,6 +208,7 @@ rb_str_cat(VALUE str, const char *ptr, long len) ::
Appends len bytes of data from ptr to the Ruby string.
rb_str_cat2(VALUE str, const char* ptr) ::
+rb_str_cat_cstr(VALUE str, const char* ptr) ::
Appends C string ptr to Ruby string str. This function is
equivalent to rb_str_cat(str, ptr, strlen(ptr)).
diff --git a/README.EXT.ja b/README.EXT.ja
index d18b81b..5a0073e 100644
--- a/README.EXT.ja
+++ b/README.EXT.ja
@@ -234,6 +234,7 @@ rb_str_cat(VALUE str, const char *ptr, long len)
Rubyの文字列strにlenバイトの文字列ptrを追加する.
rb_str_cat2(VALUE str, const char* ptr)
+rb_str_cat_cstr(VALUE str, const char* ptr)
Rubyの文字列strにCの文字列ptrを追加する.この関数の機能は
rb_str_cat(str, ptr, strlen(ptr))と同等である.
diff --git a/include/ruby/intern.h b/include/ruby/intern.h
index 26b880e..c69d378 100644
--- a/include/ruby/intern.h
+++ b/include/ruby/intern.h
@@ -727,6 +727,7 @@ VALUE rb_str_freeze(VALUE);
void rb_str_set_len(VALUE, long);
VALUE rb_str_resize(VALUE, long);
VALUE rb_str_cat(VALUE, const char*, long);
+VALUE rb_str_cat_cstr(VALUE, const char*);
VALUE rb_str_cat2(VALUE, const char*);
VALUE rb_str_append(VALUE, VALUE);
VALUE rb_str_concat(VALUE, VALUE);
@@ -798,17 +799,11 @@ VALUE rb_str_scrub(VALUE, VALUE);
(str), (long)strlen(str)) : \
rb_str_buf_new_cstr(str); \
})
-#define rb_str_buf_cat2(str, ptr) __extension__ ( \
-{ \
- (__builtin_constant_p(ptr)) ? \
- rb_str_buf_cat((str), (ptr), (long)strlen(ptr)) : \
- rb_str_buf_cat2((str), (ptr)); \
-})
-#define rb_str_cat2(str, ptr) __extension__ ( \
+#define rb_str_cat_cstr(str, ptr) __extension__ ( \
{ \
(__builtin_constant_p(ptr)) ? \
rb_str_cat((str), (ptr), (long)strlen(ptr)) : \
- rb_str_cat2((str), (ptr)); \
+ rb_str_cat_cstr((str), (ptr)); \
})
#define rb_exc_new_cstr(klass, ptr) __extension__ ( \
{ \
@@ -824,6 +819,9 @@ VALUE rb_str_scrub(VALUE, VALUE);
#define rb_tainted_str_new2 rb_tainted_str_new_cstr
#define rb_str_buf_new2 rb_str_buf_new_cstr
#define rb_usascii_str_new2 rb_usascii_str_new_cstr
+#define rb_str_buf_cat rb_str_cat
+#define rb_str_buf_cat2 rb_str_cat_cstr
+#define rb_str_cat2 rb_str_cat_cstr
/* struct.c */
VALUE rb_struct_new(VALUE, ...);
VALUE rb_struct_define(const char*, ...);
diff --git a/string.c b/string.c
index 3ad5eed..3845430 100644
--- a/string.c
+++ b/string.c
@@ -38,8 +38,10 @@
#undef rb_locale_str_new_cstr
#undef rb_str_dup_frozen
#undef rb_str_buf_new_cstr
+#undef rb_str_buf_cat
#undef rb_str_buf_cat2
#undef rb_str_cat2
+#undef rb_str_cat_cstr
static VALUE rb_str_clear(VALUE str);
@@ -2048,7 +2050,7 @@ str_buf_cat(VALUE str, const char *ptr, long len)
#define str_buf_cat2(str, ptr) str_buf_cat((str), (ptr), strlen(ptr))
VALUE
-rb_str_buf_cat(VALUE str, const char *ptr, long len)
+rb_str_cat(VALUE str, const char *ptr, long len)
{
if (len == 0) return str;
if (len < 0) {
@@ -2058,13 +2060,14 @@ rb_str_buf_cat(VALUE str, const char *ptr, long len)
}
VALUE
-rb_str_buf_cat2(VALUE str, const char *ptr)
+rb_str_cat_cstr(VALUE str, const char *ptr)
{
return rb_str_buf_cat(str, ptr, strlen(ptr));
}
-RUBY_ALIAS_FUNCTION(rb_str_cat(VALUE str, const char *ptr, long len), rb_str_buf_cat, (str, ptr, len))
-RUBY_ALIAS_FUNCTION(rb_str_cat2(VALUE str, const char *ptr), rb_str_buf_cat2, (str, ptr))
+RUBY_ALIAS_FUNCTION(rb_str_buf_cat(VALUE str, const char *ptr, long len), rb_str_cat, (str, ptr, len))
+RUBY_ALIAS_FUNCTION(rb_str_buf_cat2(VALUE str, const char *ptr), rb_str_cat_cstr, (str, ptr))
+RUBY_ALIAS_FUNCTION(rb_str_cat2(VALUE str, const char *ptr), rb_str_cat_cstr, (str, ptr))
static VALUE
rb_enc_cr_str_buf_cat(VALUE str, const char *ptr, long len,