ruby-changes:8524
From: yugui <ko1@a...>
Date: Thu, 30 Oct 2008 21:10:56 +0900 (JST)
Subject: [ruby-changes:8524] Ruby:r20059 (ruby_1_9_1): merges r20046 from trunk into ruby_1_9_1.
yugui 2008-10-30 21:09:36 +0900 (Thu, 30 Oct 2008) New Revision: 20059 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=20059 Log: merges r20046 from trunk into ruby_1_9_1. * string.c (rb_str_check_dummy_enc): new function to check dummy encoding. * string.c (rb_str_upcase_bang): case conversion functions should not be applicable to strings in dummy encoding. [ruby-dev:36985] Modified files: branches/ruby_1_9_1/ChangeLog branches/ruby_1_9_1/string.c Index: ruby_1_9_1/ChangeLog =================================================================== --- ruby_1_9_1/ChangeLog (revision 20058) +++ ruby_1_9_1/ChangeLog (revision 20059) @@ -23,6 +23,14 @@ * test/ruby/test_array.rb (test_permutation): add a test that replaces array during permutation. +Wed Oct 29 23:31:34 2008 Yukihiro Matsumoto <matz@r...> + + * string.c (rb_str_check_dummy_enc): new function to check dummy + encoding. + + * string.c (rb_str_upcase_bang): case conversion functions should + not be applicable to strings in dummy encoding. [ruby-dev:36985] + Wed Oct 29 23:57:29 2008 Yusuke Endoh <mame@t...> * array.c (rb_ary_sort_bang): replacing array during sort broke Index: ruby_1_9_1/string.c =================================================================== --- ruby_1_9_1/string.c (revision 20058) +++ ruby_1_9_1/string.c (revision 20059) @@ -4220,6 +4220,15 @@ } +static void +rb_str_check_dummy_enc(rb_encoding *enc) +{ + if (rb_enc_dummy_p(enc)) { + rb_raise(rb_eEncCompatError, "incompatible encoding with this operation: %s", + rb_enc_name(enc)); + } +} + /* * call-seq: * str.upcase! => str or nil @@ -4238,6 +4247,7 @@ str_modify_keep_cr(str); enc = STR_ENC_GET(str); + rb_str_check_dummy_enc(enc); s = RSTRING_PTR(str); send = RSTRING_END(str); if (single_byte_optimizable(str)) { while (s < send) { @@ -4319,6 +4329,7 @@ str_modify_keep_cr(str); enc = STR_ENC_GET(str); + rb_str_check_dummy_enc(enc); s = RSTRING_PTR(str); send = RSTRING_END(str); if (single_byte_optimizable(str)) { while (s < send) { @@ -4406,6 +4417,7 @@ str_modify_keep_cr(str); enc = STR_ENC_GET(str); + rb_str_check_dummy_enc(enc); if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil; s = RSTRING_PTR(str); send = RSTRING_END(str); @@ -4469,6 +4481,7 @@ str_modify_keep_cr(str); enc = STR_ENC_GET(str); + rb_str_check_dummy_enc(enc); s = RSTRING_PTR(str); send = RSTRING_END(str); while (s < send) { unsigned int c = rb_enc_codepoint(s, send, enc); @@ -5996,9 +6009,7 @@ char *s, *t, *e; enc = STR_ENC_GET(str); - if (rb_enc_dummy_p(enc)) { - rb_raise(rb_eEncCompatError, "incompatible encoding with this operation: %s", rb_enc_name(enc)); - } + rb_str_check_dummy_enc(enc); s = RSTRING_PTR(str); if (!s || RSTRING_LEN(str) == 0) return Qnil; t = e = RSTRING_END(str); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/