From 9375ff5b06704b2fbad3f740cecf10399786acfd Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 3 Jun 2015 22:12:24 +0000 Subject: dir.c: FNM_SHORTNAME * dir.c (dirent_match): match short names only when FNM_SHORTNAME flag is given, for the backward compatibility, and the new behavior is often dangerous. [ruby-core:69435] [Bug #11206] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50760 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 a6934bda6a..8aadef4bf9 100644 --- a/dir.c +++ b/dir.c @@ -157,6 +157,11 @@ has_nonascii(const char *ptr, size_t len) #else #define FNM_SYSCASE 0 #endif +#if _WIN32 +#define FNM_SHORTNAME 0x20 +#else +#define FNM_SHORTNAME 0 +#endif #define FNM_NOMATCH 1 #define FNM_ERROR 2 @@ -1595,7 +1600,7 @@ dirent_match(const char *pat, rb_encoding *enc, const char *name, const struct d { if (fnmatch(pat, enc, name, flags) == 0) return 1; #ifdef _WIN32 - if (dp->d_altname) { + if (dp->d_altname && (flags & FNM_SHORTNAME)) { if (fnmatch(pat, enc, dp->d_altname, flags) == 0) return 1; } #endif @@ -2636,4 +2641,11 @@ Init_Dir(void) * 0. */ rb_file_const("FNM_SYSCASE", INT2FIX(FNM_SYSCASE)); + + /* Document-const: File::Constants::FNM_SHORTNAME + * + * Makes patterns to match short names if existing. Valid only + * on Microsoft Windows. + */ + rb_file_const("FNM_SHORTNAME", INT2FIX(FNM_SHORTNAME)); } -- cgit v1.2.3