Skip to content

Commit

Permalink
string.c: rb_str_cat_cstr
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nobu committed Apr 17, 2014
1 parent 3d69324 commit 37dffb5
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -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()`.
1 change: 1 addition & 0 deletions README.EXT
Original file line number Diff line number Diff line change
Expand Up @@ -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)).
Expand Down
1 change: 1 addition & 0 deletions README.EXT.ja
Original file line number Diff line number Diff line change
Expand Up @@ -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))と同等である.
Expand Down
14 changes: 6 additions & 8 deletions include/ruby/intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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__ ( \
{ \
Expand All @@ -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*, ...);
Expand Down
11 changes: 7 additions & 4 deletions string.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand All @@ -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,
Expand Down

0 comments on commit 37dffb5

Please sign in to comment.