From owner-svn-src-stable@freebsd.org Thu Aug 17 17:09:29 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E3F0EDCA701; Thu, 17 Aug 2017 17:09:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BB63F7FF7D; Thu, 17 Aug 2017 17:09:29 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v7HH9SQn035583; Thu, 17 Aug 2017 17:09:28 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v7HH9SeZ035580; Thu, 17 Aug 2017 17:09:28 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201708171709.v7HH9SeZ035580@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 17 Aug 2017 17:09:28 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r322622 - stable/11/usr.bin/grep X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/usr.bin/grep X-SVN-Commit-Revision: 322622 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Aug 2017 17:09:30 -0000 Author: kevans Date: Thu Aug 17 17:09:28 2017 New Revision: 322622 URL: https://svnweb.freebsd.org/changeset/base/322622 Log: MFC r318914: bsdgrep: correct assumptions to prepare for chunking Correct a couple of minor BSD grep assumptions that are valid for line processing but not future chunk-based processing. Approved by: emaste (mentor, blanket MFC) Modified: stable/11/usr.bin/grep/grep.c stable/11/usr.bin/grep/grep.h stable/11/usr.bin/grep/util.c Directory Properties: stable/11/ (props changed) Modified: stable/11/usr.bin/grep/grep.c ============================================================================== --- stable/11/usr.bin/grep/grep.c Thu Aug 17 16:54:37 2017 (r322621) +++ stable/11/usr.bin/grep/grep.c Thu Aug 17 17:09:28 2017 (r322622) @@ -79,7 +79,7 @@ const char *errstr[] = { }; /* Flags passed to regcomp() and regexec() */ -int cflags = REG_NOSUB; +int cflags = REG_NOSUB | REG_NEWLINE; int eflags = REG_STARTEND; /* XXX TODO: Get rid of this flag. Modified: stable/11/usr.bin/grep/grep.h ============================================================================== --- stable/11/usr.bin/grep/grep.h Thu Aug 17 16:54:37 2017 (r322621) +++ stable/11/usr.bin/grep/grep.h Thu Aug 17 17:09:28 2017 (r322622) @@ -82,7 +82,7 @@ extern const char *errstr[]; #define EXCL_PAT 0 #define INCL_PAT 1 -#define MAX_LINE_MATCHES 32 +#define MAX_MATCHES 32 struct file { int fd; Modified: stable/11/usr.bin/grep/util.c ============================================================================== --- stable/11/usr.bin/grep/util.c Thu Aug 17 16:54:37 2017 (r322621) +++ stable/11/usr.bin/grep/util.c Thu Aug 17 17:09:28 2017 (r322622) @@ -61,7 +61,7 @@ static bool first_match = true; * other useful bits */ struct parsec { - regmatch_t matches[MAX_LINE_MATCHES]; /* Matches made */ + regmatch_t matches[MAX_MATCHES]; /* Matches made */ struct str ln; /* Current line */ size_t lnstart; /* Position in line */ size_t matchidx; /* Latest match index */ @@ -295,7 +295,7 @@ procfile(const char *fn) /* Print the matching line, but only if not quiet/binary */ if (t == 0 && printmatch) { printline(&pc, ':'); - while (pc.matchidx >= MAX_LINE_MATCHES) { + while (pc.matchidx >= MAX_MATCHES) { /* Reset matchidx and try again */ pc.matchidx = 0; if (procline(&pc) == 0) @@ -401,7 +401,7 @@ procline(struct parsec *pc) lastmatches = 0; startm = matchidx; retry = 0; - if (st > 0) + if (st > 0 && pc->ln.dat[st - 1] != fileeol) leflags |= REG_NOTBOL; /* Loop to compare with all the patterns */ for (i = 0; i < patterns; i++) { @@ -483,7 +483,7 @@ procline(struct parsec *pc) } /* avoid excessive matching - skip further patterns */ if ((color == NULL && !oflag) || qflag || lflag || - matchidx >= MAX_LINE_MATCHES) { + matchidx >= MAX_MATCHES) { pc->lnstart = nst; lastmatches = 0; break;