summaryrefslogtreecommitdiff
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-16 16:49:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-16 16:49:38 +0000
commit8cb6f21e1aadad2c1e114a7504425029300edb03 (patch)
treed5b49d600f6c38757e0e13ebe981ec41f394f959 /dir.c
parent17d31216ea903fa6cd464d16b5f1512479da62c1 (diff)
dir.c: reduce matching
* dir.c (glob_helper): reduce matching at non-mgaical path on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/dir.c b/dir.c
index fb13be1..0a7cdbe 100644
--- a/dir.c
+++ b/dir.c
@@ -1404,7 +1404,19 @@ glob_helper(
if (magical || recursive) {
struct dirent *dp;
DIR *dirp;
+# if DOSISH
+ char *plainname = 0;
+# endif
IF_HAVE_HFS(int hfs_p);
+# if DOSISH
+ if (cur + 1 == end && (*cur)->type <= ALPHA) {
+ plainname = join_path(path, pathlen, dirsep, (*cur)->str, strlen((*cur)->str));
+ if (!plainname) return -1;
+ dirp = do_opendir(plainname, flags, enc);
+ GLOB_FREE(plainname);
+ }
+ else
+# endif
dirp = do_opendir(*path ? path : ".", flags, enc);
if (dirp == NULL) {
# if FNM_SYSCASE || HAVE_HFS
@@ -1489,6 +1501,12 @@ glob_helper(
}
switch (p->type) {
case ALPHA:
+# ifdef DOSISH
+ if (plainname) {
+ *new_end++ = p->next;
+ break;
+ }
+# endif
case MAGICAL:
if (fnmatch(p->str, enc, name, flags) == 0)
*new_end++ = p->next;