diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:27:23 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-05-14 11:27:23 +0000 |
commit | aa6e98139c8e1ea442fb2182341aaa08ff55b529 (patch) | |
tree | a509eb830418991995bfe3b840d4bf270ff7f0e2 /ruby_1_9_3/ext/-test-/string | |
parent | 9e9d191cf367caa17776231a2d0fad0da47b160a (diff) |
add tag v1_9_3_426
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_9_3_426@40733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ruby_1_9_3/ext/-test-/string')
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/cstr.c | 20 | ||||
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/ellipsize.c | 13 | ||||
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/enc_associate.c | 14 | ||||
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/extconf.rb | 6 | ||||
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/init.c | 11 | ||||
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/modify.c | 22 | ||||
-rw-r--r-- | ruby_1_9_3/ext/-test-/string/set_len.c | 14 |
7 files changed, 100 insertions, 0 deletions
diff --git a/ruby_1_9_3/ext/-test-/string/cstr.c b/ruby_1_9_3/ext/-test-/string/cstr.c new file mode 100644 index 0000000000..d4ff360575 --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/cstr.c @@ -0,0 +1,20 @@ +#include "ruby.h" + +static VALUE +bug_str_cstr_term(VALUE str) +{ + long len; + char *s; + rb_str_modify(str); + len = RSTRING_LEN(str); + RSTRING_PTR(str)[len] = 'x'; + s = StringValueCStr(str); + rb_gc(); + return INT2NUM(s[len]); +} + +void +Init_cstr(VALUE klass) +{ + rb_define_method(klass, "cstr_term", bug_str_cstr_term, 0); +} diff --git a/ruby_1_9_3/ext/-test-/string/ellipsize.c b/ruby_1_9_3/ext/-test-/string/ellipsize.c new file mode 100644 index 0000000000..0451519492 --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/ellipsize.c @@ -0,0 +1,13 @@ +#include "ruby.h" + +static VALUE +bug_str_ellipsize(VALUE str, VALUE len) +{ + return rb_str_ellipsize(str, NUM2LONG(len)); +} + +void +Init_ellipsize(VALUE klass) +{ + rb_define_method(klass, "ellipsize", bug_str_ellipsize, 1); +} diff --git a/ruby_1_9_3/ext/-test-/string/enc_associate.c b/ruby_1_9_3/ext/-test-/string/enc_associate.c new file mode 100644 index 0000000000..d6614fb298 --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/enc_associate.c @@ -0,0 +1,14 @@ +#include "ruby.h" +#include "ruby/encoding.h" + +VALUE +bug_str_enc_associate(VALUE str, VALUE enc) +{ + return rb_enc_associate(str, rb_to_encoding(enc)); +} + +void +Init_enc_associate(VALUE klass) +{ + rb_define_method(klass, "associate_encoding!", bug_str_enc_associate, 1); +} diff --git a/ruby_1_9_3/ext/-test-/string/extconf.rb b/ruby_1_9_3/ext/-test-/string/extconf.rb new file mode 100644 index 0000000000..42c10b994b --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/extconf.rb @@ -0,0 +1,6 @@ +$srcs = Dir[File.join($srcdir, "*.{#{SRC_EXT.join(%q{,})}}")] +inits = $srcs.map {|s| File.basename(s, ".*")} +inits.delete("init") +inits.map! {|s|"X(#{s})"} +$defs << "-DTEST_INIT_FUNCS(X)=\"#{inits.join(' ')}\"" +create_makefile("-test-/string/string") diff --git a/ruby_1_9_3/ext/-test-/string/init.c b/ruby_1_9_3/ext/-test-/string/init.c new file mode 100644 index 0000000000..0b3e4a6ff2 --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/init.c @@ -0,0 +1,11 @@ +#include "ruby.h" + +#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);} + +void +Init_string(void) +{ + VALUE mBug = rb_define_module("Bug"); + VALUE klass = rb_define_class_under(mBug, "String", rb_cString); + TEST_INIT_FUNCS(init); +} diff --git a/ruby_1_9_3/ext/-test-/string/modify.c b/ruby_1_9_3/ext/-test-/string/modify.c new file mode 100644 index 0000000000..ddd2efd8f0 --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/modify.c @@ -0,0 +1,22 @@ +#include "ruby.h" + +VALUE +bug_str_modify(VALUE str) +{ + rb_str_modify(str); + return str; +} + +VALUE +bug_str_modify_expand(VALUE str, VALUE expand) +{ + rb_str_modify_expand(str, NUM2LONG(expand)); + return str; +} + +void +Init_modify(VALUE klass) +{ + rb_define_method(klass, "modify!", bug_str_modify, 0); + rb_define_method(klass, "modify_expand!", bug_str_modify_expand, 1); +} diff --git a/ruby_1_9_3/ext/-test-/string/set_len.c b/ruby_1_9_3/ext/-test-/string/set_len.c new file mode 100644 index 0000000000..3c7d19d778 --- /dev/null +++ b/ruby_1_9_3/ext/-test-/string/set_len.c @@ -0,0 +1,14 @@ +#include "ruby.h" + +static VALUE +bug_str_set_len(VALUE str, VALUE len) +{ + rb_str_set_len(str, NUM2LONG(len)); + return str; +} + +void +Init_set_len(VALUE klass) +{ + rb_define_method(klass, "set_len", bug_str_set_len, 1); +} |