From nobody Fri Jan 12 15:44:29 2024 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 4TBQnp1f78z573B2; Fri, 12 Jan 2024 15:44:30 +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 4TBQnp0nSBz4M1J; Fri, 12 Jan 2024 15:44:30 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705074270; 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=KRYU4VA88Fw6q/oqaBi1yRickTUDkUpaH+EKiqld2/E=; b=PLVzpZxCndzOftKYg6CBD0pkvGTI7k9HNSHuGP6DxufebN9HhFgShhfdE/1sDomIGBg8qd mD4EE3RUcFST2yydNXq9RZW+X946Oow5T6r1J7SVmivtroEO/KrxWeFZwoS58pvgrWYeY9 0iERD7165M67YEs/HYzr9g8wGUDG0ZdKVSUaCSmnR5cqi2FcKANZR5V/M9dOPHKDymiIUg nKOq6Bicf0afLhpL1QdwN0zXwiFojxWHIrcnNZcbEcTme9poeTQsV4yInTF0JMiQKq2AZB kfo5k3jtzgyy+egNtERW7ckQIkIzViUamk8Loqnpc+5w3A7SGQvn3XB/ZCLlHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705074270; 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=KRYU4VA88Fw6q/oqaBi1yRickTUDkUpaH+EKiqld2/E=; b=k7YaY7lFg+qOLnDwaOpVolPlgbMlwxakUhb732rDjWWcrsp7OGEoa9HRt8hEWCJkhkzkD8 bOjVBNN3GjiPxxYFSNUvEe/jx8yU+SHlgV9bKQ6Mc19qNV38S2ALAlnhg0PCgIJtLKnJ5i KTY+EP8GlBCwzc9EIdVZM75fnyhjG5M4iiKnAHQybqrcHMUUR1GuVnhcjE54QUCsc0UEhJ lSRiD9mIJrcWoz1/CIwQFJWc2ilg3iP+3+uNnU702vGYtmhDKXQ1GKoH9NKMwJ6Vtx6kaN xlw5wsErczkZct4OZw3+oRhMCTgX8QLeyx+7q3PqIui4G/NPTwfBHJ8iWBDq3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705074270; a=rsa-sha256; cv=none; b=fjVDFbEc563YFidMud1HBM5Av7c/dFpxtSZ/ltHC2MUOMiRiirk1yY67ST91r0lXHtSZLZ y/7PmsYF6trtGW7Q1j7dxFKECZMdylO38ADCzm6OheHOGc0JPP/+iZaB8zTjN9Xbuomhad GHqlgHs/JPcH6+QuArGBfBusmtS4UF57+ehJnfFvDduUEjz5Y2JUq5blGdeoOqeHmFV2Uz MRwqxGUToPO/L0eJeyB9lgVPTwi0pipWPLe5h9/cirEkAfk70HL3YWdcCGH/vToXB6QCzG CqaehHMBfRxUrYew5Blv8FBT7ARYB6dqvImMv1kKOrjXHpnyAvDSy6NHix+aUw== 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 4TBQnn70fQz16wM; Fri, 12 Jan 2024 15:44:29 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 40CFiTNb076687; Fri, 12 Jan 2024 15:44:29 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 40CFiT5q076684; Fri, 12 Jan 2024 15:44:29 GMT (envelope-from git) Date: Fri, 12 Jan 2024 15:44:29 GMT Message-Id: <202401121544.40CFiT5q076684@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: e2ec8ee02a33 - main - uniq: Clean up and test obsolete options. 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: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: e2ec8ee02a33e39b8ff86a56e8a1ef5e84ac7e62 Auto-Submitted: auto-generated The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=e2ec8ee02a33e39b8ff86a56e8a1ef5e84ac7e62 commit e2ec8ee02a33e39b8ff86a56e8a1ef5e84ac7e62 Author: Dag-Erling Smørgrav AuthorDate: 2024-01-12 15:40:40 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-01-12 15:44:00 +0000 uniq: Clean up and test obsolete options. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D43402 --- usr.bin/uniq/tests/uniq_test.sh | 3 +++ usr.bin/uniq/uniq.c | 14 +++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/usr.bin/uniq/tests/uniq_test.sh b/usr.bin/uniq/tests/uniq_test.sh index 8dc2015734f6..537962eb6513 100755 --- a/usr.bin/uniq/tests/uniq_test.sh +++ b/usr.bin/uniq/tests/uniq_test.sh @@ -74,6 +74,7 @@ skip_fields_head() { skip_fields_body() { printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input printf "1 a\n3 b\n5 a\n" >expected + atf_check_uniq -1 atf_check_uniq -f 1 atf_check_uniq --skip-fields 1 } @@ -85,6 +86,7 @@ skip_fields_tab_head() { skip_fields_tab_body() { printf "1\ta\n2\ta\n3\tb\n4\tb\n5\ta\n6\ta\n" >input printf "1\ta\n3\tb\n5\ta\n" >expected + atf_check_uniq -1 atf_check_uniq -f 1 atf_check_uniq --skip-fields 1 } @@ -107,6 +109,7 @@ skip_chars_head() { skip_chars_body() { printf "1 a\n2 a\n3 b\n4 b\n5 a\n6 a\n" >input printf "1 a\n3 b\n5 a\n" >expected + atf_check_uniq +2 atf_check_uniq -s 2 atf_check_uniq --skip-chars 2 } diff --git a/usr.bin/uniq/uniq.c b/usr.bin/uniq/uniq.c index 0bc9b2b86af3..ef59d7339d0c 100644 --- a/usr.bin/uniq/uniq.c +++ b/usr.bin/uniq/uniq.c @@ -338,29 +338,25 @@ file(const char *name, const char *mode) static void obsolete(char *argv[]) { - int len; - char *ap, *p, *start; + char *ap, *p; while ((ap = *++argv)) { /* Return if "--" or not an option of any form. */ if (ap[0] != '-') { if (ap[0] != '+') return; - } else if (ap[1] == '-') + } else if (ap[1] == '-') { return; + } if (!isdigit((unsigned char)ap[1])) continue; /* * Digit signifies an old-style option. Malloc space for dash, * new option and argument. */ - len = strlen(ap); - if ((start = p = malloc(len + 3)) == NULL) + if (asprintf(&p, "-%c%s", ap[0] == '+' ? 's' : 'f', ap + 1) < 0) err(1, "malloc"); - *p++ = '-'; - *p++ = ap[0] == '+' ? 's' : 'f'; - (void)strcpy(p, ap + 1); - *argv = start; + *argv = p; } }