From nobody Wed Jan 04 05:38:39 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Nmz0w13xqz2npSY; Wed, 4 Jan 2023 05:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Nmz0w0Xnlz46Zx; Wed, 4 Jan 2023 05:38:40 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672810720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dE9WQIPsyUUn4A1VhUahUFJGK4LgrXICrSyFhorVSqM=; b=UTgoXCJVtNL3c1MnEU2LLhYiIANRKLtcm13VDnxFiXd9Tamzf1CgaO7KlgLL+CYcJ1wUoU udVK0Xfy1dhfaQhDAwkBAiT58Wi66xMhHovGPmJk+yjJdQTtgcG0NFMfZwOFM1YVemmrZk W2YpnoK7pJX24wqCn7xDvX10h6vJQoI4YZorSr8w9z4ttbcjAMmQx8Eyh634ScIT6xCke+ 4Hyw/184y9SaCbScRA7iTcbcQWDofTVYZLX6ONtCV5VGBy+gNzm+H8/xjWvSuO3wWCpgb/ cTU0QZibiftrH62ZT7WgumkgKa1WuEZxPFHyJ8vuUwADWtTdMbRB1KCtIdyxew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672810720; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=dE9WQIPsyUUn4A1VhUahUFJGK4LgrXICrSyFhorVSqM=; b=M6TLC1qjWf7KwbsNkdbc51WGjFRwhxRKKQplXMSuF5bkHHYChwwwTOGGBb43aEX2LgYxT0 e56DJGYfarhB2REFGSEtXB1lqMscnVqlPMzPij8anyLn2mkchxoG9ex2ku3jNTGseDaJgG YNK/LKg3s5qs2leoTosHrR2DfBXOWxrc/ReK/mvj0OKbrlSMaNN+i/9wTH5zSKtggXlDmf /39hMlOgZPMskuyWkqblI+XG1kBYBneC9UIbXatmM2QYqxJ9XtZD1Z8ftetalMPi3uDiUC ZDjOiaZANltscBXd5S687gQ9yhvzHciYmHJY/YcvurFlaZxyN1bVReVdLYJY/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672810720; a=rsa-sha256; cv=none; b=CVAjNglOfWs0rBMAB0Aqve2/+SCw8uyB7sLpz5/rmylLXUG3XU9fZiERX/BTK1dQgXPCBm REcPXS6cKvNZ1bhBv1209ygANikhNtqUKQ08UDNBwbsm6mp0ZVEVpJwj9u500oqtAyDGoc N8PZmoz7dmHHF51Iz9Vx/c8PFbHG2YcqurEQORFDB8NV+ZZgwV8EL5nsYuQYIE1oUpZzHG 07y7EPLf9PgjuAnx2FSrbmTSvFeTdO+Zi8NDRaKkaX+ysFanoByy+xL6AmNl5LEvor1z5V pY5uhZUiR7hRNn8ksY9r3jDtwF3PnqkDkyweiut1C+fC8xvhVC1Pq3YXASROHA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Nmz0v6h1Sz10jd; Wed, 4 Jan 2023 05:38:39 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 3045cdsh018614; Wed, 4 Jan 2023 05:38:39 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 3045cdSN018613; Wed, 4 Jan 2023 05:38:39 GMT (envelope-from git) Date: Wed, 4 Jan 2023 05:38:39 GMT Message-Id: <202301040538.3045cdSN018613@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kyle Evans Subject: git: e898a3af97f9 - main - grep: properly switch EOL indicator with -z List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kevans X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e898a3af97f97f74c0fb22032bbd163f7cc92a05 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=e898a3af97f97f74c0fb22032bbd163f7cc92a05 commit e898a3af97f97f74c0fb22032bbd163f7cc92a05 Author: Kyle Evans AuthorDate: 2023-01-04 05:21:10 +0000 Commit: Kyle Evans CommitDate: 2023-01-04 05:37:54 +0000 grep: properly switch EOL indicator with -z -z is supposed to use only the NUL byte as EOL, but we were inadvertently using both newline and NUL due to REG_NEWLINE in cflags. The odds of anyone relying on this bsdgrep-specific bug are quite low, so let's just fix it. At least one port in the wild has been reported to expect the intended behavior. Reported by: Hill Ma Triaged by: the self-proclaimed peanut gallery on Discord --- usr.bin/grep/grep.c | 1 + usr.bin/grep/tests/grep_freebsd_test.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/usr.bin/grep/grep.c b/usr.bin/grep/grep.c index 6306cbff5932..3f16d118f0d8 100644 --- a/usr.bin/grep/grep.c +++ b/usr.bin/grep/grep.c @@ -562,6 +562,7 @@ main(int argc, char *argv[]) break; case 'z': fileeol = '\0'; + cflags &= ~REG_NEWLINE; break; case BIN_OPT: if (strcasecmp("binary", optarg) == 0) diff --git a/usr.bin/grep/tests/grep_freebsd_test.sh b/usr.bin/grep/tests/grep_freebsd_test.sh index 0d068d5d1c65..f6881791357c 100755 --- a/usr.bin/grep/tests/grep_freebsd_test.sh +++ b/usr.bin/grep/tests/grep_freebsd_test.sh @@ -92,9 +92,22 @@ gnuext_body() } +atf_test_case zflag +zflag_body() +{ + + # The -z flag should pick up 'foo' and 'bar' as on the same line with + # 'some kind of junk' in between; a bug was present that instead made + # it process this incorrectly. + printf "foo\nbar\0" > in + + atf_check grep -qz "foo.*bar" in +} + atf_init_test_cases() { atf_add_test_case grep_r_implied atf_add_test_case rgrep atf_add_test_case gnuext + atf_add_test_case zflag }