[前][次][番号順一覧][スレッド一覧]

ruby-changes:36894

From: nobu <ko1@a...>
Date: Wed, 24 Dec 2014 23:40:03 +0900 (JST)
Subject: [ruby-changes:36894] nobu:r48975 (trunk): dir.c: shortcut for case-insensitive name

nobu	2014-12-24 23:39:49 +0900 (Wed, 24 Dec 2014)

  New Revision: 48975

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48975

  Log:
    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]

  Modified files:
    trunk/dir.c
Index: dir.c
===================================================================
--- dir.c	(revision 48974)
+++ dir.c	(revision 48975)
@@ -1439,6 +1439,7 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L1439
 	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( https://github.com/ruby/ruby/blob/trunk/dir.c#L1541
 # 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( https://github.com/ruby/ruby/blob/trunk/dir.c#L1555
 	    GLOB_FREE(buf);
 	    GLOB_FREE(new_beg);
 	    if (status) break;
+	    IF_HAVE_HFS(if (alpha_matched) break);
 	}
 
 	closedir(dirp);

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]