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

ruby-changes:7994

From: matz <ko1@a...>
Date: Wed, 24 Sep 2008 16:01:02 +0900 (JST)
Subject: [ruby-changes:7994] Ruby:r19518 (trunk): * string.c (rb_str_rstrip_bang): removing mixed spaces and nuls at

matz	2008-09-24 16:00:43 +0900 (Wed, 24 Sep 2008)

  New Revision: 19518

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

  Log:
    * string.c (rb_str_rstrip_bang): removing mixed spaces and nuls at
      the end of strings.  [ruby-dev:36497]

  Modified files:
    trunk/ChangeLog
    trunk/string.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 19517)
+++ ChangeLog	(revision 19518)
@@ -1,3 +1,8 @@
+Wed Sep 24 15:58:52 2008  Yukihiro Matsumoto  <matz@r...>
+
+	* string.c (rb_str_rstrip_bang): removing mixed spaces and nuls at
+	  the end of strings.  [ruby-dev:36497]
+
 Wed Sep 24 15:13:04 2008  Takeyuki Fujioka  <xibbar@r...>
 
 	* test/cgi/test_cgi_multipart.rb : test for miniunit.
Index: string.c
===================================================================
--- string.c	(revision 19517)
+++ string.c	(revision 19518)
@@ -5861,11 +5861,8 @@
     t = e = RSTRING_END(str);
 
     if (single_byte_optimizable(str)) {
-        /* remove trailing '\0's */
-        while (s < t && t[-1] == '\0') t--;
-      
-	/* remove trailing spaces */
-	while (s < t && rb_enc_isspace(*(t-1), enc)) t--;
+	/* remove trailing spaces or '\0's */
+	while (s < t && (t[-1] == '\0' || rb_enc_isspace(*(t-1), enc))) t--;
     }
     else {
 	char *tp;

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

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