Bug #8753
closed__FILE__.encoding is wrong
Description
=begin
A bug introduced by change r42183
(({FILE}))'s encoding is wrong.
In file ((%ruby.c%)) and function (({load_file_internal})) type (({VALUE})) convert to (({char*})), and lost the encoding info
const char orig_fname = StringValueCStr(argp->fname);
and call the (({rb_parser_compile_file})) with the (({char})) variable
tree = rb_parser_compile_file(parser, orig_fname, f, line_start);
and in file ((%parse.y%)) and function (({rb_parser_compile_file})), type (({char*})) convert to (({VALUE})) using the ((filesystem encoding)).
return rb_parser_compile_file_path(vparser, rb_filesystem_str_new_cstr(f), file, start);
But the beginning parameter (((({argp->fname}))'s encoding)) not the ((filesystem encoding)).
What's the principle of ruby's encoding?Why so many (({VALUE})) to (({char*})) converting?Is the (({char*})) has the regular encoding?
I think we should convert the encoding at the boundary and every thing should encoding to internal encoding in the internal, am I right?
=end
Updated by ko1 (Koichi Sasada) over 11 years ago
- Assignee set to naruse (Yui NARUSE)
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Description updated (diff)
Updated by nobu (Nobuyoshi Nakada) over 11 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r42468.
贾, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
ruby.c: use String path version parser functions
- ruby.c (load_file_internal): use rb_parser_compile_string_path and
rb_parser_compile_file_path, String path name versions. [Bug #8753]