aboutsummaryrefslogtreecommitdiffstats
path: root/dir.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-08 07:57:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-03-08 07:57:38 +0000
commit5b06e833453dcbbf4da69a5f98d50e565d4300ef (patch)
tree185ce18aa5c6db3d4144bab7bbbbe99cfa03f660 /dir.c
parentdb24cb705dd1337129909ccd5923db0ebf695a13 (diff)
downloadruby-5b06e833453dcbbf4da69a5f98d50e565d4300ef.tar.gz
dir.c: glob short names
* dir.c (glob_helper): match patterns against legacy short names too, not only ordinary names. [ruby-core:67954] [Bug #10819] * win32/dir.h (struct direct): add short name members. * win32/win32.c (opendir_internal, readdir_internal): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49892 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'dir.c')
-rw-r--r--dir.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/dir.c b/dir.c
index 89f7bb89cb..8e7f1c945b 100644
--- a/dir.c
+++ b/dir.c
@@ -1554,6 +1554,18 @@ glob_func_caller(VALUE val)
return Qnil;
}
+static inline int
+dirent_match(const char *pat, rb_encoding *enc, const char *name, const struct dirent *dp, int flags)
+{
+ if (fnmatch(pat, enc, name, flags) == 0) return 1;
+#ifdef _WIN32
+ if (dp->d_altname) {
+ if (fnmatch(pat, enc, dp->d_altname, flags) == 0) return 1;
+ }
+#endif
+ return 0;
+}
+
static int
glob_helper(
const char *path,
@@ -1753,7 +1765,7 @@ glob_helper(
# endif
case PLAIN:
case MAGICAL:
- if (fnmatch(p->str, enc, name, flags) == 0)
+ if (dirent_match(p->str, enc, name, dp, flags))
*new_end++ = p->next;
default:
break;