1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* parse.y (parser_initialize): explicitly call rb_ascii8bit_encoding().

* parse.y (parser_prepare): lex_input may not be have encoding (e.g. IO).

* parse.y (rb_parser_compile_string): set encoding from input string. 

* encoding.c (rb_enc_find_index): use ASCII-8BIT if loading known
  encoding failed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15099 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2008-01-18 00:23:18 +00:00
parent f7929ed206
commit 231ab57f6f
3 changed files with 19 additions and 2 deletions

View file

@ -1,3 +1,14 @@
Fri Jan 18 09:22:07 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (parser_initialize): explicitly call rb_ascii8bit_encoding().
* parse.y (parser_prepare): lex_input may not be have encoding (e.g. IO).
* parse.y (rb_parser_compile_string): set encoding from input string.
* encoding.c (rb_enc_find_index): use ASCII-8BIT if loading known
encoding failed.
Fri Jan 18 07:06:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org> Fri Jan 18 07:06:25 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
* io.c (Init_IO): stdin/stdout may not be duplex. * io.c (Init_IO): stdin/stdout may not be duplex.

View file

@ -498,6 +498,12 @@ rb_enc_find_index(const char *name)
} }
else { else {
i = load_encoding(name); i = load_encoding(name);
enc = rb_enc_from_index(i);
if (!enc->precise_mbc_enc_len) {
rb_warn("failed to load encoding (%s); use ASCII-8BIT instead",
name);
return 0;
}
} }
} }
return i; return i;

View file

@ -4764,6 +4764,7 @@ rb_parser_compile_string(volatile VALUE vparser, const char *f, VALUE s, int lin
lex_gets = lex_get_str; lex_gets = lex_get_str;
lex_gets_ptr = 0; lex_gets_ptr = 0;
lex_input = s; lex_input = s;
parser->enc = rb_enc_get(s);
lex_pbeg = lex_p = lex_pend = 0; lex_pbeg = lex_p = lex_pend = 0;
compile_for_eval = rb_parse_in_eval(); compile_for_eval = rb_parse_in_eval();
@ -5956,7 +5957,6 @@ parser_prepare(struct parser_params *parser)
return; return;
} }
pushback(c); pushback(c);
parser->enc = rb_enc_get(lex_input);
} }
#define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG) #define IS_ARG() (lex_state == EXPR_ARG || lex_state == EXPR_CMDARG)
@ -9192,7 +9192,7 @@ parser_initialize(struct parser_params *parser)
#ifdef YYMALLOC #ifdef YYMALLOC
parser->heap = NULL; parser->heap = NULL;
#endif #endif
parser->enc = rb_enc_from_index(0); parser->enc = rb_ascii8bit_encoding();
} }
extern void rb_mark_source_filename(char *); extern void rb_mark_source_filename(char *);