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 | 38b1f98a72129983956d26162df6825046ccf5db (patch) | |
tree | 199313fefd144f10ad9ef4b7140f35fdf629eb39 | |
parent | 88f13dfc7276ac7fbc4f010de9848ed8652c369c (diff) | |
download | ruby-38b1f98a72129983956d26162df6825046ccf5db.tar.gz |
* parse.y (parser_prepare): set parser encode too when BOM exists.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13292 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | parse.y | 12 |
2 files changed, 13 insertions, 3 deletions
@@ -1,3 +1,7 @@ +Tue Aug 28 14:21:46 2007 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * parse.y (parser_prepare): set parser encode too when BOM exists. + Tue Aug 28 00:51:22 2007 Koichi Sasada <ko1@atdot.net> * thread.c: fix Mutex to be interruptable lock. @@ -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; } |