PERFORCE change 144191 for review

Gabor Kovesdan gabor at FreeBSD.org
Fri Jun 27 14:25:01 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=144191

Change 144191 by gabor at gabor_server on 2008/06/27 14:24:02

	- Restore compatibility of empty regexp

Affected files ...

.. //depot/projects/soc2008/gabor_textproc/grep/grep.c#52 edit

Differences ...

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

@@ -343,7 +343,7 @@
 int
 main(int argc, char *argv[])
 {
-	int		 c, lastc, prevoptind, newarg, i;
+	int		 c, lastc, prevoptind, newarg, i, needpattern;
 	char		*ep;
 	unsigned long long l;
 
@@ -382,6 +382,7 @@
 	lastc = '\0';
 	newarg = 1;
 	prevoptind = 1;
+	needpattern = 1;
 	while ((c = getopt_long(argc, argv, optstr,
 				long_options, NULL)) != -1) {
 		switch (c) {
@@ -439,6 +440,7 @@
 			break;
 		case 'e':
 			add_pattern(optarg, strlen(optarg));
+			needpattern = 0;
 			break;
 		case 'F':
 			Eflag = Gflag = 0;
@@ -446,6 +448,7 @@
 			break;
 		case 'f':
 			read_patterns(optarg);
+			needpattern = 0;
 			break;
 		case 'G':
 			Eflag = Fflag = 0;
@@ -575,10 +578,10 @@
 	argc -= optind;
 	argv += optind;
 
-	if (argc == 0 && patterns == 0)
+	if (argc == 0 && needpattern)
 		usage();
 
-	if (patterns == 0) {
+	if (argc != 0 && needpattern) {
 		add_pattern(*argv, strlen(*argv));
 		--argc;
 		++argv;


More information about the p4-projects mailing list