ruby-changes:3731
From: ko1@a...
Date: Thu, 24 Jan 2008 22:11:32 +0900 (JST)
Subject: [ruby-changes:3731] akr - Ruby:r15220 (trunk): * parse.y (reg_fragment_setenc_gen): associate ASCII-8BIT only if
akr 2008-01-24 22:11:00 +0900 (Thu, 24 Jan 2008) New Revision: 15220 Modified files: trunk/ChangeLog trunk/parse.y Log: * parse.y (reg_fragment_setenc_gen): associate ASCII-8BIT only if str has only ASCII characters. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/parse.y?r1=15220&r2=15219&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15220&r2=15219&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15219) +++ ChangeLog (revision 15220) @@ -1,3 +1,8 @@ +Thu Jan 24 21:46:24 2008 Tanaka Akira <akr@f...> + + * parse.y (reg_fragment_setenc_gen): associate ASCII-8BIT only if + str has only ASCII characters. + Thu Jan 24 20:46:17 2008 NAKAMURA Usaku <usa@r...> * test/ruby/test_m17n.rb: follow to the following changes. Index: parse.y =================================================================== --- parse.y (revision 15219) +++ parse.y (revision 15220) @@ -8475,17 +8475,26 @@ if (c) { int opt, idx; rb_char_to_option_kcode(c, &opt, &idx); - if (idx != ENCODING_GET(str) && !ENCODING_IS_ASCII8BIT(str) && + if (idx != ENCODING_GET(str) && rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) { - compile_error(PARSER_ARG - "regexp encoding option '%c' differs from source encoding '%s'", - c, rb_enc_name(rb_enc_get(str))); + goto error; } ENCODING_SET(str, idx); } else if (RE_OPTION_ENCODING_NONE(options)) { + if (!ENCODING_IS_ASCII8BIT(str) && + rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) { + c = 'n'; + goto error; + } rb_enc_associate(str, rb_ascii8bit_encoding()); } + return; + +error: + compile_error(PARSER_ARG + "regexp encoding option '%c' differs from source encoding '%s'", + c, rb_enc_name(rb_enc_get(str))); } static void -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/