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

ruby-changes:68185

From: Nobuyoshi <ko1@a...>
Date: Fri, 1 Oct 2021 20:29:06 +0900 (JST)
Subject: [ruby-changes:68185] 3e46117d3f (master): Associate the encoding to the found path

https://git.ruby-lang.org/ruby.git/commit/?id=3e46117d3f

From 3e46117d3fb12d1428c97daf9e8d6bce36b90240 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Wed, 29 Sep 2021 20:01:14 +0900
Subject: Associate the encoding to the found path

---
 file.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/file.c b/file.c
index 98b9d50446..626043816f 100644
--- a/file.c
+++ b/file.c
@@ -6369,6 +6369,10 @@ is_explicit_relative(const char *path) https://github.com/ruby/ruby/blob/trunk/file.c#L6369
 static VALUE
 copy_path_class(VALUE path, VALUE orig)
 {
+    int encidx = rb_enc_get_index(orig);
+    if (encidx == ENCINDEX_ASCII || encidx == ENCINDEX_US_ASCII)
+        encidx = rb_filesystem_encindex();
+    rb_enc_associate_index(path, encidx);
     str_shrink(path);
     RBASIC_SET_CLASS(path, rb_obj_class(orig));
     OBJ_FREEZE(path);
-- 
cgit v1.2.1


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

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