From nobody Mon Aug 01 13:56:47 2022 X-Original-To: dev-commits-src-main@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 4LxKRg4Gxdz4XqGr; Mon, 1 Aug 2022 13:56:47 +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 4LxKRg3pWgz45hh; Mon, 1 Aug 2022 13:56:47 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659362207; 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=qAhYP417fDXM5l3WzLy7wr67vpwmH7Ha++VkdhnFxa8=; b=lorCgZwl37Y8KuiXgjdVH3/BtltNTe2Ejzjf4VweBH/wZPOyBYADDU9siZamAkv3LdWRo9 IOSMX/OQWd0DFj8F9qF38pawJ562AFk7qHXGfYLw1gPQ009q5hzgeX85JpcQWob+Svc7WK G+DUNjFckYszkoCnwL+V6nXMA4PErt6aMGaqjWwdnaGB/r6eZsb9KRTkzUp2gpz1balRk9 hN5w+jfLz+EQUZAJNMa5ZjFdWJXHouHoAppfvPPHKqml8LAGsXLBeKn32Fx0KUCyMkto4E fq2vC6dB3NX5ymggf9YU3nGPbfygx46fjjQGMIjuqfipEFDRLufE4gCkRpWrRw== 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 4LxKRg2gf3zbbm; Mon, 1 Aug 2022 13:56:47 +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 271Dulqj097623; Mon, 1 Aug 2022 13:56:47 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 271DulVK097622; Mon, 1 Aug 2022 13:56:47 GMT (envelope-from git) Date: Mon, 1 Aug 2022 13:56:47 GMT Message-Id: <202208011356.271DulVK097622@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: 2c4276aaa2d0 - main - diff3: Use variables for old and new in A scripts List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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: 2c4276aaa2d03217b9c1797196864bbbe4f2d8ea Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1659362207; 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=qAhYP417fDXM5l3WzLy7wr67vpwmH7Ha++VkdhnFxa8=; b=ZgbhB6I6LCgdNzvmXcUbUwDkbnsz+Puo0+Og0pXoJXSRI/q0NB+FrGpvf+lU1DatL9y0ZT //ADE09D0mfFMZuD/UUHqagOAEFVoTjhBGUcDQ/x4nXvvG2gqQRLPPi5C60nIZywAMLjN/ ttVr7SmEvWm1QlWB9yaa5fwNBvElDVa0KTQgu7laXx0yBld5VE+qwULDQBm5O0wqKfKH6P pZm5fG2Lu39AYKXQxtb6I+RrfZ2EXATz0m6cB+xsqbj3kXMCXvth30fS8gsV1uXW5SnZYx 651uhAgpAsw+3l0VRO6wBWB+paZg0+rVb5v/R6076MqRHBPpLcXsgwbzg6iHjQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1659362207; a=rsa-sha256; cv=none; b=FnVWDj6JgS/44RyUhHuaPBEBONEBOjSzhqsjW3xj1M6i0pRwXiEzSFBrQgPvvigpOwBD9t wrGeSGMuIjfMeiNHYF/chXlcYQfQ7w0tu743rcsCzt1HUTRcCK+rUZGKB97aCc/1jHrlh3 nsFRWh+o2LcBOh5r72WTS95s66iZLG7LDxfYa78E1sCdtW5pQcrTIhCoaAdo+SlFP0kn60 tLOLrlU//4eYBXHRQaC0PKqNiiaqtFFY9QIFJ8jk7GTsMPYTU62J7mMAk8JobtCBTlTJYd Nv+AJ7IEnDhY5cSqn0QUSyNCzJIP/3vf/2Uall3QWNh/3754+IR0SXofWHnh0A== 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=2c4276aaa2d03217b9c1797196864bbbe4f2d8ea commit 2c4276aaa2d03217b9c1797196864bbbe4f2d8ea Author: Tom Jones AuthorDate: 2022-08-01 13:48:35 +0000 Commit: Tom Jones CommitDate: 2022-08-01 13:54:20 +0000 diff3: Use variables for old and new in A scripts This makes the code easier to follow, no functional changes intended Sponsored by: Klara, Inc. --- usr.bin/diff3/diff3.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/usr.bin/diff3/diff3.c b/usr.bin/diff3/diff3.c index 7adb9b5c5043..ff8d03007e4e 100644 --- a/usr.bin/diff3/diff3.c +++ b/usr.bin/diff3/diff3.c @@ -631,19 +631,21 @@ Ascript(int n) bool deletenew; bool deleteold; - for (; n > 0; n--) { + struct range *new, *old; - deletenew = (de[n].new.from == de[n].new.to); - deleteold = (de[n].old.from == de[n].old.to); - startmark = de[n].old.from + (de[n].old.to - de[n].old.from) - 1; + for (; n > 0; n--) { + new = &de[n].new; + old = &de[n].old; + deletenew = (new->from == new->to); + deleteold = (old->from == old->to); + startmark = old->from + (old->to - old->from) - 1; if (de[n].type == DIFF_TYPE2) { if (!oflag || !overlap[n]) { - prange(&de[n].old, deletenew); - printrange(fp[2], &de[n].new); + prange(old, deletenew); + printrange(fp[2], new); } else { - startmark = de[n].new.from + - (de[n].new.to - de[n].new.from); + startmark = new->from + (new->to - new->from); if (!deletenew) startmark--; @@ -654,31 +656,31 @@ Ascript(int n) printf(".\n"); printf("%da\n", startmark - - (de[n].new.to - de[n].new.from)); + (new->to - new->from)); printf("%s %s\n", oldmark, f2mark); if (!deleteold) - printrange(fp[1], &de[n].old); + printrange(fp[1], old); printf("%s\n.\n", divider); } } else if (de[n].type == DIFF_TYPE3) { if (!oflag || !overlap[n]) { - prange(&de[n].old, deletenew); - printrange(fp[2], &de[n].new); + prange(old, deletenew); + printrange(fp[2], new); } else { printf("%da\n", startmark); printf("%s %s\n", orgmark, f2mark); if (deleteold) { struct range r; - r.from = de[n].old.from-1; - r.to = de[n].new.to; + r.from = old->from-1; + r.to = new->to; printrange(fp[1], &r); } else - printrange(fp[1], &de[n].old); + printrange(fp[1], old); printf("%s\n", divider); - printrange(fp[2], &de[n].new); + printrange(fp[2], new); } if (!oflag || !overlap[n]) { @@ -692,7 +694,7 @@ Ascript(int n) * file and append lines */ printf("%da\n%s %s\n.\n", - startmark - (de[n].old.to - de[n].old.from), + startmark - (old->to - old->from), oldmark, f1mark); } }