summaryrefslogtreecommitdiff
path: root/ext/-test-
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-01 08:09:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-01 08:09:17 +0000
commit41cbb7f05010b4f37490059ff8f5e52b4f1f8538 (patch)
treeacd50e060201989a20f157bf3e82cc62a41a9519 /ext/-test-
parent8d7d4e332241ca922b0821c2a5cd4b19c18a6cdf (diff)
cstr.c: split bug_str_cstr_unterm
* ext/-test-/string/cstr.c (bug_str_cstr_unterm): split unterminating from bug_str_cstr_term. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-')
-rw-r--r--ext/-test-/string/cstr.c30
1 files changed, 28 insertions, 2 deletions
diff --git a/ext/-test-/string/cstr.c b/ext/-test-/string/cstr.c
index ba2e46b..897793d 100644
--- a/ext/-test-/string/cstr.c
+++ b/ext/-test-/string/cstr.c
@@ -9,9 +9,7 @@ bug_str_cstr_term(VALUE str)
int c;
rb_encoding *enc;
- rb_str_modify(str);
len = RSTRING_LEN(str);
- RSTRING_PTR(str)[len] = 'x';
s = StringValueCStr(str);
rb_gc();
enc = rb_enc_get(str);
@@ -20,6 +18,17 @@ bug_str_cstr_term(VALUE str)
}
static VALUE
+bug_str_cstr_unterm(VALUE str, VALUE c)
+{
+ long len;
+
+ rb_str_modify(str);
+ len = RSTRING_LEN(str);
+ RSTRING_PTR(str)[len] = NUM2CHR(c);
+ return str;
+}
+
+static VALUE
bug_str_cstr_term_char(VALUE str)
{
long len;
@@ -42,6 +51,20 @@ bug_str_cstr_term_char(VALUE str)
}
static VALUE
+bug_str_s_cstr_term(VALUE self, VALUE str)
+{
+ Check_Type(str, T_STRING);
+ return bug_str_cstr_term(str);
+}
+
+static VALUE
+bug_str_s_cstr_unterm(VALUE self, VALUE str, VALUE c)
+{
+ Check_Type(str, T_STRING);
+ return bug_str_cstr_unterm(str, c);
+}
+
+static VALUE
bug_str_s_cstr_term_char(VALUE self, VALUE str)
{
Check_Type(str, T_STRING);
@@ -52,6 +75,9 @@ void
Init_cstr(VALUE klass)
{
rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0);
+ rb_define_method(klass, "cstr_unterm", bug_str_cstr_unterm, 1);
rb_define_method(klass, "cstr_term_char", bug_str_cstr_term_char, 0);
+ rb_define_singleton_method(klass, "cstr_term", bug_str_s_cstr_term, 1);
+ rb_define_singleton_method(klass, "cstr_unterm", bug_str_s_cstr_unterm, 2);
rb_define_singleton_method(klass, "cstr_term_char", bug_str_s_cstr_term_char, 1);
}