[前][次][番号順一覧][スレッド一覧]

ruby-changes:30129

From: nobu <ko1@a...>
Date: Fri, 26 Jul 2013 13:02:12 +0900 (JST)
Subject: [ruby-changes:30129] nobu:r42181 (trunk): file.c: use rb_str_conv_enc

nobu	2013-07-26 13:02:01 +0900 (Fri, 26 Jul 2013)

  New Revision: 42181

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42181

  Log:
    file.c: use rb_str_conv_enc
    
    * file.c (rb_str_encode_ospath): simplify using rb_str_conv_enc().

  Modified files:
    trunk/ChangeLog
    trunk/file.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42180)
+++ ChangeLog	(revision 42181)
@@ -1,4 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
-Fri Jul 26 13:01:04 2013  Nobuyoshi Nakada  <nobu@r...>
+Fri Jul 26 13:01:57 2013  Nobuyoshi Nakada  <nobu@r...>
+
+	* file.c (rb_str_encode_ospath): simplify using rb_str_conv_enc().
 
 	* win32/file.c (fix_string_encoding): simplify with rb_str_conv_enc().
 
Index: file.c
===================================================================
--- file.c	(revision 42180)
+++ file.c	(revision 42181)
@@ -229,15 +229,12 @@ rb_str_encode_ospath(VALUE path) https://github.com/ruby/ruby/blob/trunk/file.c#L229
 {
 #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);
+    rb_encoding *utf8 = rb_utf8_encoding();
+    if (enc == rb_ascii8bit_encoding()) {
+	enc = rb_filesystem_encoding();
     }
-    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);
+    if (enc != utf8) {
+	path = rb_str_conv_enc(path, enc, utf8);
     }
 #endif
     return path;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]