* 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]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2007-12-28 10:41:52 +00:00
parent b1b238da2c
commit eb1014e4ae
4 changed files with 20 additions and 35 deletions

View File

@ -1,3 +1,16 @@
Fri Dec 28 19:39:34 2007 NAKAMURA Usaku <usa@ruby-lang.org>
* 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@ruby-lang.org>
* ext/readline/readline.c (readline_readline, readline_s_set_input):

View File

@ -857,8 +857,12 @@ rb_encoding *
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();

View File

@ -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 @@ readline_readline(int argc, VALUE *argv, VALUE self)
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 @@ readline_s_set_input(VALUE self, VALUE input)
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 @@ Init_readline()
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);

19
ruby.c
View File

@ -135,23 +135,6 @@ usage(const char *name)
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 @@ process_options(VALUE arg)
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));