diff options
| author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-22 01:43:16 +0000 |
|---|---|---|
| committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-12-22 01:43:16 +0000 |
| commit | ef6481f88233b791ff12dff7cf33aa30d55b2d90 (patch) | |
| tree | 2ea3b6805afe2c16e917f54f123c152b5ae9f68e /parse.y | |
| parent | 2b227f53400de1a26e649c19aeec5ac342608151 (diff) | |
| download | ruby-ef6481f88233b791ff12dff7cf33aa30d55b2d90.tar.gz ruby-ef6481f88233b791ff12dff7cf33aa30d55b2d90.tar.xz ruby-ef6481f88233b791ff12dff7cf33aa30d55b2d90.zip | |
* parse.y (gettable_gen): the encoding of __FILE__ should be
rb_filesystem_encoding(). [ruby-list:45733]
* parse.y (gettable_gen): __FILE__ should be ASCII-8BIT when
filesystem encoding is US-ASCII and __FILE__ contains non 7bit
characters.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@20905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
| -rw-r--r-- | parse.y | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -7923,7 +7923,13 @@ gettable_gen(struct parser_params *parser, ID id) return NEW_FALSE(); } else if (id == keyword__FILE__) { - return NEW_STR(STR_NEW2(ruby_sourcefile)); + VALUE str = rb_external_str_new_with_enc(ruby_sourcefile, strlen(ruby_sourcefile), + rb_filesystem_encoding()); + if (rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT && + ENCODING_GET(str) == rb_usascii_encindex()) { + rb_enc_associate(str, rb_ascii8bit_encoding()); + } + return NEW_STR(str); } else if (id == keyword__LINE__) { return NEW_LIT(INT2FIX(ruby_sourceline)); |
