svn commit: r232110 - user/gabor/tre-integration/usr.bin/grep
Gabor Kovesdan
gabor at FreeBSD.org
Fri Feb 24 13:11:51 UTC 2012
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;
More information about the svn-src-user
mailing list