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

ruby-changes:45975

From: naruse <ko1@a...>
Date: Tue, 21 Mar 2017 23:11:46 +0900 (JST)
Subject: [ruby-changes:45975] naruse:r58046 (ruby_2_4): merge revision(s) 58042: [Backport #13339]

naruse	2017-03-21 23:11:42 +0900 (Tue, 21 Mar 2017)

  New Revision: 58046

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

  Log:
    merge revision(s) 58042: [Backport #13339]
    
    string.c: use the usable size
    
    * string.c (rb_str_change_terminator_length): when called after
      the content has been copied, old terminator length no longer
      makes sense.  use the whole usable size instead of capacity
      without terminator.  [ruby-core:80257] [Bug #13339]

  Modified directories:
    branches/ruby_2_4/
  Modified files:
    branches/ruby_2_4/string.c
    branches/ruby_2_4/version.h
Index: ruby_2_4/version.h
===================================================================
--- ruby_2_4/version.h	(revision 58045)
+++ ruby_2_4/version.h	(revision 58046)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1
 #define RUBY_VERSION "2.4.0"
 #define RUBY_RELEASE_DATE "2017-03-21"
-#define RUBY_PATCHLEVEL 108
+#define RUBY_PATCHLEVEL 109
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_4/string.c
===================================================================
--- ruby_2_4/string.c	(revision 58045)
+++ ruby_2_4/string.c	(revision 58046)
@@ -2102,11 +2102,11 @@ str_fill_term(VALUE str, char *s, long l https://github.com/ruby/ruby/blob/trunk/ruby_2_4/string.c#L2102
 void
 rb_str_change_terminator_length(VALUE str, const int oldtermlen, const int termlen)
 {
-    long capa = str_capacity(str, oldtermlen);
+    long capa = str_capacity(str, oldtermlen) + oldtermlen;
     long len = RSTRING_LEN(str);
 
     assert(capa >= len);
-    if (capa - len < termlen - oldtermlen) {
+    if (capa - len < termlen) {
 	rb_check_lockedtmp(str);
 	str_make_independent_expand(str, len, 0L, termlen);
     }
@@ -2118,7 +2118,7 @@ rb_str_change_terminator_length(VALUE st https://github.com/ruby/ruby/blob/trunk/ruby_2_4/string.c#L2118
 	if (!STR_EMBED_P(str)) {
 	    /* modify capa instead of realloc */
 	    assert(!FL_TEST((str), STR_SHARED));
-	    RSTRING(str)->as.heap.aux.capa = capa - (termlen - oldtermlen);
+	    RSTRING(str)->as.heap.aux.capa = capa - termlen;
 	}
 	if (termlen > oldtermlen) {
 	    TERM_FILL(RSTRING_PTR(str) + len, termlen);

Property changes on: ruby_2_4
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r58042


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

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