ruby-changes:43486
From: ngoto <ko1@a...>
Date: Sat, 2 Jul 2016 03:11:17 +0900 (JST)
Subject: [ruby-changes:43486] ngoto:r55559 (trunk): * string.c: Partially reverts r55547 and r55555.
ngoto 2016-07-02 03:11:11 +0900 (Sat, 02 Jul 2016) New Revision: 55559 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=55559 Log: * string.c: Partially reverts r55547 and r55555. ChangeLog about the reverted changes are also deleted in this file. [Bug #12536] [ruby-dev:49699] [ruby-dev:49702] Modified files: trunk/ChangeLog trunk/string.c Index: string.c =================================================================== --- string.c (revision 55558) +++ string.c (revision 55559) @@ -120,7 +120,6 @@ VALUE rb_cSymbol; https://github.com/ruby/ruby/blob/trunk/string.c#L120 if (UNLIKELY(term_fill_len > 1))\ memset(term_fill_ptr, 0, term_fill_len);\ } while (0) -#define TERM_LEN_MAX 4 /* UTF-32LE, UTF-32BE */ #define RESIZE_CAPA(str,capacity) do {\ const int termlen = TERM_LEN(str);\ @@ -714,7 +713,7 @@ str_new0(VALUE klass, const char *ptr, l https://github.com/ruby/ruby/blob/trunk/string.c#L713 static VALUE str_new(VALUE klass, const char *ptr, long len) { - return str_new0(klass, ptr, len, TERM_LEN_MAX); + return str_new0(klass, ptr, len, 1); } VALUE @@ -726,7 +725,7 @@ rb_str_new(const char *ptr, long len) https://github.com/ruby/ruby/blob/trunk/string.c#L725 VALUE rb_usascii_str_new(const char *ptr, long len) { - VALUE str = str_new0(rb_cString, ptr, len, 1); /* termlen == 1 */ + VALUE str = rb_str_new(ptr, len); ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT); return str; } @@ -734,7 +733,7 @@ rb_usascii_str_new(const char *ptr, long https://github.com/ruby/ruby/blob/trunk/string.c#L733 VALUE rb_utf8_str_new(const char *ptr, long len) { - VALUE str = str_new0(rb_cString, ptr, len, 1); /* termlen == 1 */ + VALUE str = str_new(rb_cString, ptr, len); rb_enc_associate_index(str, rb_utf8_encindex()); return str; } @@ -758,17 +757,10 @@ rb_str_new_cstr(const char *ptr) https://github.com/ruby/ruby/blob/trunk/string.c#L757 return rb_str_new(ptr, strlen(ptr)); } -static VALUE -str_new0_cstr(const char *ptr, int termlen) -{ - must_not_null(ptr); - return str_new0(rb_cString, ptr, strlen(ptr), termlen); -} - VALUE rb_usascii_str_new_cstr(const char *ptr) { - VALUE str = str_new0_cstr(ptr, 1); /* termlen == 1 */ + VALUE str = rb_str_new_cstr(ptr); ENCODING_CODERANGE_SET(str, rb_usascii_encindex(), ENC_CODERANGE_7BIT); return str; } @@ -776,7 +768,7 @@ rb_usascii_str_new_cstr(const char *ptr) https://github.com/ruby/ruby/blob/trunk/string.c#L768 VALUE rb_utf8_str_new_cstr(const char *ptr) { - VALUE str = str_new0_cstr(ptr, 1); /* termlen == 1 */ + VALUE str = rb_str_new_cstr(ptr); rb_enc_associate_index(str, rb_utf8_encindex()); return str; } @@ -1202,7 +1194,7 @@ rb_str_buf_new(long capa) https://github.com/ruby/ruby/blob/trunk/string.c#L1194 } FL_SET(str, STR_NOEMBED); RSTRING(str)->as.heap.aux.capa = capa; - RSTRING(str)->as.heap.ptr = ALLOC_N(char, capa + TERM_LEN_MAX); + RSTRING(str)->as.heap.ptr = ALLOC_N(char, capa+1); RSTRING(str)->as.heap.ptr[0] = '\0'; return str; Index: ChangeLog =================================================================== --- ChangeLog (revision 55558) +++ ChangeLog (revision 55559) @@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Jul 2 03:09:27 2016 Naohisa Goto <ngotogenome@g...> + + * string.c: Partially reverts r55547 and r55555. + ChangeLog about the reverted changes are also deleted in this file. + [Bug #12536] [ruby-dev:49699] [ruby-dev:49702] + Sat Jul 2 02:22:22 2016 Naohisa Goto <ngotogenome@g...> * string.c (str_fill_term): When termlen increases, re-allocation @@ -10,15 +16,6 @@ Fri Jul 1 20:20:20 2016 Naohisa Goto https://github.com/ruby/ruby/blob/trunk/ChangeLog#L16 * string.c: Specify termlen as far as possible. Additional fix for [Bug #12536] [ruby-dev:49699]. - * string.c (rb_usascii_str_new, rb_utf8_str_new): Specify termlen - which is apparently 1 for the encodings. - - * string.c (str_new0_cstr): New static function to create a String - object from a C string with specifying termlen. - - * string.c (rb_usascii_str_new_cstr, rb_utf8_str_new_cstr): Specify - termlen by using new str_new0_cstr(). - * string.c (str_new_static): Specify termlen from the given encoding when creating a new String object is needed. @@ -67,13 +64,6 @@ Thu Jun 30 19:15:13 2016 Naohisa Goto https://github.com/ruby/ruby/blob/trunk/ChangeLog#L64 * string.c: Fix memory corruptions when using UTF-16/32 strings. [Bug #12536] [ruby-dev:49699] - * string.c (TERM_LEN_MAX): Macro for the longest TERM_FILL length, - the same as largest value of rb_enc_mbminlen(enc) among encodings. - - * string.c (str_new, rb_str_buf_new, str_shared_replace): Allocate - +TERM_LEN_MAX bytes instead of +1. This change may increase memory - usage. - * string.c (rb_str_new_with_class): Use TERM_LEN of the "obj". * string.c (rb_str_plus, rb_str_justify): Use str_new0 which is aware -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/