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

ruby-changes:33885

From: nobu <ko1@a...>
Date: Sat, 17 May 2014 01:49:59 +0900 (JST)
Subject: [ruby-changes:33885] nobu:r45966 (trunk): dir.c: reduce matching

nobu	2014-05-17 01:49:38 +0900 (Sat, 17 May 2014)

  New Revision: 45966

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

  Log:
    dir.c: reduce matching
    
    * dir.c (glob_helper): reduce matching at non-mgaical path on
      Windows.

  Modified files:
    trunk/ChangeLog
    trunk/dir.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 45965)
+++ ChangeLog	(revision 45966)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Sat May 17 01:49:27 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* dir.c (glob_helper): reduce matching at non-mgaical path on
+	  Windows.
+
 Sat May 17 01:49:23 2014  Nobuyoshi Nakada  <nobu@r...>
 
 	* dir.c (glob_pattern_type): separate names with alphabet but no
Index: dir.c
===================================================================
--- dir.c	(revision 45965)
+++ dir.c	(revision 45966)
@@ -1404,7 +1404,19 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L1404
     if (magical || recursive) {
 	struct dirent *dp;
 	DIR *dirp;
+# if DOSISH
+	char *plainname = 0;
+# endif
 	IF_HAVE_HFS(int hfs_p);
+# if DOSISH
+	if (cur + 1 == end && (*cur)->type <= ALPHA) {
+	    plainname = join_path(path, pathlen, dirsep, (*cur)->str, strlen((*cur)->str));
+	    if (!plainname) return -1;
+	    dirp = do_opendir(plainname, flags, enc);
+	    GLOB_FREE(plainname);
+	}
+	else
+# endif
 	dirp = do_opendir(*path ? path : ".", flags, enc);
 	if (dirp == NULL) {
 # if FNM_SYSCASE || HAVE_HFS
@@ -1489,6 +1501,12 @@ glob_helper( https://github.com/ruby/ruby/blob/trunk/dir.c#L1501
 		}
 		switch (p->type) {
 		  case ALPHA:
+# ifdef DOSISH
+		    if (plainname) {
+			*new_end++ = p->next;
+			break;
+		    }
+# endif
 		  case MAGICAL:
 		    if (fnmatch(p->str, enc, name, flags) == 0)
 			*new_end++ = p->next;

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

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