summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-08 12:57:44 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-06-08 12:57:44 +0000
commit5eb73eeda81b63d3d9d219b36bfd98dc27671a13 (patch)
tree3bc9f9fd2eca09c0700ecafccd2362836f1bd69c
parentf0fc6ec872f043836f01455b16feee6bb9ed9eb9 (diff)
* string.c: Special-case :ascii option in rb_str_upcase_bang.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55330 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--string.c11
2 files changed, 9 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 23806d8355..7d2e134a81 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jun 8 21:57:41 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
+
+ * string.c: Special-case :ascii option in rb_str_upcase_bang.
+
Wed Jun 8 21:28:36 2016 Martin Duerst <duerst@it.aoyama.ac.jp>
* string.c: New static function rb_str_ascii_casemap; special-casing
diff --git a/string.c b/string.c
index e1cedf42aa..a8d06be52d 100644
--- a/string.c
+++ b/string.c
@@ -5871,7 +5871,6 @@ static VALUE
rb_str_upcase_bang(int argc, VALUE *argv, VALUE str)
{
rb_encoding *enc;
- int modify = 0;
OnigCaseFoldType flags = ONIGENC_CASE_UPCASE;
flags = check_case_options(argc, argv, flags);
@@ -5887,17 +5886,17 @@ rb_str_upcase_bang(int argc, VALUE *argv, VALUE str)
if (rb_enc_isascii(c, enc) && 'a' <= c && c <= 'z') {
*s = 'A' + (c - 'a');
- modify = 1;
+ flags |= ONIGENC_CASE_MODIFIED;
}
s++;
}
}
- else {
+ else if (flags&ONIGENC_CASE_ASCII_ONLY)
+ rb_str_ascii_casemap(str, &flags, enc);
+ else
str_shared_replace(str, rb_str_casemap(str, &flags, enc));
- modify = ONIGENC_CASE_MODIFIED & flags;
- }
- if (modify) return str;
+ if (ONIGENC_CASE_MODIFIED&flags) return str;
return Qnil;
}