ruby-changes:3739
From: ko1@a...
Date: Fri, 25 Jan 2008 15:12:56 +0900 (JST)
Subject: [ruby-changes:3739] nobu - Ruby:r15228 (trunk): * ruby.c (process_options): not set encoding of -e option from -E
nobu 2008-01-25 15:12:44 +0900 (Fri, 25 Jan 2008) New Revision: 15228 Modified files: trunk/ChangeLog trunk/ruby.c Log: * ruby.c (process_options): not set encoding of -e option from -E option if they are not compatible. http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=15228&r2=15227&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15228&r2=15227&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15227) +++ ChangeLog (revision 15228) @@ -1,3 +1,8 @@ +Fri Jan 25 15:12:42 2008 Nobuyoshi Nakada <nobu@r...> + + * ruby.c (process_options): not set encoding of -e option from -E + option if they are not compatible. + Fri Jan 25 13:15:23 2008 NAKAMURA Usaku <usa@r...> * ruby.c (proc_options, process_options, load_file): shouldn't effect Index: ruby.c =================================================================== --- ruby.c (revision 15227) +++ ruby.c (revision 15228) @@ -1000,14 +1000,30 @@ enc = rb_enc_from_index(opt->ext.enc.index); } else { - enc = rb_locale_encoding(); + enc = 0; } if (opt->e_script) { - rb_enc_associate(opt->e_script, enc); + rb_encoding *eenc = rb_locale_encoding(); + if (!enc) { + enc = eenc; + } + else if (!rb_enc_asciicompat(enc)) { + rb_warning("%s is not ASCII compatible, ignored for -e", + rb_enc_name(enc)); + } + else if (eenc != enc && + (rb_enc_str_coderange(opt->e_script) != ENC_CODERANGE_7BIT)) { + rb_warning("-e conatains non ASCII string, encoding %s is not used", + rb_enc_name(enc)); + } + rb_enc_associate(opt->e_script, eenc); require_libraries(); tree = rb_parser_compile_string(parser, opt->script, opt->e_script, 1); } else { + if (!enc) { + enc = rb_locale_encoding(); + } if (opt->script[0] == '-' && !opt->script[1]) { forbid_setid("program input from stdin"); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/