summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-29 02:01:02 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-12-29 02:01:02 +0000
commit1ebed6c6140a1c3fe0e6b157910cc1d2d1bd49bc (patch)
treef6ba6e1f4786c0e790a7c3ac0afa091a5d4d33a8
parent1487d9743b6e5082676c194d023b6dabaa53085c (diff)
* file.c (rb_get_path): move encoding conversion of file path
from rb_scan_open_args. * io.c (rb_scan_open_args): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21146 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog7
-rw-r--r--file.c22
-rw-r--r--io.c21
3 files changed, 29 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index ba3908fd84..1eb49c5d02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+Mon Dec 29 10:58:54 2008 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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@ruby-lang.org>
* cont.c: small RDoc fix mentioned from <radek.bulat at gmail.com>
diff --git a/file.c b/file.c
index aa814a5c76..3ca63595ff 100644
--- a/file.c
+++ b/file.c
@@ -107,7 +107,6 @@ rb_get_path_check(VALUE obj, int check)
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 @@ rb_get_path_check(VALUE obj, int check)
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);
}
diff --git a/io.c b/io.c
index ce0c35048b..472957f598 100644
--- a/io.c
+++ b/io.c
@@ -4885,26 +4885,7 @@ rb_scan_open_args(int argc, VALUE *argv,
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);