From nobody Tue Feb 13 15:14:48 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 4TZ4cv6xxDz5BVwm for ; Tue, 13 Feb 2024 15:14:55 +0000 (UTC) (envelope-from pfg@freebsd.org) Received: from sonic301-31.consmr.mail.ne1.yahoo.com (sonic301-31.consmr.mail.ne1.yahoo.com [66.163.184.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4TZ4cv4wXfz4ZB4 for ; Tue, 13 Feb 2024 15:14:55 +0000 (UTC) (envelope-from pfg@freebsd.org) Authentication-Results: mx1.freebsd.org; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1707837293; bh=b15CkXVXUQhJf3tFELai4RLB69958/safd2j3Z1PRJ0=; h=Date:From:To:In-Reply-To:References:Subject:From:Subject:Reply-To; b=Ab9Rnnodz2rel9JwCSnmw2gp7lsxcy3A8ubwdNXJSj2Tei8YrqxhaIUfAsTEoLQSVoftjystgDAVohQr5bgftfDw2xCvt4EJlVXA/qaWifKSepO9xOUjnhrVfvDiBnMubV1kSufLdLf2ObaeUE7cduOpfLu5qlT3M+gGm+GcJFFn5RyB/q7LBtmFNc67z1oOHI+fIo71brtbW6zMFbLLZinTNPbELGhEKrmZhZHccvyRJn8Us5FSo1EWaI4QECLG4U6NVSlPHAzeo99UMMMeEz0GVXErQfZITqAwkWR+9h0A/LBdp8z+G6kxgzIdKvSbZOL0tgD+OEEo9MZAV4EbUw== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1707837293; bh=gotXTHp1QKLC1cn8JpTvKeAopo4W+wbGga1e7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ODtIfCJ_SOqXxl1g2V67KSztVyK6Iz3A9el3IhDljxsezuabV5KkL_hP4EBVbnFGl91e SryMkPWploO2afxe4vfYHDX7RUhTNSHEggWs2QpWe6GwCKyoPJpkyOB13Gd58SL8yC7dmJqLxXvV Dq4ZW4qfD6uO_xEIZarPq9rqyMXdaY4_uLNT.bLE5a3W7nFVi4AvwzZpt4vWHKJh1xHYK4K2fYJC fgLAZ.nZT8FGq6t1GAqpZOul7TnTvk4lSeU9os81sT4LoCfwXi5kvs37sZ2tVjH1gbUvRvkAxwW. LtX2VL675xJMR5vzv5IWrLG9VLRnCE6FgT1S7RYYwMmDHbPqkJQSwCpzs9HagZmnKxXfM5owXgoO zceMxrjNrdi62kCxQXjwMit15bE3qKUepkUvYFj.bYSVrbekFUpXc1qD0joH9DUQwA6Kh1tM7xjJ LiTddUk4chK1vsbjM9jh4d8Fu38Lmnw-- X-Sonic-MF: X-Sonic-ID: 9ea47e50-25f3-4504-9d7d-8ad52725b0fd Received: from sonic.gate.mail.ne1.yahoo.com by sonic301.consmr.mail.ne1.yahoo.com with HTTP; Tue, 13 Feb 2024 15:14:53 +0000 Date: Tue, 13 Feb 2024 15:14:48 +0000 (UTC) From: Pedro Giffuni To: "src-committers@freebsd.org" , "dev-commits-src-all@freebsd.org" , =?UTF-8?Q?Dag-Erling_Sm=C3=B8rgrav?= Message-ID: <1620767053.1846857.1707837288566@mail.yahoo.com> In-Reply-To: <202402121826.41CIQUk5080390@gitrepo.freebsd.org> References: <202402121826.41CIQUk5080390@gitrepo.freebsd.org> Subject: Re: git: 851a9da38f07 - main - patch: Support long context lines. 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: multipart/alternative; boundary="----=_Part_1846856_2104703329.1707837288562" X-Mailer: WebService/1.1.22077 YMailNorrin X-Spamd-Result: default: False [-4.00 / 15.00]; REPLY(-4.00)[]; ASN(0.00)[asn:36646, ipnet:66.163.184.0/21, country:US] X-Rspamd-Queue-Id: 4TZ4cv4wXfz4ZB4 X-Spamd-Bar: ---- X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated ------=_Part_1846856_2104703329.1707837288562 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable FWIW ... We were already supporting very long lines. There was a thread like ages ag= o about not making them unnecessarily longer. But I doubt anyone cares about that anymore ;). Pedro. On Monday, February 12, 2024 at 01:26:38 PM GMT-5, Dag-Erling Sm=C3=B8r= grav wrote: =20 =20 The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=3D851a9da38f070675c42a6d69c41c= 47a5d29ee3d0 commit 851a9da38f070675c42a6d69c41c47a5d29ee3d0 Author:=C2=A0 =C2=A0 Dag-Erling Sm=C3=B8rgrav AuthorDate: 2024-02-12 18:26:13 +0000 Commit:=C2=A0 =C2=A0 Dag-Erling Sm=C3=B8rgrav CommitDate: 2024-02-12 18:26:13 +0000 =C2=A0 =C2=A0 patch: Support long context lines. =C2=A0 =C2=A0=20 =C2=A0 =C2=A0 MFC after:=C2=A0 =C2=A0 =C2=A0 1 week =C2=A0 =C2=A0 Sponsored by:=C2=A0 Klara, Inc. =C2=A0 =C2=A0 Reviewed by:=C2=A0 =C2=A0 allanjude =C2=A0 =C2=A0 Differential Revision:=C2=A0 https://reviews.freebsd.org/D438= 50 --- usr.bin/patch/patch.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 |=C2=A0 2 +- usr.bin/patch/pch.c=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 | 10 +++++----- usr.bin/patch/pch.h=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 |=C2=A0 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 403189bc92b1..838c721841ea 100644 --- a/usr.bin/patch/patch.c +++ b/usr.bin/patch/patch.c @@ -1085,7 +1085,7 @@ patch_match(LINENUM base, LINENUM offset, LINENUM fuz= z) =C2=A0=C2=A0=C2=A0 LINENUM=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 pat_lines = =3D pch_ptrn_lines() - fuzz; =C2=A0=C2=A0=C2=A0 const char=C2=A0=C2=A0=C2=A0 *ilineptr; =C2=A0=C2=A0=C2=A0 const char=C2=A0=C2=A0=C2=A0 *plineptr; -=C2=A0=C2=A0=C2=A0 unsigned short=C2=A0=C2=A0=C2=A0 plinelen; +=C2=A0=C2=A0=C2=A0 size_t=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 plinelen; =20 =C2=A0=C2=A0=C2=A0 /* Patch does not match if we don't have any more conte= xt to use */ =C2=A0=C2=A0=C2=A0 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=C2=A0=C2=A0=C2=A0 p_max;=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 /* max allowed value of p_end */ static LINENUM=C2=A0=C2=A0=C2=A0 p_context =3D 3;=C2=A0=C2=A0=C2=A0 /* # o= f context lines */ static LINENUM=C2=A0=C2=A0=C2=A0 p_input_line =3D 0;=C2=A0=C2=A0=C2=A0 /* = current line # from patch file */ static char=C2=A0=C2=A0=C2=A0 **p_line =3D NULL;/* the text of the hunk */ -static unsigned short=C2=A0=C2=A0=C2=A0 *p_len =3D NULL; /* length of each= line */ +static size_t=C2=A0=C2=A0=C2=A0 *p_len =3D NULL;=C2=A0=C2=A0=C2=A0 /* leng= th of each line */ static char=C2=A0=C2=A0=C2=A0 *p_char =3D NULL;=C2=A0=C2=A0=C2=A0 /* +, -,= and ! */ static int=C2=A0=C2=A0=C2=A0 hunkmax =3D INITHUNKMAX;=C2=A0=C2=A0=C2=A0 /*= size of above arrays to begin with */ static int=C2=A0=C2=A0=C2=A0 p_indent;=C2=A0=C2=A0=C2=A0 /* indent to patc= h */ @@ -137,7 +137,7 @@ set_hunkmax(void) =C2=A0=C2=A0=C2=A0 if (p_line =3D=3D NULL) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 p_line =3D malloc(hunkmax * sizeof(c= har *)); =C2=A0=C2=A0=C2=A0 if (p_len =3D=3D NULL) -=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 p_len =3D malloc(hunkmax * sizeof(un= signed short)); +=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 p_len =3D malloc(hunkmax * sizeof(si= ze_t)); =C2=A0=C2=A0=C2=A0 if (p_char =3D=3D NULL) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 p_char =3D malloc(hunkmax * sizeof(c= har)); } @@ -154,7 +154,7 @@ grow_hunkmax(void) =C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 fatal("Internal memory allocation er= ror\n"); =20 =C2=A0=C2=A0=C2=A0 p_line =3D reallocf(p_line, new_hunkmax * sizeof(char *= )); -=C2=A0=C2=A0=C2=A0 p_len =3D reallocf(p_len, new_hunkmax * sizeof(unsigned= short)); +=C2=A0=C2=A0=C2=A0 p_len =3D reallocf(p_len, new_hunkmax * sizeof(size_t))= ; =C2=A0=C2=A0=C2=A0 p_char =3D reallocf(p_char, new_hunkmax * sizeof(char))= ; =20 =C2=A0=C2=A0=C2=A0 if (p_line !=3D NULL && p_len !=3D NULL && p_char !=3D = NULL) { @@ -1251,7 +1251,7 @@ bool pch_swap(void) { =C2=A0=C2=A0=C2=A0 char=C2=A0=C2=A0=C2=A0 **tp_line;=C2=A0=C2=A0=C2=A0 /* = the text of the hunk */ -=C2=A0=C2=A0=C2=A0 unsigned short=C2=A0=C2=A0=C2=A0 *tp_len;/* length of e= ach line */ +=C2=A0=C2=A0=C2=A0 size_t=C2=A0=C2=A0=C2=A0 *tp_len;=C2=A0=C2=A0=C2=A0 /* = length of each line */ =C2=A0=C2=A0=C2=A0 char=C2=A0=C2=A0=C2=A0 *tp_char;=C2=A0=C2=A0=C2=A0 /* += , -, and ! */ =C2=A0=C2=A0=C2=A0 LINENUM=C2=A0=C2=A0=C2=A0 i; =C2=A0=C2=A0=C2=A0 LINENUM=C2=A0=C2=A0=C2=A0 n; @@ -1408,7 +1408,7 @@ pch_context(void) /* =C2=A0 * Return the length of a particular patch line. =C2=A0 */ -unsigned short +size_t pch_line_len(LINENUM line) { =C2=A0=C2=A0=C2=A0 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=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 there_is_anothe= r_patch(void); bool=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 another_hunk(void); bool=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 pch_swap(void); char=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 *pfetch(LINENUM); -unsigned short=C2=A0=C2=A0=C2=A0 pch_line_len(LINENUM); +size_t=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 pch_line_len(LINENUM); LINENUM=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 pch_first(void); LINENUM=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 pch_ptrn_lines(void); LINENUM=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 pch_newfirst(void); diff --git a/usr.bin/patch/tests/unified_patch_test.sh b/usr.bin/patch/test= s/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() =C2=A0=C2=A0=C2=A0 atf_check -o inline:"y\n" cat foo } =20 +atf_test_case plinelen +plinelen_body() +{ +=C2=A0=C2=A0=C2=A0 hello=3D"$(jot -b hello -s, 20000 | tee foo.txt)" +=C2=A0=C2=A0=C2=A0 cp foo.txt bar.txt +=C2=A0=C2=A0=C2=A0 echo "world" >>bar.txt +=C2=A0=C2=A0=C2=A0 cat >foo.diff <
FWIW ...

We were alr= eady supporting very long lines. There was a thread like ages ago about not= making them unnecessarily longer.

But I doubt anyone cares about t= hat anymore ;).

Pedro.


=20
=20
On Monday, February 12, 2024 at 01:26:38 PM GMT-5, Dag-= Erling Sm=C3=B8rgrav <des@freebsd.org> wrote:


The branch main has been updated by d= es:


commit 851a9da38f070675c42a6d69c41c47a5d29e= e3d0
Author:    Dag-Erling Sm=C3=B8rgr= av <des@FreeBSD.org>
AuthorDate: 2024-02-12 = 18:26:13 +0000
Commit:    Dag-Erling S= m=C3=B8rgrav <des@FreeBSD.org>
CommitDate: 2= 024-02-12 18:26:13 +0000

    patch: Support long context lines.
   
    MFC after:  =     1 week
    Sponsored by:&= nbsp; Klara, Inc.
    Reviewed by:&nbs= p;   allanjude
    Differential Re= vision:  https://reviews.freebsd.org/D43850
---
usr.bin/patch/patch.c   = ;                 |  2 +-
=
usr.bin/patch/pch.c        &nbs= p;             | 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 403189bc92b= 1..838c721841ea 100644
--- a/usr.bin/patch/patch.= c
+++ b/usr.bin/patch/patch.c
@@ -1085,7 +1085,7 @@ patch_match(LINENUM base, LINENUM offset, LI= NENUM fuzz)
    LINENUM &nbs= p;      pat_lines =3D pch_ptrn_lines() - fuzz;
    const char    *ilinept= r;
    const char  &nbs= p; *plineptr;
-    unsigned short&= nbsp;   plinelen;
+    s= ize_t        plinelen;

    /* Patch does not match= if we don't have any more context to use */
&nb= sp;   if (pline > pat_lines)
diff --= git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c
i= ndex 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 =3D 3;&n= bsp;   /* # of context lines */
static= LINENUM    p_input_line =3D 0;    /* current= line # from patch file */
static char &nbs= p;  **p_line =3D NULL;/* the text of the hunk */
-static unsigned short    *p_len =3D NULL; /* length of= each line */
+static size_t    *p= _len =3D NULL;    /* length of each line */
static char    *p_char =3D NULL;   = ; /* +, -, and ! */
static int   = hunkmax =3D INITHUNKMAX;    /* size of above arrays to begi= n with */
static int    p_indent;=     /* indent to patch */
@@ -137,= 7 +137,7 @@ set_hunkmax(void)
   = if (p_line =3D=3D NULL)
    &nbs= p;   p_line =3D malloc(hunkmax * sizeof(char *));
    if (p_len =3D=3D NULL)
-        p_len =3D malloc(hunkmax * size= of(unsigned short));
+     &n= bsp;  p_len =3D malloc(hunkmax * sizeof(size_t));
    if (p_char =3D=3D NULL)
        p_char =3D malloc(hunkmax * sizeof(= char));
}
@@ -154,7 +1= 54,7 @@ grow_hunkmax(void)
    &n= bsp;   fatal("Internal memory allocation error\n");

    p_line =3D rea= llocf(p_line, new_hunkmax * sizeof(char *));
-&nb= sp;   p_len =3D reallocf(p_len, new_hunkmax * sizeof(unsigned sho= rt));
+    p_len =3D reallocf(p_le= n, new_hunkmax * sizeof(size_t));
  &n= bsp; p_char =3D reallocf(p_char, new_hunkmax * sizeof(char));

    if (p_line != =3D NULL && p_len !=3D NULL && p_char !=3D NULL) {
@@ -1251,7 +1251,7 @@ bool
pch= _swap(void)
{
 &= nbsp;  char    **tp_line;    /* the text= of the hunk */
-    unsigned shor= t    *tp_len;/* length of each line */
+    size_t    *tp_len;   = ; /* length of each line */
    c= har    *tp_char;    /* +, -, and ! */
    LINENUM    i;
    LINENUM    n;
@@ -1408,7 +1408,7 @@ pch_context(void)
/*
  * Return the length of a par= ticular 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/pat= ch/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    &nbs= p;   pch_line_len(LINENUM);
LINENUM&nb= sp;       pch_first(void);
LINENUM        pch_ptrn_lines(void);
<= /div>
LINENUM        pch_new= first(void);
diff --git a/usr.bin/patch/tests/uni= fied_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()
&nbs= p;   atf_check -o inline:"y\n" cat foo
= }

+atf_test_case pli= nelen
+plinelen_body()
= +{
+    hello=3D"$(jot -b hello -s= , 20000 | tee foo.txt)"
+    cp fo= o.txt bar.txt
+    echo "world" &g= t;>bar.txt
+    cat >foo.dif= f <<EOF
+--- foo.txt.orig
++++ foo.txt
+@@ -1,1 +1,2 @@
<= div dir=3D"ltr">+ $hello
++world
+EOF
+    atf_check -o m= atch:"Hunk #1 succeeded" \
+    &n= bsp;     patch <foo.diff
+ = ;   atf_check -o file:bar.txt cat foo.txt
+}
+
atf_init_test_= cases()
{
  = ;  atf_add_test_case basic
@@ -148,4 +166,5 = @@ atf_init_test_cases()
    atf_= add_test_case file_creation
    a= tf_add_test_case file_nodupe
    = atf_add_test_case file_removal
+   = ; atf_add_test_case plinelen
}
------=_Part_1846856_2104703329.1707837288562--