From nobody Sat Feb 24 12:15:00 2024 X-Original-To: dev-commits-src-branches@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 4Thm6F1grQz5Cf98; Sat, 24 Feb 2024 12:15:01 +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 4Thm6F0SH0z4pB6; Sat, 24 Feb 2024 12:15:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708776901; 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=HH1D8t1vNXytuOEsC50C9ty7JfzbFYX/Nv1ze0AkeHY=; b=PuT9X5mFaDIOsiyi1rtXBz9T1PA2ZCgv5YslDQRbdpeFqD06sDlzz89xbOfsBZQGiEeQgJ gJ826xI5xYmGbppTjbwle6/Tia6hTDY/qV87SxRbOifQnqiccNsHkB+1SC7ItWz/DgslGi 4Ec6A/dYSIzujvDIsdNgXl5XsHLUyjo2/i2EnH493VVHbKpLu7lVn9L9pigMFA50CWPI1q PkjP0e3pyTxHUEuo6eORBzxfPOvOm1fSE2RGRMdotX62xaQQYjKRbbvOX2XzB3QqrMUda7 u9mN1tgAdpZu+YUVv5A+Nb7gr3ya033AnmNulB6FZgoPRvGkJv0sXJshfs4wpg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1708776901; a=rsa-sha256; cv=none; b=qBEzn3Cyf7zi74/Yff7wBU8wvFgjIsf+oVsChZLS2DU5pBTpw33Z4EsWkNgFN3OV3dleIp uC5yt9gvwQbtfNeTE8CmYuRoNYdaqB+RjMkuUmpq9V80wIujIN8y821Ffq6G4YmviXrFQL lLyrIxXEJjWwEPwQdFcO0JZr3XK7Wz9lsJT8AXwCTEfan6Lyw7gTwQZ+ApQHsFENlHAFzx 7WMGXTyNQVNvwVHJCh2llC5Svphg1CtE/LXt0IQxHMWoOwJoHbfe3+xPsNsUAXT/HVOFaG 5VmVUt6VXS1lvu0ftMU1ykWZtYVZ46yIYm8I4BN7ScJKKVgxp3IB98Q8Pe1iEA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1708776901; 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=HH1D8t1vNXytuOEsC50C9ty7JfzbFYX/Nv1ze0AkeHY=; b=XhI/TmGq6x1GLgZlVop7/ZBdthynW0X5FC9b10aj/l08uf2OkgrvrJyAH+a4V0Jy6ifYs0 wgu77crwtDf42wppBdBuQJss9BWlBfRenEeHumowDZdF9QxgHnVpUAQC4UmG23y/7wEdYK sxc+C7NDDlvSwrKi/e9StYvTE9NjMjDJNs/9aXiqwRTOSKUvEzdLeEyu5l8RFJM+eCJUcX Tv2C+lOjLgN1Tt0iTyu0jo27EjCCBnzlpQIIzGloy4CrAAkdoNDWQgVsW0D306CNK6DR3O s9dq3uITjpOcc3A4LFgjHsXCo9IQyq4g1zI6/qWz7+cA0YksxtenMa7gtRGjzg== 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 4Thm6D6d6Rz10Q3; Sat, 24 Feb 2024 12:15:00 +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 41OCF0dq085108; Sat, 24 Feb 2024 12:15:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41OCF0ZM085105; Sat, 24 Feb 2024 12:15:00 GMT (envelope-from git) Date: Sat, 24 Feb 2024 12:15:00 GMT Message-Id: <202402241215.41OCF0ZM085105@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dag-Erling =?utf-8?Q?Sm=C3=B8rgrav?= Subject: git: 4ffc5ab03f83 - stable/14 - patch: Support long context lines. List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/14 X-Git-Reftype: branch X-Git-Commit: 4ffc5ab03f8370dcffb1d0bb968e2152348cc709 Auto-Submitted: auto-generated The branch stable/14 has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=4ffc5ab03f8370dcffb1d0bb968e2152348cc709 commit 4ffc5ab03f8370dcffb1d0bb968e2152348cc709 Author: Dag-Erling Smørgrav AuthorDate: 2024-02-12 18:26:13 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2024-02-24 12:12:49 +0000 patch: Support long context lines. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D43850 (cherry picked from commit 851a9da38f070675c42a6d69c41c47a5d29ee3d0) --- usr.bin/patch/patch.c | 2 +- usr.bin/patch/pch.c | 10 +++++----- usr.bin/patch/pch.h | 2 +- usr.bin/patch/tests/unified_patch_test.sh | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/usr.bin/patch/patch.c b/usr.bin/patch/patch.c index ecaf799fe9b6..92ea4973e8f6 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1083,7 +1083,7 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuzz) LINENUM pat_lines = pch_ptrn_lines() - fuzz; const char *ilineptr; const char *plineptr; - unsigned short plinelen; + size_t plinelen; /* Patch does not match if we don't have any more context to use */ if (pline > pat_lines) diff --git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c index d528f06235bf..fb53ff86f9ef 100644 --- a/usr.bin/patch/pch.c +++ b/usr.bin/patch/pch.c @@ -55,7 +55,7 @@ static LINENUM p_max; /* max allowed value of p_end */ static LINENUM p_context = 3; /* # of context lines */ static LINENUM p_input_line = 0; /* current line # from patch file */ static char **p_line = NULL;/* the text of the hunk */ -static unsigned short *p_len = NULL; /* length of each line */ +static size_t *p_len = NULL; /* length of each line */ static char *p_char = NULL; /* +, -, and ! */ static int hunkmax = INITHUNKMAX; /* size of above arrays to begin with */ static int p_indent; /* indent to patch */ @@ -137,7 +137,7 @@ set_hunkmax(void) if (p_line == NULL) p_line = malloc(hunkmax * sizeof(char *)); if (p_len == NULL) - p_len = malloc(hunkmax * sizeof(unsigned short)); + p_len = malloc(hunkmax * sizeof(size_t)); if (p_char == NULL) p_char = malloc(hunkmax * sizeof(char)); } @@ -154,7 +154,7 @@ grow_hunkmax(void) fatal("Internal memory allocation error\n"); p_line = reallocf(p_line, new_hunkmax * sizeof(char *)); - p_len = reallocf(p_len, new_hunkmax * sizeof(unsigned short)); + p_len = reallocf(p_len, new_hunkmax * sizeof(size_t)); p_char = reallocf(p_char, new_hunkmax * sizeof(char)); if (p_line != NULL && p_len != NULL && p_char != NULL) { @@ -1251,7 +1251,7 @@ bool pch_swap(void) { char **tp_line; /* the text of the hunk */ - unsigned short *tp_len;/* length of each line */ + size_t *tp_len; /* length of each line */ char *tp_char; /* +, -, and ! */ LINENUM i; LINENUM n; @@ -1408,7 +1408,7 @@ pch_context(void) /* * Return the length of a particular patch line. */ -unsigned short +size_t pch_line_len(LINENUM line) { return p_len[line]; diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h index 5ce4f72497c7..b6c6363155a5 100644 --- a/usr.bin/patch/pch.h +++ b/usr.bin/patch/pch.h @@ -45,7 +45,7 @@ bool there_is_another_patch(void); bool another_hunk(void); bool pch_swap(void); char *pfetch(LINENUM); -unsigned short pch_line_len(LINENUM); +size_t pch_line_len(LINENUM); LINENUM pch_first(void); LINENUM pch_ptrn_lines(void); LINENUM pch_newfirst(void); diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh index 43b0d8373cfa..7d4b74182c41 100755 --- a/usr.bin/patch/tests/unified_patch_test.sh +++ b/usr.bin/patch/tests/unified_patch_test.sh @@ -141,6 +141,24 @@ file_removal_body() atf_check -o inline:"y\n" cat foo } +atf_test_case plinelen +plinelen_body() +{ + hello="$(jot -b hello -s, 20000 | tee foo.txt)" + cp foo.txt bar.txt + echo "world" >>bar.txt + cat >foo.diff <