Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/grep Consistently short cut the pattern loop on mism...
details: https://anonhg.NetBSD.org/src/rev/da83300eabd2
branches: trunk
changeset: 779151:da83300eabd2
user: joerg <joerg%NetBSD.org@localhost>
date: Sun May 06 22:32:05 2012 +0000
description:
Consistently short cut the pattern loop on mismatches.
Don't assign 1 conditionally, if unconditional works as well.
diffstat:
usr.bin/grep/util.c | 40 ++++++++++++++++++----------------------
1 files changed, 18 insertions(+), 22 deletions(-)
diffs (71 lines):
diff -r f3a47674d084 -r da83300eabd2 usr.bin/grep/util.c
--- a/usr.bin/grep/util.c Sun May 06 22:27:00 2012 +0000
+++ b/usr.bin/grep/util.c Sun May 06 22:32:05 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: util.c,v 1.15 2012/05/06 22:27:01 joerg Exp $ */
+/* $NetBSD: util.c,v 1.16 2012/05/06 22:32:05 joerg Exp $ */
/* $FreeBSD: head/usr.bin/grep/util.c 211496 2010-08-19 09:28:59Z des $ */
/* $OpenBSD: util.c,v 1.39 2010/07/02 22:18:03 tedu Exp $ */
@@ -34,7 +34,7 @@
#endif
#include <sys/cdefs.h>
-__RCSID("$NetBSD: util.c,v 1.15 2012/05/06 22:27:01 joerg Exp $");
+__RCSID("$NetBSD: util.c,v 1.16 2012/05/06 22:32:05 joerg Exp $");
#include <sys/stat.h>
#include <sys/types.h>
@@ -317,36 +317,32 @@
if (r == REG_NOMATCH)
continue;
/* Check for full match */
- if (r == 0 && xflag)
- if (pmatch.rm_so != 0 ||
- (size_t)pmatch.rm_eo != l->len)
- r = REG_NOMATCH;
+ if (xflag &&
+ (pmatch.rm_so != 0 ||
+ (size_t)pmatch.rm_eo != l->len))
+ continue;
/* Check for whole word match */
- if (r == 0 && fg_pattern[i].word &&
- pmatch.rm_so != 0) {
+ if (fg_pattern[i].word && pmatch.rm_so != 0) {
wint_t wbegin, wend;
wbegin = wend = L' ';
if (pmatch.rm_so != 0 &&
sscanf(&l->dat[pmatch.rm_so - 1],
"%lc", &wbegin) != 1)
- r = REG_NOMATCH;
- else if ((size_t)pmatch.rm_eo != l->len &&
+ continue;
+ if ((size_t)pmatch.rm_eo != l->len &&
sscanf(&l->dat[pmatch.rm_eo],
"%lc", &wend) != 1)
- r = REG_NOMATCH;
- else if (iswword(wbegin) || iswword(wend))
- r = REG_NOMATCH;
+ continue;
+ if (iswword(wbegin) || iswword(wend))
+ continue;
}
- if (r == 0) {
- if (m == 0)
- c++;
- if (m < MAX_LINE_MATCHES)
- matches[m++] = pmatch;
- /* matches - skip further patterns */
- if ((color != NULL && !oflag) || qflag || lflag)
- break;
- }
+ c = 1;
+ if (m < MAX_LINE_MATCHES)
+ matches[m++] = pmatch;
+ /* matches - skip further patterns */
+ if ((color != NULL && !oflag) || qflag || lflag)
+ break;
}
if (vflag) {
Home |
Main Index |
Thread Index |
Old Index