ruby-changes:3277
From: ko1@a...
Date: 28 Dec 2007 19:42:18 +0900
Subject: [ruby-changes:3277] usa - Ruby:r14770 (trunk): * encoding.c (rb_locale_encoding): should check return value from
usa 2007-12-28 19:41:52 +0900 (Fri, 28 Dec 2007) New Revision: 14770 Modified files: trunk/ChangeLog trunk/encoding.c trunk/ext/readline/readline.c trunk/ruby.c Log: * encoding.c (rb_locale_encoding): should check return value from rb_locale_charmap(). * ruby.c (locale_encoding): removed. * ruby.c (process_options): use rb_locale_encoding() instead of locale_encoding(). * ext/readline/readline.c (readline_readline): use locale encoding instead of input IO's encoding. [ruby-dev:32872] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ruby.c?r1=14770&r2=14769 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14770&r2=14769 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/readline/readline.c?r1=14770&r2=14769 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/encoding.c?r1=14770&r2=14769 Index: encoding.c =================================================================== --- encoding.c (revision 14769) +++ encoding.c (revision 14770) @@ -857,8 +857,12 @@ rb_locale_encoding(void) { VALUE charmap = rb_locale_charmap(rb_cEncoding); - int idx = rb_enc_find_index(StringValueCStr(charmap)); + int idx; + if (NIL_P(charmap)) + return rb_ascii8bit_encoding(); + + idx = rb_enc_find_index(StringValueCStr(charmap)); if (idx < 0) return rb_ascii8bit_encoding(); Index: ChangeLog =================================================================== --- ChangeLog (revision 14769) +++ ChangeLog (revision 14770) @@ -1,3 +1,16 @@ +Fri Dec 28 19:39:34 2007 NAKAMURA Usaku <usa@r...> + + * encoding.c (rb_locale_encoding): should check return value from + rb_locale_charmap(). + + * ruby.c (locale_encoding): removed. + + * ruby.c (process_options): use rb_locale_encoding() instead of + locale_encoding(). + + * ext/readline/readline.c (readline_readline): use locale encoding + instead of input IO's encoding. [ruby-dev:32872] + Fri Dec 28 19:29:07 2007 NAKAMURA Usaku <usa@r...> * ext/readline/readline.c (readline_readline, readline_s_set_input): Index: ext/readline/readline.c =================================================================== --- ext/readline/readline.c (revision 14769) +++ ext/readline/readline.c (revision 14770) @@ -29,7 +29,6 @@ #endif static VALUE mReadline; -static VALUE id_var_input; #define TOLOWER(c) (isupper(c) ? tolower(c) : c) @@ -95,18 +94,8 @@ add_history(buff); } if (buff) { - rb_encoding* enc; - VALUE input = rb_ivar_get(mReadline, id_var_input); - rb_io_t *ifp; - GetOpenFile(input, ifp); - if (ifp->enc) - enc = ifp->enc; - else if (ifp->mode & FMODE_BINMODE) - enc = rb_ascii8bit_encoding(); - else - enc = rb_default_external_encoding(); result = rb_tainted_str_new2(buff); - rb_enc_associate(result, enc); + rb_enc_associate(result, rb_locale_encoding()); } else result = Qnil; @@ -123,7 +112,6 @@ Check_Type(input, T_FILE); GetOpenFile(input, ifp); rl_instream = rb_io_stdio_file(ifp); - rb_ivar_set(mReadline, id_var_input, input); return input; } @@ -769,9 +757,6 @@ rb_define_singleton_method(mReadline, "filename_quote_characters", readline_s_get_filename_quote_characters, 0); - id_var_input = rb_intern("#input"); - rb_ivar_set(mReadline, id_var_input, rb_stdin); - history = rb_obj_alloc(rb_cObject); rb_extend_object(history, rb_mEnumerable); rb_define_singleton_method(history,"to_s", hist_to_s, 0); Index: ruby.c =================================================================== --- ruby.c (revision 14769) +++ ruby.c (revision 14770) @@ -135,23 +135,6 @@ printf(" %s\n", *p++); } -static rb_encoding * -locale_encoding(void) -{ - VALUE codeset = rb_locale_charmap(Qnil); - char *name; - int idx; - - if (codeset == Qnil) - return rb_ascii8bit_encoding(); - - name = StringValueCStr(codeset); - idx = rb_enc_find_index(name); - if (idx < 0) - return rb_ascii8bit_encoding(); - return rb_enc_from_index(idx); -} - extern VALUE rb_load_path; #ifndef CharNext /* defined as CharNext[AW] on Windows. */ @@ -1025,7 +1008,7 @@ enc = rb_enc_from_index(opt->enc_index); } else { - enc = locale_encoding(); + enc = rb_locale_encoding(); } rb_enc_set_default_external(rb_enc_from_encoding(enc)); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml