From nobody Wed May 25 14:08:41 2022 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 31D6D1B4C629; Wed, 25 May 2022 14:08:42 +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 4L7Xwn5mHqz3llX; Wed, 25 May 2022 14:08:41 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653487721; 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=Uiqtmiuc3WJdfg4cX/uU6vfQg/24Iqwn2fmOfWpVXtk=; b=q+NN1yvB/e1JUiq644t0W0rfC8OiBRG4PQ+2MfTR2jjndcSIJms+31Ny62T2SXhqZiRZE0 gn4z9SG8lGuWvteSsdrUWUilgVP5b8zWdiuxD2FZ0umPuwK40NKDEzSRE2GaMKL2bxb3Rn GKO5a4LuxYQqazwgcJURttT/Fj2jWj+mcYd2x+jb1oqh+8fL+ds7z+5cVi0cVdfr64P12U fQW+6i8V7lsTyDcoOEgzTEofc4BFlQpyi+Qf8w83/LQxVQFp+Daw0pVjwxQr50oY0xV22W 4Tdgk6Y0EgZPFcuUih+UpP6qK4gcAl2Vj/bC2hBtf2eI8yrKuCBeraKTEPnQqg== 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 606AB1ABF1; Wed, 25 May 2022 14:08:41 +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 24PE8fLZ025114; Wed, 25 May 2022 14:08:41 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24PE8fwL025113; Wed, 25 May 2022 14:08:41 GMT (envelope-from git) Date: Wed, 25 May 2022 14:08:41 GMT Message-Id: <202205251408.24PE8fwL025113@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Tom Jones Subject: git: 3ddd6eb688af - main - diff3: Add help and version 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: thj X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3ddd6eb688af37e03cd6d56be4e0400362a179f7 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653487721; 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=Uiqtmiuc3WJdfg4cX/uU6vfQg/24Iqwn2fmOfWpVXtk=; b=rkynmb7yoPwwT/vXRvjjvASSlZqrvV9FhscEw2xlYRMpspFEWqaHzhY9URxXOAJDvHwU4A gNGjyOgmuDhl6XEbLkIf6ICuVP9gShtZyqLZ6HYZ+4tHodRJpSiwEc+8dpizybpPzi610f 3pcSy2VQEPlVIfDoDXjzTRO9eI64MSNWgccSmlLYrLBIjMY9Nijjasg9+DfQ+fIYKFHglJ v4A2CAOhgtjyrw7+plssPlD4qYzT7TVbst+byLLusk8XBSdgc51iAAgsBRJi+KgyY6t1Tn Hw4hyt9XD0UW8lVmwlvuMDpjQ5aQwzzKFxUJyTTfnQMezXUy/PRmmynE7jTcEQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653487721; a=rsa-sha256; cv=none; b=j9kJE5sl5MIPQjnudZAslLaWxg1mmOlWapwmEGHRczrHqKZv1uXXGg7ALmL5vTZflNF5vM 0MVbe7ZZLOE25i/1LuFxo7gK1toR4Tz3FMShO4PxjvW5VGqIchTGB0z7NGfMxk2/+e0Z86 vGMTzCJBD67CXjdxD9rwO9klPkKg9IagNdPK9SWceV/ujpRgA3qvo9tmiUn5Sml+WWcmc9 aUBNaNN0V1subPGP8sKyh29gqB9tFJnzR3NG5pmddoocMFXV+3TyOdr3rtzJKiill4A8D7 2dq3wmNKiP/5urgX2p2pvegh0vTwiRaTwMobfNixtRUkAt5ezvDYjWC12d52BQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by thj: URL: https://cgit.FreeBSD.org/src/commit/?id=3ddd6eb688af37e03cd6d56be4e0400362a179f7 commit 3ddd6eb688af37e03cd6d56be4e0400362a179f7 Author: Tom Jones AuthorDate: 2022-05-25 13:53:06 +0000 Commit: Tom Jones CommitDate: 2022-05-25 13:53:06 +0000 diff3: Add help and version options Add help and version flags. Exit values in these paths are set to match the behaviour of gnu diff3. --- usr.bin/diff3/diff3.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index a6d765ce0f75..860af98d13e2 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -155,12 +155,16 @@ static void edscript(int) __dead2; static void Ascript(int) __dead2; static void mergescript(int) __dead2; static void increase(void); -static void usage(void) __dead2; +static void usage(void); static void printrange(FILE *, struct range *); +static const char diff3_version[] = "FreeBSD diff3 20220517"; + enum { DIFFPROG_OPT, STRIPCR_OPT, + HELP_OPT, + VERSION_OPT }; #define DIFF_PATH "/usr/bin/diff" @@ -178,6 +182,8 @@ static struct option longopts[] = { { "merge", no_argument, NULL, 'm' }, { "label", required_argument, NULL, 'L' }, { "diff-program", required_argument, NULL, DIFFPROG_OPT }, + { "help", no_argument, NULL, HELP_OPT}, + { "version", no_argument, NULL, VERSION_OPT} }; static void @@ -185,7 +191,6 @@ usage(void) { fprintf(stderr, "usage: diff3 [-3aAeEimTxX] [-L label1] [-L label2] " "[-L label3] file1 file2 file3\n"); - exit(2); } static int @@ -872,6 +877,12 @@ main(int argc, char **argv) strip_cr = 1; diffargv[diffargc++] = __DECONST(char *, "--strip-trailing-cr"); break; + case HELP_OPT: + usage(); + exit(0); + case VERSION_OPT: + printf("%s\n", diff3_version); + exit(0); } } argc -= optind; @@ -882,8 +893,10 @@ main(int argc, char **argv) oflag = 1; } - if (argc != 3) + if (argc != 3) { usage(); + exit(2); + } if (caph_limit_stdio() == -1) err(2, "unable to limit stdio");