mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 55385,55390: [Backport #12483]
* file.c (append_fspath): normalize directory name to be appended on OS X. [ruby-core:75957] [Ruby trunk Bug#12483] https://github.com/rails/rails/issues/25303#issuecomment-224834804 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@55909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ab61e5c932
commit
12b6cd61c0
4 changed files with 48 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
Tue Aug 16 04:28:22 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* file.c (append_fspath): normalize directory name to be appended
|
||||||
|
on OS X. [ruby-core:75957] [Ruby trunk Bug#12483]
|
||||||
|
https://github.com/rails/rails/issues/25303#issuecomment-224834804
|
||||||
|
|
||||||
Tue Aug 16 04:16:14 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Tue Aug 16 04:16:14 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* regcomp.c (noname_disable_map): don't optimize out group 0
|
* regcomp.c (noname_disable_map): don't optimize out group 0
|
||||||
|
|
22
file.c
22
file.c
|
@ -235,6 +235,7 @@ rb_str_encode_ospath(VALUE path)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
# define NORMALIZE_UTF8PATH 1
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_str_append_normalized_ospath(VALUE str, const char *ptr, long len)
|
rb_str_append_normalized_ospath(VALUE str, const char *ptr, long len)
|
||||||
{
|
{
|
||||||
|
@ -334,6 +335,8 @@ ignored_char_p(const char *p, const char *e, rb_encoding *enc)
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
# define NORMALIZE_UTF8PATH 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static long
|
static long
|
||||||
|
@ -3218,6 +3221,18 @@ rb_default_home_dir(VALUE result)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
|
static VALUE
|
||||||
|
ospath_new(const char *ptr, long len, rb_encoding *fsenc)
|
||||||
|
{
|
||||||
|
#if NORMALIZE_UTF8PATH
|
||||||
|
VALUE path = rb_str_normalize_ospath(ptr, len);
|
||||||
|
rb_enc_associate(path, fsenc);
|
||||||
|
return path;
|
||||||
|
#else
|
||||||
|
return rb_enc_str_new(ptr, len, fsenc);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
static char *
|
static char *
|
||||||
append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encoding *fsenc)
|
append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encoding *fsenc)
|
||||||
{
|
{
|
||||||
|
@ -3225,12 +3240,15 @@ append_fspath(VALUE result, VALUE fname, char *dir, rb_encoding **enc, rb_encodi
|
||||||
VALUE dirname = Qnil;
|
VALUE dirname = Qnil;
|
||||||
size_t dirlen = strlen(dir), buflen = rb_str_capacity(result);
|
size_t dirlen = strlen(dir), buflen = rb_str_capacity(result);
|
||||||
|
|
||||||
if (*enc != fsenc) {
|
if (NORMALIZE_UTF8PATH || *enc != fsenc) {
|
||||||
rb_encoding *direnc = rb_enc_check(fname, dirname = rb_enc_str_new(dir, dirlen, fsenc));
|
rb_encoding *direnc = rb_enc_check(fname, dirname = ospath_new(dir, dirlen, fsenc));
|
||||||
if (direnc != fsenc) {
|
if (direnc != fsenc) {
|
||||||
dirname = rb_str_conv_enc(dirname, fsenc, direnc);
|
dirname = rb_str_conv_enc(dirname, fsenc, direnc);
|
||||||
RSTRING_GETMEM(dirname, cwdp, dirlen);
|
RSTRING_GETMEM(dirname, cwdp, dirlen);
|
||||||
}
|
}
|
||||||
|
else if (NORMALIZE_UTF8PATH) {
|
||||||
|
RSTRING_GETMEM(dirname, cwdp, dirlen);
|
||||||
|
}
|
||||||
*enc = direnc;
|
*enc = direnc;
|
||||||
}
|
}
|
||||||
do {buflen *= 2;} while (dirlen > buflen);
|
do {buflen *= 2;} while (dirlen > buflen);
|
||||||
|
|
|
@ -1075,6 +1075,27 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
assert_equal('z:/bar/foo', File.expand_path('z:foo', '/bar'), bug10858)
|
assert_equal('z:/bar/foo', File.expand_path('z:foo', '/bar'), bug10858)
|
||||||
end if DRIVE
|
end if DRIVE
|
||||||
|
|
||||||
|
case RUBY_PLATFORM
|
||||||
|
when /darwin/
|
||||||
|
def test_expand_path_compose
|
||||||
|
pp = Object.new.extend(Test::Unit::Assertions)
|
||||||
|
def pp.mu_pp(str) #:nodoc:
|
||||||
|
str.dump
|
||||||
|
end
|
||||||
|
|
||||||
|
Dir.mktmpdir do |dir|
|
||||||
|
Dir.chdir(dir) do
|
||||||
|
orig = %W"d\u{e9}tente x\u{304c 304e 3050 3052 3054}"
|
||||||
|
orig.each do |o|
|
||||||
|
Dir.mkdir(o)
|
||||||
|
n = Dir.chdir(o) {File.expand_path(".")}
|
||||||
|
pp.assert_equal(o, File.basename(n))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def test_basename
|
def test_basename
|
||||||
assert_equal(File.basename(regular_file).sub(/\.test$/, ""), File.basename(regular_file, ".test"))
|
assert_equal(File.basename(regular_file).sub(/\.test$/, ""), File.basename(regular_file, ".test"))
|
||||||
assert_equal(File.basename(utf8_file).sub(/\.test$/, ""), File.basename(utf8_file, ".test"))
|
assert_equal(File.basename(utf8_file).sub(/\.test$/, ""), File.basename(utf8_file, ".test"))
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.3.2"
|
#define RUBY_VERSION "2.3.2"
|
||||||
#define RUBY_RELEASE_DATE "2016-08-16"
|
#define RUBY_RELEASE_DATE "2016-08-16"
|
||||||
#define RUBY_PATCHLEVEL 159
|
#define RUBY_PATCHLEVEL 160
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2016
|
#define RUBY_RELEASE_YEAR 2016
|
||||||
#define RUBY_RELEASE_MONTH 8
|
#define RUBY_RELEASE_MONTH 8
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue