From 37aa93141e7154e716228969de270086d011d48b Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 16 Oct 2007 05:48:40 +0000 Subject: * parse.y (parser_regx_options): check if regexp encoding option matches to current encoding. * re.c (char_to_option, rb_char_to_option_kcode): 'n' is not kcode option now. * re.c (rb_reg_to_s, rb_reg_error_desc): copy encoding rather than append as an option. * re.c (make_regexp, rb_reg_prepare_re): use encoding of Regexp and String instead of kcode. * re.c (rb_reg_initialize): set fixed option if none is set. * re.c (rb_reg_regcomp): ditto. * re.c (rb_reg_equal): check if encodings are equal. * re.c (rb_reg_initialize_m): encoding option is obsolete. * re.c (rb_kcode, rb_get_kcode, rb_set_kcode): removed. * re.c (Init_Regexp): removed Regexp#kcode method. * ruby.c (proc_options): allow long encoding name. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ruby.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'ruby.c') diff --git a/ruby.c b/ruby.c index f8e812be7..c39731385 100644 --- a/ruby.c +++ b/ruby.c @@ -733,9 +733,7 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) case 'K': if (*++s) { rb_encoding *enc = 0; -#if 0 if ((opt->enc_index = rb_enc_find_index(s)) >= 0) break; -#endif switch (*s) { case 'E': case 'e': enc = ONIG_ENCODING_EUC_JP; @@ -749,10 +747,11 @@ proc_options(int argc, char **argv, struct cmdline_options *opt) case 'N': case 'n': case 'A': case 'a': enc = ONIG_ENCODING_ASCII; break; - default: + } + if (!enc) { rb_raise(rb_eRuntimeError, "unknown encoding name - %s", s); } - opt->enc_index = rb_enc_to_index(enc); + opt->enc_index = rb_enc_find_index(rb_enc_name(enc)); s++; } goto reswitch; -- cgit