Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Feb 2012 13:11:50 +0000 (UTC)
From:      Gabor Kovesdan <gabor@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-user@freebsd.org
Subject:   svn commit: r232110 - user/gabor/tre-integration/usr.bin/grep
Message-ID:  <201202241311.q1ODBo76060269@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gabor
Date: Fri Feb 24 13:11:50 2012
New Revision: 232110
URL: http://svn.freebsd.org/changeset/base/232110

Log:
  - Add an error handling after pattern matching (there was no error handling so
    far, although such error rarely occurs).
  - Simplify code

Modified:
  user/gabor/tre-integration/usr.bin/grep/util.c

Modified: user/gabor/tre-integration/usr.bin/grep/util.c
==============================================================================
--- user/gabor/tre-integration/usr.bin/grep/util.c	Fri Feb 24 13:05:10 2012	(r232109)
+++ user/gabor/tre-integration/usr.bin/grep/util.c	Fri Feb 24 13:11:50 2012	(r232110)
@@ -285,20 +285,25 @@ procline(struct str *l, int nottext)
 		    (size_t)pmatch.rm_eo;
 		if (r == REG_NOMATCH)
 			continue;
+		else if (ret != REG_OK)
+		  // XXX: better error msg?
+		  errx(2, "Failed processing input.");
+
 		/* Check for full match */
-		if (r == REG_OK && xflag)
+		if (xflag)
 			if (pmatch.rm_so != 0 ||
 			    (size_t)pmatch.rm_eo != l->len)
-				r = REG_NOMATCH;
-		if (r == REG_OK) {
-			if (m == 0)
-				c++;
-			if (m < MAX_LINE_MATCHES)
-				matches[m++] = pmatch;
-			/* matches - skip further patterns */
-			if ((color == NULL && !oflag) || qflag || lflag)
-				break;
-		}
+				continue;
+
+		/* If reached here, we have a match. */
+		if (m == 0)
+			c++;
+		if (m < MAX_LINE_MATCHES)
+			matches[m++] = pmatch;
+
+		/* matches - skip further patterns */
+		if ((color == NULL && !oflag) || qflag || lflag)
+			break;
 
 		if (vflag) {
 			c = !c;
@@ -306,7 +311,6 @@ procline(struct str *l, int nottext)
 		}
 	}
 
-
 	/* Count the matches if we have a match limit */
 	if (mflag)
 		mcount -= c;



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