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 + + * 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 * 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;