summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 04:02:01 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-07-26 04:02:01 +0000
commitf375a8b40ec65991df54d84856851c2149f11211 (patch)
tree1aaf396d2a6a2c400705638de616cec5184bd2ed
parent320a0dd218e2aecd8510b5a8f88ffb93643a5c48 (diff)
file.c: use rb_str_conv_enc
* file.c (rb_str_encode_ospath): simplify using rb_str_conv_enc(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42181 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--file.c15
2 files changed, 9 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index ad6582ac36..e5285235c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
-Fri Jul 26 13:01:04 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+Fri Jul 26 13:01:57 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * file.c (rb_str_encode_ospath): simplify using rb_str_conv_enc().
* win32/file.c (fix_string_encoding): simplify with rb_str_conv_enc().
diff --git a/file.c b/file.c
index b3b6f2a2bb..ceed58d774 100644
--- a/file.c
+++ b/file.c
@@ -229,15 +229,12 @@ rb_str_encode_ospath(VALUE path)
{
#ifdef _WIN32
rb_encoding *enc = rb_enc_get(path);
- if (enc != rb_ascii8bit_encoding()) {
- rb_encoding *utf8 = rb_utf8_encoding();
- if (enc != utf8)
- path = rb_str_encode(path, rb_enc_from_encoding(utf8), 0, Qnil);
- }
- else if (RSTRING_LEN(path) > 0) {
- path = rb_str_dup(path);
- rb_enc_associate(path, rb_filesystem_encoding());
- path = rb_str_encode(path, rb_enc_from_encoding(rb_utf8_encoding()), 0, Qnil);
+ rb_encoding *utf8 = rb_utf8_encoding();
+ if (enc == rb_ascii8bit_encoding()) {
+ enc = rb_filesystem_encoding();
+ }
+ if (enc != utf8) {
+ path = rb_str_conv_enc(path, enc, utf8);
}
#endif
return path;