Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 5 Jan 2013 14:52:32 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r245057 - head/usr.bin/grep
Message-ID:  <201301051452.r05EqWHt051825@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Sat Jan  5 14:52:31 2013
New Revision: 245057
URL: http://svnweb.freebsd.org/changeset/base/245057

Log:
  - Fix handling of the case when multiple patterns are specified in a single
    command line argument, separated by newlines
  
  PR:		bin/173673
  Submitted by:	ache
  MFC after:	1 week

Modified:
  head/usr.bin/grep/grep.c

Modified: head/usr.bin/grep/grep.c
==============================================================================
--- head/usr.bin/grep/grep.c	Sat Jan  5 11:13:48 2013	(r245056)
+++ head/usr.bin/grep/grep.c	Sat Jan  5 14:52:31 2013	(r245057)
@@ -479,7 +479,13 @@ main(int argc, char *argv[])
 			grepbehave = GREP_EXTENDED;
 			break;
 		case 'e':
-			add_pattern(optarg, strlen(optarg));
+			{
+				char *token;
+				char *string = strdup(optarg);
+
+				while ((token = strsep(&string, "\n")) != NULL)
+					add_pattern(token, strlen(token));
+			}
 			needpattern = 0;
 			break;
 		case 'F':
@@ -668,7 +674,11 @@ main(int argc, char *argv[])
 
 	/* Process patterns from command line */
 	if (aargc != 0 && needpattern) {
-		add_pattern(*aargv, strlen(*aargv));
+		char *token;
+		char *string = strdup(*aargv);
+
+		while ((token = strsep(&string, "\n")) != NULL)
+			add_pattern(token, strlen(token));
 		--aargc;
 		++aargv;
 	}



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