svn commit: r245996 - stable/9/usr.bin/grep

Gabor Kovesdan gabor at FreeBSD.org
Sun Jan 27 19:44:42 UTC 2013


Author: gabor
Date: Sun Jan 27 19:44:41 2013
New Revision: 245996
URL: http://svnweb.freebsd.org/changeset/base/245996

Log:
  MFC r245057, r245688
  
    - Fix handling of the case when multiple patterns are specified in a single
      command line argument, separated by newlines

Modified:
  stable/9/usr.bin/grep/grep.c
Directory Properties:
  stable/9/usr.bin/grep/   (props changed)

Modified: stable/9/usr.bin/grep/grep.c
==============================================================================
--- stable/9/usr.bin/grep/grep.c	Sun Jan 27 18:01:03 2013	(r245995)
+++ stable/9/usr.bin/grep/grep.c	Sun Jan 27 19:44:41 2013	(r245996)
@@ -477,7 +477,13 @@ main(int argc, char *argv[])
 			grepbehave = GREP_EXTENDED;
 			break;
 		case 'e':
-			add_pattern(optarg, strlen(optarg));
+			{
+				char *token;
+				char *string = optarg;
+
+				while ((token = strsep(&string, "\n")) != NULL)
+					add_pattern(token, strlen(token));
+			}
 			needpattern = 0;
 			break;
 		case 'F':
@@ -666,7 +672,11 @@ main(int argc, char *argv[])
 
 	/* Process patterns from command line */
 	if (aargc != 0 && needpattern) {
-		add_pattern(*aargv, strlen(*aargv));
+		char *token;
+		char *string = *aargv;
+
+		while ((token = strsep(&string, "\n")) != NULL)
+			add_pattern(token, strlen(token));
 		--aargc;
 		++aargv;
 	}


More information about the svn-src-all mailing list