Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2008 11:49:37 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 143816 for review
Message-ID:  <200806201149.m5KBnb63092145@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=143816

Change 143816 by gabor@gabor_server on 2008/06/20 11:48:57

	- Don't grep directories as standard files when -R is given
	
	Reported by:	Michael Plass <mfp49_freebsd@plass-family.net>

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/util.c#29 edit

Differences ...

==== //depot/projects/soc2008/gabor_textproc/grep/util.c#29 (text+ko) ====

@@ -66,7 +66,6 @@
 	FTS		*fts;
 	FTSENT		*p;
 	int		 c, fts_flags;
-	struct stat	*finfo = 0;
 
 	c = fts_flags = 0;
 
@@ -91,19 +90,26 @@
 		case FTS_DP:
 			break;
 		default:
-			if (Dflag) {
+			if (Dflag || Rflag) {
+				struct stat	*finfo;
+
 				if (!(finfo = malloc(sizeof(struct stat))))
 					err(2, NULL);
 				if (stat(p->fts_path, finfo) == -1)
 					err(2, NULL);
-				if (S_ISBLK(finfo->st_mode) ||
+
+				if (Dflag && (S_ISBLK(finfo->st_mode) ||
 				    S_ISCHR(finfo->st_mode) ||
 				    S_ISFIFO(finfo->st_mode) ||
-				    S_ISSOCK(finfo->st_mode)) {
+				    S_ISSOCK(finfo->st_mode))) {
 					free(finfo);
 					break;
-				} else
+				}
+				if (Rflag && S_ISDIR(finfo->st_mode)) {
 					free(finfo);
+					break;
+				}
+				free(finfo);
 			}
 			c += procfile(p->fts_path);
 			break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806201149.m5KBnb63092145>