Skip to content

Commit 2b713dc

Browse files
committed
merge revision(s) d33e3d4: [Backport #20704]
[Bug #20704] Win32: Fix chdir to non-ASCII path On Windows, `chdir` in compilers' runtime libraries uses the active code page, but command line arguments in ruby are always UTF-8, since commit:33ea2646b98adb49ae2e1781753bf22d33729ac0.
1 parent e7c939a commit 2b713dc

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

ruby.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,8 @@ translit_char_bin(char *p, int from, int to)
571571
#endif
572572

573573
#ifdef _WIN32
574+
# undef chdir
575+
# define chdir rb_w32_uchdir
574576
# define UTF8_PATH 1
575577
#endif
576578

test/ruby/test_rubyoptions.rb

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def test_disable
227227

228228
def test_kanji
229229
assert_in_out_err(%w(-KU), "p '\u3042'") do |r, e|
230-
assert_equal("\"\u3042\"", r.join.force_encoding(Encoding::UTF_8))
230+
assert_equal("\"\u3042\"", r.join('').force_encoding(Encoding::UTF_8))
231231
end
232232
line = '-eputs"\xc2\xa1".encoding'
233233
env = {'RUBYOPT' => nil}
@@ -353,9 +353,20 @@ def test_chdir
353353

354354
d = Dir.tmpdir
355355
assert_in_out_err(["-C", d, "-e", "puts Dir.pwd"]) do |r, e|
356-
assert_file.identical?(r.join, d)
356+
assert_file.identical?(r.join(''), d)
357357
assert_equal([], e)
358358
end
359+
360+
Dir.mktmpdir(d) do |base|
361+
# "test" in Japanese and N'Ko
362+
test = base + "/\u{30c6 30b9 30c8}_\u{7e1 7ca 7dd 7cc 7df 7cd 7eb}"
363+
Dir.mkdir(test)
364+
assert_in_out_err(["-C", base, "-C", File.basename(test), "-e", "puts Dir.pwd"]) do |r, e|
365+
assert_file.identical?(r.join(''), test)
366+
assert_equal([], e)
367+
end
368+
Dir.rmdir(test)
369+
end
359370
end
360371

361372
def test_yydebug

version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
1212
#define RUBY_VERSION_TEENY 5
1313
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
14-
#define RUBY_PATCHLEVEL 102
14+
#define RUBY_PATCHLEVEL 103
1515

1616
#include "ruby/version.h"
1717
#include "ruby/internal/abi.h"

0 commit comments

Comments
 (0)