aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--string.c7
2 files changed, 7 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index fb3d3dffae..f6aff7f594 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Wed Sep 24 15:58:52 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* test/cgi/test_cgi_multipart.rb : test for miniunit.
diff --git a/string.c b/string.c
index 46c1908350..33d03e13c6 100644
--- a/string.c
+++ b/string.c
@@ -5861,11 +5861,8 @@ rb_str_rstrip_bang(VALUE str)
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;