ruby-changes:9606
From: naruse <ko1@a...>
Date: Mon, 29 Dec 2008 11:01:20 +0900 (JST)
Subject: [ruby-changes:9606] Ruby:r21146 (trunk): * file.c (rb_get_path): move encoding conversion of file path
naruse 2008-12-29 11:01:02 +0900 (Mon, 29 Dec 2008) New Revision: 21146 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=21146 Log: * file.c (rb_get_path): move encoding conversion of file path from rb_scan_open_args. * io.c (rb_scan_open_args): ditto. Modified files: trunk/ChangeLog trunk/file.c trunk/io.c Index: ChangeLog =================================================================== --- ChangeLog (revision 21145) +++ ChangeLog (revision 21146) @@ -1,3 +1,10 @@ +Mon Dec 29 10:58:54 2008 NARUSE, Yui <naruse@r...> + + * file.c (rb_get_path): move encoding conversion of file path + from rb_scan_open_args. + + * io.c (rb_scan_open_args): ditto. + Mon Dec 29 07:15:16 2008 Yukihiro Matsumoto <matz@r...> * cont.c: small RDoc fix mentioned from <radek.bulat at gmail.com> Index: io.c =================================================================== --- io.c (revision 21145) +++ io.c (revision 21146) @@ -4885,26 +4885,7 @@ opt = pop_last_hash(&argc, argv); rb_scan_args(argc, argv, "12", &fname, &vmode, &vperm); FilePathValue(fname); -#if defined _WIN32 || defined __APPLE__ - { - static rb_encoding *fs_encoding; - rb_encoding *fname_encoding = rb_enc_get(fname); - if (!fs_encoding) - fs_encoding = rb_filesystem_encoding(); - if (rb_usascii_encoding() != fname_encoding - && rb_ascii8bit_encoding() != fname_encoding -#if defined __APPLE__ - && rb_utf8_encoding() != fname_encoding -#endif - && fs_encoding != fname_encoding) { - static VALUE fs_enc; - if (!fs_enc) - fs_enc = rb_enc_from_encoding(fs_encoding); - fname = rb_str_encode(fname, fs_enc, 0, Qnil); - } - } -#endif - + rb_io_extract_modeenc(&vmode, &vperm, opt, &oflags, &fmode, convconfig_p); perm = NIL_P(vperm) ? 0666 : NUM2UINT(vperm); Index: file.c =================================================================== --- file.c (revision 21145) +++ file.c (revision 21146) @@ -107,7 +107,6 @@ tmp = rb_check_string_type(obj); if (!NIL_P(tmp)) goto exit; - CONST_ID(to_path, "to_path"); if (rb_respond_to(obj, to_path)) { tmp = rb_funcall(obj, to_path, 0, 0); @@ -120,6 +119,27 @@ if (check && obj != tmp) { rb_check_safe_obj(tmp); } + +#if defined _WIN32 || defined __APPLE__ + { + static rb_encoding *fs_encoding; + rb_encoding *fname_encoding = rb_enc_get(tmp); + if (!fs_encoding) + fs_encoding = rb_filesystem_encoding(); + if (rb_usascii_encoding() != fname_encoding + && rb_ascii8bit_encoding() != fname_encoding +#if defined __APPLE__ + && rb_utf8_encoding() != fname_encoding +#endif + && fs_encoding != fname_encoding) { + static VALUE fs_enc; + if (!fs_enc) + fs_enc = rb_enc_from_encoding(fs_encoding); + tmp = rb_str_encode(tmp, fs_enc, 0, Qnil); + } + } +#endif + return rb_str_new4(tmp); } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/