Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Jun 2008 00:33:53 GMT
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 143851 for review
Message-ID:  <200806210033.m5L0Xr5k020834@repoman.freebsd.org>

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

Change 143851 by gabor@gabor_server on 2008/06/21 00:33:00

	- GNU compatibility: better -d behaviour

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#32 edit
.. //depot/projects/soc2008/gabor_textproc/grep/grep.h#17 edit
.. //depot/projects/soc2008/gabor_textproc/grep/util.c#31 edit

Differences ...

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

@@ -80,6 +80,7 @@
 int	 Zflag;		/* -Z: grep in gzipped file */
 int	 bflag;		/* -b: show block numbers for each match */
 int	 cflag;		/* -c: only show a count of matching lines */
+int	 dflag;		/* -d: skip reading of directories */
 int	 hflag;		/* -h: don't print filename headers */
 int	 iflag;		/* -i: ignore case */
 int	 lflag;		/* -l: only show names of files with matches */
@@ -422,7 +423,10 @@
 			if (strcmp("recurse", optarg) == 0) {
 				Hflag++;
 				Rflag++;
-			}
+			} else if (strcmp("skip", optarg) == 0)
+				dflag++;
+			else if (strcmp("read", optarg) != 0)
+				usage();
 			break;
 		case 'E':
 			Fflag = Gflag = 0;

==== //depot/projects/soc2008/gabor_textproc/grep/grep.h#17 (text+ko) ====

@@ -62,7 +62,7 @@
 /* Command line flags */
 extern int	 Aflag, Bflag, Dflag, Eflag, Fflag, Gflag, Hflag, Jflag,
 		 Lflag, Oflag, Pflag, Rflag, Zflag,
-		 bflag, cflag, hflag, iflag, lflag, mflag, nflag, oflag,
+		 bflag, cflag, dflag, hflag, iflag, lflag, mflag, nflag, oflag,
 		 qflag, sflag, vflag, wflag, xflag, nullflag;
 extern long long mcount;
 extern char	*color, *label;

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

@@ -90,7 +90,7 @@
 		case FTS_DP:
 			break;
 		default:
-			if (Dflag || Rflag) {
+			if (Dflag || Rflag || dflag) {
 				struct stat	*finfo;
 
 				if (!(finfo = malloc(sizeof(struct stat))))
@@ -105,7 +105,7 @@
 					free(finfo);
 					break;
 				}
-				if (Rflag && S_ISDIR(finfo->st_mode)) {
+				if ((Rflag || dflag) && S_ISDIR(finfo->st_mode)) {
 					free(finfo);
 					break;
 				}



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