summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-10 08:35:17 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-10 08:35:17 +0000
commit10174c295b91ef1370d3c910755d79c895d0ef32 (patch)
treee92c83d7fd5b54fafac022126c03e00471295002
parent13f576d6b9f76c6ab2e6762dc78697309dac3708 (diff)
* string.c: Special-case :ascii option in rb_str_capitalize_bang and
rb_str_swapcase_bang. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--string.c10
2 files changed, 13 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index a8c3673a06..cd07e66ac7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Jun 10 17:35:11 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
+
+ * string.c: Special-case :ascii option in rb_str_capitalize_bang and
+ rb_str_swapcase_bang.
+
Fri Jun 10 17:12:24 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* string.c: Special-case :ascii option in rb_str_upcase_bang (retry).
diff --git a/string.c b/string.c
index 83c8271ac3..4567ce2af3 100644
--- a/string.c
+++ b/string.c
@@ -6053,7 +6053,10 @@ rb_str_capitalize_bang(int argc, VALUE *argv, VALUE str)
enc = STR_ENC_GET(str);
rb_str_check_dummy_enc(enc);
if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil;
- str_shared_replace(str, rb_str_casemap(str, &flags, enc));
+ if (flags&ONIGENC_CASE_ASCII_ONLY)
+ rb_str_ascii_casemap(str, &flags, enc);
+ else
+ str_shared_replace(str, rb_str_casemap(str, &flags, enc));
if (ONIGENC_CASE_MODIFIED&flags) return str;
return Qnil;
@@ -6105,7 +6108,10 @@ rb_str_swapcase_bang(int argc, VALUE *argv, VALUE str)
str_modify_keep_cr(str);
enc = STR_ENC_GET(str);
rb_str_check_dummy_enc(enc);
- str_shared_replace(str, rb_str_casemap(str, &flags, enc));
+ if (flags&ONIGENC_CASE_ASCII_ONLY)
+ rb_str_ascii_casemap(str, &flags, enc);
+ else
+ str_shared_replace(str, rb_str_casemap(str, &flags, enc));
if (ONIGENC_CASE_MODIFIED&flags) return str;
return Qnil;