Revert "dir.c: glob cases on case-insensitive system"
This reverts commit r44796. * dir.c (glob_helper): return the filename with actual cases on the filesystem if it is case-insensitive. [ruby-core:42469] [Feature #5994] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
4f43122496
commit
859ae7764c
@ -8,12 +8,6 @@ Mon Feb 3 12:04:47 2014 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
|||||||
|
|
||||||
* error.c: [DOC] Exception#cause may return nil. [ci skip]
|
* error.c: [DOC] Exception#cause may return nil. [ci skip]
|
||||||
|
|
||||||
Mon Feb 3 10:49:48 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
|
||||||
|
|
||||||
* dir.c (glob_helper): return the filename with actual cases on
|
|
||||||
the filesystem if it is case-insensitive. [ruby-core:42469]
|
|
||||||
[Feature #5994]
|
|
||||||
|
|
||||||
Sun Feb 2 05:48:42 2014 Eric Wong <e@80x24.org>
|
Sun Feb 2 05:48:42 2014 Eric Wong <e@80x24.org>
|
||||||
|
|
||||||
* io.c (rb_io_syswrite): add RB_GC_GUARD
|
* io.c (rb_io_syswrite): add RB_GC_GUARD
|
||||||
|
22
dir.c
22
dir.c
@ -1397,29 +1397,14 @@ glob_helper(
|
|||||||
|
|
||||||
if (exist == NO || isdir == NO) return 0;
|
if (exist == NO || isdir == NO) return 0;
|
||||||
|
|
||||||
if (magical || recursive || ((FNM_SYSCASE || HAVE_HFS) && plain)) {
|
if (magical || recursive) {
|
||||||
struct dirent *dp;
|
struct dirent *dp;
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
IF_HAVE_HFS(int hfs_p);
|
IF_HAVE_HFS(int hfs_p);
|
||||||
dirp = do_opendir(*path ? path : ".", flags, enc);
|
dirp = do_opendir(*path ? path : ".", flags, enc);
|
||||||
if (dirp == NULL) {
|
if (dirp == NULL) return 0;
|
||||||
# if FNM_SYSCASE || HAVE_HFS
|
|
||||||
if (!(magical || recursive) && (errno == EACCES)) {
|
|
||||||
/* no read permission, fallback */
|
|
||||||
goto literally;
|
|
||||||
}
|
|
||||||
# endif
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
IF_HAVE_HFS(hfs_p = is_hfs(dirp));
|
IF_HAVE_HFS(hfs_p = is_hfs(dirp));
|
||||||
|
|
||||||
# if HAVE_HFS
|
|
||||||
if (!(hfs_p || magical || recursive)) {
|
|
||||||
closedir(dirp);
|
|
||||||
goto literally;
|
|
||||||
}
|
|
||||||
flags |= FNM_CASEFOLD;
|
|
||||||
# endif
|
|
||||||
while ((dp = READDIR(dirp, enc)) != NULL) {
|
while ((dp = READDIR(dirp, enc)) != NULL) {
|
||||||
char *buf;
|
char *buf;
|
||||||
enum answer new_isdir = UNKNOWN;
|
enum answer new_isdir = UNKNOWN;
|
||||||
@ -1501,9 +1486,6 @@ glob_helper(
|
|||||||
else if (plain) {
|
else if (plain) {
|
||||||
struct glob_pattern **copy_beg, **copy_end, **cur2;
|
struct glob_pattern **copy_beg, **copy_end, **cur2;
|
||||||
|
|
||||||
# if FNM_SYSCASE || HAVE_HFS
|
|
||||||
literally:
|
|
||||||
# endif
|
|
||||||
copy_beg = copy_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg);
|
copy_beg = copy_end = GLOB_ALLOC_N(struct glob_pattern *, end - beg);
|
||||||
if (!copy_beg) return -1;
|
if (!copy_beg) return -1;
|
||||||
for (cur = beg; cur < end; ++cur)
|
for (cur = beg; cur < end; ++cur)
|
||||||
|
@ -228,27 +228,6 @@ class TestDir < Test::Unit::TestCase
|
|||||||
assert_empty(Dir.glob(File.join(@root, "<")), bug8597)
|
assert_empty(Dir.glob(File.join(@root, "<")), bug8597)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_glob_cases
|
|
||||||
feature5994 = "[ruby-core:42469] [Feature #5994]"
|
|
||||||
feature5994 << "\nDir.glob should return the filename with actual cases on the filesystem"
|
|
||||||
Dir.chdir(File.join(@root, "a")) do
|
|
||||||
open("FileWithCases", "w") {}
|
|
||||||
return unless File.exist?("filewithcases")
|
|
||||||
assert_equal(%w"FileWithCases", Dir.glob("filewithcases"), feature5994)
|
|
||||||
end
|
|
||||||
Dir.chdir(File.join(@root, "c")) do
|
|
||||||
open("FileWithCases", "w") {}
|
|
||||||
mode = File.stat(".").mode
|
|
||||||
begin
|
|
||||||
File.chmod(mode & ~0444, ".")
|
|
||||||
return if mode == File.stat(".").mode
|
|
||||||
assert_equal(%w"filewithcases", Dir.glob("filewithcases"), feature5994)
|
|
||||||
ensure
|
|
||||||
File.chmod(mode, ".")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_home
|
def test_home
|
||||||
env_home = ENV["HOME"]
|
env_home = ENV["HOME"]
|
||||||
env_logdir = ENV["LOGDIR"]
|
env_logdir = ENV["LOGDIR"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user