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

ruby-changes:16372

From: usa <ko1@a...>
Date: Thu, 17 Jun 2010 18:59:30 +0900 (JST)
Subject: [ruby-changes:16372] Ruby:r28350 (ruby_1_9_2): merge from trunk (r28349)

usa	2010-06-17 18:55:46 +0900 (Thu, 17 Jun 2010)

  New Revision: 28350

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

  Log:
    merge from trunk (r28349)
    
    * file.c (rb_str_encode_ospath): when the encoding of the parameter
      is ASCII-8BIT, should recognize as filesystem encoding, and convert
      to UTF-8 on Windows.
    
    * file.c (realpath_rec): should convert to ospath encoding before
      calling lstat().
    
    * file.c (rb_realpath_internal): resolved string should take over
      the encoding of base string.
    
    * transcode.c (rb_str_encode): should return new string always.
      fixed #3444.

  Modified files:
    branches/ruby_1_9_2/ChangeLog
    branches/ruby_1_9_2/file.c
    branches/ruby_1_9_2/transcode.c

Index: ruby_1_9_2/ChangeLog
===================================================================
--- ruby_1_9_2/ChangeLog	(revision 28349)
+++ ruby_1_9_2/ChangeLog	(revision 28350)
@@ -1,3 +1,18 @@
+Thu Jun 17 18:55:01 2010  NAKAMURA Usaku  <usa@r...>
+
+	* file.c (rb_str_encode_ospath): when the encoding of the parameter
+	  is ASCII-8BIT, should recognize as filesystem encoding, and convert
+	  to UTF-8 on Windows.
+
+	* file.c (realpath_rec): should convert to ospath encoding before
+	  calling lstat().
+
+	* file.c (rb_realpath_internal): resolved string should take over
+	  the encoding of base string.
+
+	* transcode.c (rb_str_encode): should return new string always.
+	  fixed #3444.
+
 Thu Jun 17 18:22:00 2010  Kenta Murata  <mrkn@m...>
 
 	* ext/digest/sha2/lib/sha2.rb: revert r28347.  It's my mistake.
Index: ruby_1_9_2/file.c
===================================================================
--- ruby_1_9_2/file.c	(revision 28349)
+++ ruby_1_9_2/file.c	(revision 28350)
@@ -191,8 +191,11 @@
 	if (enc != utf8)
 	    path = rb_str_encode(path, rb_enc_from_encoding(utf8), 0, Qnil);
     }
-    else if (RSTRING_LEN(path) > 0)
-	path = rb_str_encode(path, rb_enc_from_encoding(rb_filesystem_encoding()), 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);
+    }
 #endif
     return path;
 }
@@ -3223,7 +3226,8 @@
             else {
                 struct stat sbuf;
                 int ret;
-                ret = lstat(RSTRING_PTR(testpath), &sbuf);
+                VALUE testpath2 = rb_str_encode_ospath(testpath);
+                ret = lstat(RSTRING_PTR(testpath2), &sbuf);
                 if (ret == -1) {
                     if (errno == ENOENT) {
                         if (strict || !last || *unresolved_firstsep)
@@ -3292,7 +3296,8 @@
     ptr = RSTRING_PTR(unresolved_path);
     path_names = skiproot(ptr);
     if (ptr != path_names) {
-        resolved = rb_str_new(ptr, path_names - ptr);
+        resolved = rb_enc_str_new(ptr, path_names - ptr,
+				  rb_enc_get(unresolved_path));
         goto root_found;
     }
 
@@ -3300,7 +3305,8 @@
         ptr = RSTRING_PTR(basedir);
         basedir_names = skiproot(ptr);
         if (ptr != basedir_names) {
-            resolved = rb_str_new(ptr, basedir_names - ptr);
+            resolved = rb_enc_str_new(ptr, basedir_names - ptr,
+				      rb_enc_get(basedir));
             goto root_found;
         }
     }
@@ -3308,7 +3314,7 @@
     curdir = rb_dir_getwd();
     ptr = RSTRING_PTR(curdir);
     curdir_names = skiproot(ptr);
-    resolved = rb_str_new(ptr, curdir_names - ptr);
+    resolved = rb_enc_str_new(ptr, curdir_names - ptr, rb_enc_get(curdir));
 
   root_found:
     prefixptr = RSTRING_PTR(resolved);
Index: ruby_1_9_2/transcode.c
===================================================================
--- ruby_1_9_2/transcode.c	(revision 28349)
+++ ruby_1_9_2/transcode.c	(revision 28350)
@@ -2805,7 +2805,12 @@
     int encidx = str_transcode0(argc, argv, &newstr, ecflags, ecopts);
 
     if (encidx < 0) return rb_str_dup(str);
-    RBASIC(newstr)->klass = rb_obj_class(str);
+    if (newstr == str) {
+	newstr = rb_str_dup(str);
+    }
+    else {
+	RBASIC(newstr)->klass = rb_obj_class(str);
+    }
     return str_encode_associate(newstr, encidx);
 }
 

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

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