[前][次][番号順一覧][スレッド一覧]

ruby-changes:54626

From: nobu <ko1@a...>
Date: Thu, 17 Jan 2019 09:36:16 +0900 (JST)
Subject: [ruby-changes:54626] nobu:r66840 (trunk): call rb_str_modify to make a copy unshared

nobu	2019-01-17 09:36:08 +0900 (Thu, 17 Jan 2019)

  New Revision: 66840

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66840

  Log:
    call rb_str_modify to make a copy unshared

  Modified files:
    trunk/spec/ruby/optional/capi/ext/rubyspec.h
    trunk/spec/ruby/optional/capi/ext/string_spec.c
    trunk/spec/ruby/optional/capi/string_spec.rb
Index: spec/ruby/optional/capi/ext/rubyspec.h
===================================================================
--- spec/ruby/optional/capi/ext/rubyspec.h	(revision 66839)
+++ spec/ruby/optional/capi/ext/rubyspec.h	(revision 66840)
@@ -572,6 +572,7 @@ https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/rubyspec.h#L572
 #define HAVE_RB_STRING                     1
 #define HAVE_SAFE_STRING_VALUE             1
 #define HAVE_RB_STRING_VALUE_CSTR          1
+#define HAVE_RB_STR_MODIFY                 1
 
 /* Struct */
 #define HAVE_RB_STRUCT_AREF                1
Index: spec/ruby/optional/capi/ext/string_spec.c
===================================================================
--- spec/ruby/optional/capi/ext/string_spec.c	(revision 66839)
+++ spec/ruby/optional/capi/ext/string_spec.c	(revision 66840)
@@ -504,6 +504,13 @@ static VALUE string_spec_rb_string_value https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/string_spec.c#L504
 }
 #endif
 
+#ifdef HAVE_RB_STR_MODIFY
+static VALUE string_spec_rb_str_modify(VALUE self, VALUE str) {
+  rb_str_modify(str);
+  return str;
+}
+#endif
+
 void Init_string_spec(void) {
   VALUE cls;
   cls = rb_define_class("CApiStringSpecs", rb_cObject);
@@ -744,6 +751,10 @@ void Init_string_spec(void) { https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/ext/string_spec.c#L751
 #ifdef HAVE_RB_STRING_VALUE_CSTR
   rb_define_method(cls, "rb_string_value_cstr", string_spec_rb_string_value_cstr, 1);
 #endif
+
+#ifdef HAVE_RB_STR_MODIFY
+  rb_define_method(cls, "rb_str_modify", string_spec_rb_str_modify, 1);
+#endif
 }
 #ifdef __cplusplus
 }
Index: spec/ruby/optional/capi/string_spec.rb
===================================================================
--- spec/ruby/optional/capi/string_spec.rb	(revision 66839)
+++ spec/ruby/optional/capi/string_spec.rb	(revision 66840)
@@ -36,7 +36,8 @@ describe "C-API String function" do https://github.com/ruby/ruby/blob/trunk/spec/ruby/optional/capi/string_spec.rb#L36
     before :each do
       # Make a completely new copy of the string
       # for every example (#dup doesn't cut it).
-      @str = "abcdefghij"[0..-1]
+      @str = "abcdefghij"
+      @s.rb_str_modify(@str)
     end
 
     it "reduces the size of the string" do

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]