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

ruby-changes:36199

From: nobu <ko1@a...>
Date: Wed, 5 Nov 2014 15:05:26 +0900 (JST)
Subject: [ruby-changes:36199] nobu:r48280 (trunk): string.c: no terminator

nobu	2014-11-05 15:05:14 +0900 (Wed, 05 Nov 2014)

  New Revision: 48280

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

  Log:
    string.c: no terminator
    
    * string.c (rb_str_{,l,r}strip_bang): rb_str_subseq() will not
      NUL-terminate the result string, in the future, so it will not
      be needed in other cases.

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/string.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48279)
+++ ChangeLog	(revision 48280)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov  5 15:05:12 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* string.c (rb_str_{,l,r}strip_bang): rb_str_subseq() will not
+	  NUL-terminate the result string, in the future, so it will not
+	  be needed in other cases.
+
 Wed Nov  5 14:11:30 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (lib/unicode_normalize/tables.rb): do nothing unless
Index: string.c
===================================================================
--- string.c	(revision 48279)
+++ string.c	(revision 48280)
@@ -128,7 +128,10 @@ VALUE rb_cSymbol; https://github.com/ruby/ruby/blob/trunk/string.c#L128
 
 #define STR_ENC_GET(str) get_encoding(str)
 
-#if 1
+#if !defined SHARABLE_MIDDLE_SUBSTRING
+# define SHARABLE_MIDDLE_SUBSTRING 0
+#endif
+#if !SHARABLE_MIDDLE_SUBSTRING
 #define SHARABLE_SUBSTRING_P(beg, len, end) ((beg) + (len) == (end))
 #else
 #define SHARABLE_SUBSTRING_P(beg, len, end) 1
@@ -7227,7 +7230,9 @@ rb_str_lstrip_bang(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L7230
 	s = start + loffset;
 	memmove(start, s, len);
 	STR_SET_LEN(str, len);
+#if !SHARABLE_MIDDLE_SUBSTRING
 	TERM_FILL(start+len, rb_enc_mbminlen(enc));
+#endif
 	return str;
     }
     return Qnil;
@@ -7309,7 +7314,9 @@ rb_str_rstrip_bang(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L7314
 	long len = olen - roffset;
 
 	STR_SET_LEN(str, len);
+#if !SHARABLE_MIDDLE_SUBSTRING
 	TERM_FILL(start+len, rb_enc_mbminlen(enc));
+#endif
 	return str;
     }
     return Qnil;
@@ -7371,7 +7378,9 @@ rb_str_strip_bang(VALUE str) https://github.com/ruby/ruby/blob/trunk/string.c#L7378
 	    memmove(start, start + loffset, len);
 	}
 	STR_SET_LEN(str, len);
+#if !SHARABLE_MIDDLE_SUBSTRING
 	TERM_FILL(start+len, rb_enc_mbminlen(enc));
+#endif
 	return str;
     }
     return Qnil;
Index: NEWS
===================================================================
--- NEWS	(revision 48279)
+++ NEWS	(revision 48280)
@@ -290,10 +290,10 @@ with all sufficient information, see the https://github.com/ruby/ruby/blob/trunk/NEWS#L290
 
 * rb_str_cat_cstr() added. This is same as `rb_str_cat2()`.
 
-* `rb_str_substr()` and `rb_str_subseq()` now share middle of a string,
-  but not only the end of a string.  Therefore, result strings may not
-  be NUL-terminated, `StringValueCStr()` is needed calling to obtain a
-  NUL-terminated C string.
+* `rb_str_substr()` and `rb_str_subseq()` will share middle of a string,
+  but not only the end of a string, in the futre.  Therefore, result
+  strings may not be NUL-terminated, `StringValueCStr()` is needed
+  calling to obtain a NUL-terminated C string.
 
 * rb_tracepoint_new() supports new internal events accessible only from C:
   * RUBY_INTERNAL_EVENT_GC_ENTER

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

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