diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-28 05:21:48 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-28 05:21:48 +0000 |
commit | 82a44eff1c31c15be40141a28b1581b7c4fc2576 (patch) | |
tree | 199313fefd144f10ad9ef4b7140f35fdf629eb39 /parse.y | |
parent | d3ab29075a285d1b2b78b327fb670cbdb1910977 (diff) | |
download | ruby-82a44eff1c31c15be40141a28b1581b7c4fc2576.tar.gz ruby-82a44eff1c31c15be40141a28b1581b7c4fc2576.tar.xz ruby-82a44eff1c31c15be40141a28b1581b7c4fc2576.zip |
* parse.y (parser_prepare): set parser encode too when BOM exists.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@13292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -5490,6 +5490,13 @@ lvar_defined_gen(struct parser_params *parser, ID id) } /* emacsen -*- hack */ +static void +parser_set_encode(struct parser_params *parser, const char *name) +{ + rb_set_kcode(name); + parser->enc = rb_enc_find(name); +} + #ifndef RIPPER typedef void (*rb_pragma_setter_t)(struct parser_params *parser, const char *name, const char *val); @@ -5498,8 +5505,7 @@ pragma_encoding(struct parser_params *parser, const char *name, const char *val) { if (parser && parser->line_count != (parser->has_shebang ? 2 : 1)) return; - rb_set_kcode(val); - parser->enc = rb_enc_find(val); + parser_set_encode(parser, val); } struct pragma { @@ -5641,7 +5647,7 @@ parser_prepare(struct parser_params *parser) if (lex_pend - lex_p >= 2 && (unsigned char)lex_p[0] == 0xbb && (unsigned char)lex_p[1] == 0xbf) { - rb_set_kcode("UTF-8"); + parser_set_encode(parser, "UTF-8"); lex_p += 2; return; } |