From 5b06e833453dcbbf4da69a5f98d50e565d4300ef Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 8 Mar 2015 07:57:38 +0000 Subject: 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 --- dir.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'dir.c') 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; -- cgit v1.2.3