From: nobu@... Date: 2015-06-02T12:18:50+00:00 Subject: [ruby-core:69444] [Ruby trunk - Bug #11206] short file name match incompatibility Issue #11206 has been updated by Nobuyoshi Nakada. For better or worse, extension names are something special things on Windows, so what about matching extension of long names, but not short names? ~~~diff diff --git i/dir.c w/dir.c index a6934bd..2b03a72 100644 --- i/dir.c +++ w/dir.c @@ -1596,7 +1596,21 @@ 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 (fnmatch(pat, enc, dp->d_altname, flags) == 0) return 1; + const char *altname = dp->d_altname; + long altextlen = strlen(dp->d_altname); + const char *altext = ruby_enc_find_extname(altname, &altextlen, enc); + if (altext) { + long extlen = NAMLEN(dp); + const char *ext = ruby_enc_find_extname(name, &extlen, enc); + if (ext) { + char *tmpname = ALLOCA_N(char, altext - altname + extlen + 1); + memcpy(tmpname, altname, altext - altname); + memcpy(tmpname + (altext - altname), ext, extlen); + tmpname[altext - altname + extlen] = '\0'; + altname = tmpname; + } + } + if (fnmatch(pat, enc, altname, flags) == 0) return 1; } #endif return 0; ~~~ ---------------------------------------- Bug #11206: short file name match incompatibility https://bugs.ruby-lang.org/issues/11206#change-52716 * Author: Yui NARUSE * Status: Assigned * Priority: Normal * Assignee: Nobuyoshi Nakada * ruby -v: * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- When I develop a foo.gem, my working diretory has foo.gemspec and foo.gem. If I run `gem install -l foo`, it fails as following: ERROR: While executing gem ... (Gem::Package::FormatError) package metadata is missing in foo.gemspec Because gem command tries to traverse the current directory with Dir["*.gem"], and it include *.gemspec. Another example, Rakefile has `rake clean` task and it is specified by CLEAN constant. if I specify CLEAN.include( "*.gem" ), it removes *.gemspec. -- https://bugs.ruby-lang.org/