diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-24 14:39:49 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-12-24 14:39:49 +0000 |
commit | ae6fb2c8f752e40d0ccbe1795adba4977adf804e (patch) | |
tree | 23763db27b88f45b7fa52402be0ae398d0e43acc | |
parent | e000d687b3c964232974f2cdd9946ef8e01cf4b9 (diff) | |
download | ruby-ae6fb2c8f752e40d0ccbe1795adba4977adf804e.tar.gz |
dir.c: shortcut for case-insensitive name
* dir.c (glob_helper): shortcut for case-insensitive name by
stopping reading after a matching name found.
[ruby-core:63591] [Bug #10015]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | dir.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1439,6 +1439,7 @@ glob_helper( char *plainname = 0; # endif IF_HAVE_HFS(int hfs_p); + IF_HAVE_HFS(int alpha_matched = 0); # ifdef DOSISH if (cur + 1 == end && (*cur)->type <= ALPHA) { plainname = join_path(path, pathlen, dirsep, (*cur)->str, strlen((*cur)->str)); @@ -1540,8 +1541,10 @@ glob_helper( # endif case PLAIN: case MAGICAL: - if (fnmatch(p->str, enc, name, flags) == 0) + if (fnmatch(p->str, enc, name, flags) == 0) { + IF_HAVE_HFS(alpha_matched |= (p->type == ALPHA)); *new_end++ = p->next; + } default: break; } @@ -1552,6 +1555,7 @@ glob_helper( GLOB_FREE(buf); GLOB_FREE(new_beg); if (status) break; + IF_HAVE_HFS(if (alpha_matched) break); } closedir(dirp); |