summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-24 07:00:43 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-09-24 07:00:43 +0000
commitbfa3763a21d05ff854ce02212f1ed9ab89990d52 (patch)
treeccca3bde8a93ece543dcaf9ee3ed2785fbe7ac30 /string.c
parent79012388765712e07c09b6493f9b81c3ef87f9fc (diff)
downloadruby-bfa3763a21d05ff854ce02212f1ed9ab89990d52.tar.gz
ruby-bfa3763a21d05ff854ce02212f1ed9ab89990d52.tar.xz
ruby-bfa3763a21d05ff854ce02212f1ed9ab89990d52.zip
* string.c (rb_str_rstrip_bang): removing mixed spaces and nuls at
the end of strings. [ruby-dev:36497] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@19518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/string.c b/string.c
index 46c190835..33d03e13c 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;