Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 13 Feb 2024 15:14:48 +0000 (UTC)
From:      Pedro Giffuni <pfg@freebsd.org>
To:        "src-committers@freebsd.org" <src-committers@freebsd.org>,  "dev-commits-src-all@freebsd.org" <dev-commits-src-all@freebsd.org>,  =?UTF-8?Q?Dag-Erling_Sm=C3=B8rgrav?= <des@FreeBSD.org>
Subject:   Re: git: 851a9da38f07 - main - patch: Support long context  lines.
Message-ID:  <1620767053.1846857.1707837288566@mail.yahoo.com>
In-Reply-To: <202402121826.41CIQUk5080390@gitrepo.freebsd.org>
References:  <202402121826.41CIQUk5080390@gitrepo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
------=_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 <des@freebsd.org> 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 <des@FreeBSD.org>
AuthorDate: 2024-02-12 18:26:13 +0000
Commit:=C2=A0 =C2=A0 Dag-Erling Sm=C3=B8rgrav <des@FreeBSD.org>
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 <<EOF
+--- foo.txt.orig
++++ foo.txt
+@@ -1,1 +1,2 @@
+ $hello
++world
+EOF
+=C2=A0=C2=A0=C2=A0 atf_check -o match:"Hunk #1 succeeded" \
+=C2=A0=C2=A0=C2=A0 =C2=A0=C2=A0=C2=A0 =C2=A0 patch <foo.diff
+=C2=A0=C2=A0=C2=A0 atf_check -o file:bar.txt cat foo.txt
+}
+
 atf_init_test_cases()
 {
 =C2=A0=C2=A0=C2=A0 atf_add_test_case basic
@@ -148,4 +166,5 @@ atf_init_test_cases()
 =C2=A0=C2=A0=C2=A0 atf_add_test_case file_creation
 =C2=A0=C2=A0=C2=A0 atf_add_test_case file_nodupe
 =C2=A0=C2=A0=C2=A0 atf_add_test_case file_removal
+=C2=A0=C2=A0=C2=A0 atf_add_test_case plinelen
 }
 =20
------=_Part_1846856_2104703329.1707837288562
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html><head></head><body><div class=3D"ydp9fe492cdyahoo-style-wrap" style=
=3D"font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px=
;"><div></div>
        <div dir=3D"ltr" data-setdir=3D"false"><div><div dir=3D"ltr" data-s=
etdir=3D"false" style=3D"color: rgb(0, 0, 0); font-family: Helvetica Neue, =
Helvetica, Arial, sans-serif; font-size: 16px;">FWIW ...</div><div dir=3D"l=
tr" data-setdir=3D"false" style=3D"color: rgb(0, 0, 0); font-family: Helvet=
ica Neue, Helvetica, Arial, sans-serif; font-size: 16px;"><br></div><div di=
r=3D"ltr" data-setdir=3D"false" style=3D"color: rgb(0, 0, 0); font-family: =
Helvetica Neue, Helvetica, Arial, sans-serif; font-size: 16px;">We were alr=
eady supporting very long lines. There was a thread like ages ago about not=
 making them unnecessarily longer.</div><div dir=3D"ltr" data-setdir=3D"fal=
se" style=3D"color: rgb(0, 0, 0); font-family: Helvetica Neue, Helvetica, A=
rial, sans-serif; font-size: 16px;"><br></div><div dir=3D"ltr" data-setdir=
=3D"false" style=3D"color: rgb(0, 0, 0); font-family: Helvetica Neue, Helve=
tica, Arial, sans-serif; font-size: 16px;">But I doubt anyone cares about t=
hat anymore ;).</div><div dir=3D"ltr" data-setdir=3D"false" style=3D"color:=
 rgb(0, 0, 0); font-family: Helvetica Neue, Helvetica, Arial, sans-serif; f=
ont-size: 16px;"><br></div><div dir=3D"ltr" data-setdir=3D"false" style=3D"=
color: rgb(0, 0, 0); font-family: Helvetica Neue, Helvetica, Arial, sans-se=
rif; font-size: 16px;">Pedro.</div></div><br></div><div><br></div>
       =20
        </div><div id=3D"ydpa2b2e994yahoo_quoted_8834098867" class=3D"ydpa2=
b2e994yahoo_quoted">
            <div style=3D"font-family:'Helvetica Neue', Helvetica, Arial, s=
ans-serif;font-size:13px;color:#26282a;">
               =20
                <div>
                    On Monday, February 12, 2024 at 01:26:38 PM GMT-5, Dag-=
Erling Sm=C3=B8rgrav &lt;des@freebsd.org&gt; wrote:
                </div>
                <div><br></div>
                <div><br></div>
                <div><div dir=3D"ltr">The branch main has been updated by d=
es:<br></div><div dir=3D"ltr"><br></div><div dir=3D"ltr">URL: <a href=3D"ht=
tps://cgit.FreeBSD.org/src/commit/?id=3D851a9da38f070675c42a6d69c41c47a5d29=
ee3d0" rel=3D"nofollow" target=3D"_blank">https://cgit.FreeBSD.org/src/comm=
it/?id=3D851a9da38f070675c42a6d69c41c47a5d29ee3d0</a><br></div><div dir=3D"=
ltr"><br></div><div dir=3D"ltr">commit 851a9da38f070675c42a6d69c41c47a5d29e=
e3d0<br></div><div dir=3D"ltr">Author:&nbsp; &nbsp;  Dag-Erling Sm=C3=B8rgr=
av &lt;<a href=3D"mailto:des@FreeBSD.org" rel=3D"nofollow" target=3D"_blank=
">des@FreeBSD.org</a>&gt;<br></div><div dir=3D"ltr">AuthorDate: 2024-02-12 =
18:26:13 +0000<br></div><div dir=3D"ltr">Commit:&nbsp; &nbsp;  Dag-Erling S=
m=C3=B8rgrav &lt;<a href=3D"mailto:des@FreeBSD.org" rel=3D"nofollow" target=
=3D"_blank">des@FreeBSD.org</a>&gt;<br></div><div dir=3D"ltr">CommitDate: 2=
024-02-12 18:26:13 +0000<br></div><div dir=3D"ltr"><br></div><div dir=3D"lt=
r">&nbsp; &nbsp; patch: Support long context lines.<br></div><div dir=3D"lt=
r">&nbsp; &nbsp; <br></div><div dir=3D"ltr">&nbsp; &nbsp; MFC after:&nbsp; =
&nbsp; &nbsp; 1 week<br></div><div dir=3D"ltr">&nbsp; &nbsp; Sponsored by:&=
nbsp;  Klara, Inc.<br></div><div dir=3D"ltr">&nbsp; &nbsp; Reviewed by:&nbs=
p; &nbsp; allanjude<br></div><div dir=3D"ltr">&nbsp; &nbsp; Differential Re=
vision:&nbsp; <a href=3D"https://reviews.freebsd.org/D43850" rel=3D"nofollo=
w" target=3D"_blank">https://reviews.freebsd.org/D43850</a><br></div><div d=
ir=3D"ltr">---<br></div><div dir=3D"ltr"> usr.bin/patch/patch.c&nbsp; &nbsp=
; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp; 2 +-<br>=
</div><div dir=3D"ltr"> usr.bin/patch/pch.c&nbsp; &nbsp; &nbsp; &nbsp; &nbs=
p; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  | 10 +++++-----<br></div><div=
 dir=3D"ltr"> usr.bin/patch/pch.h&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  |&nbsp; 2 +-<br></div><div dir=3D"ltr">=
 usr.bin/patch/tests/unified_patch_test.sh | 19 +++++++++++++++++++<br></di=
v><div dir=3D"ltr"> 4 files changed, 26 insertions(+), 7 deletions(-)<br></=
div><div dir=3D"ltr"><br></div><div dir=3D"ltr">diff --git a/usr.bin/patch/=
patch.c b/usr.bin/patch/patch.c<br></div><div dir=3D"ltr">index 403189bc92b=
1..838c721841ea 100644<br></div><div dir=3D"ltr">--- a/usr.bin/patch/patch.=
c<br></div><div dir=3D"ltr">+++ b/usr.bin/patch/patch.c<br></div><div dir=
=3D"ltr">@@ -1085,7 +1085,7 @@ patch_match(LINENUM base, LINENUM offset, LI=
NENUM fuzz)<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; LINENUM&nbsp;&nbs=
p;&nbsp; &nbsp;&nbsp;&nbsp; pat_lines =3D pch_ptrn_lines() - fuzz;<br></div=
><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; const char&nbsp;&nbsp;&nbsp; *ilinept=
r;<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; const char&nbsp;&nbsp;&nbs=
p; *plineptr;<br></div><div dir=3D"ltr">-&nbsp;&nbsp;&nbsp; unsigned short&=
nbsp;&nbsp;&nbsp; plinelen;<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; s=
ize_t&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; plinelen;<br></div><div dir=3D"l=
tr"> <br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; /* Patch does not match=
 if we don't have any more context to use */<br></div><div dir=3D"ltr"> &nb=
sp;&nbsp;&nbsp; if (pline &gt; pat_lines)<br></div><div dir=3D"ltr">diff --=
git a/usr.bin/patch/pch.c b/usr.bin/patch/pch.c<br></div><div dir=3D"ltr">i=
ndex d528f06235bf..fb53ff86f9ef 100644<br></div><div dir=3D"ltr">--- a/usr.=
bin/patch/pch.c<br></div><div dir=3D"ltr">+++ b/usr.bin/patch/pch.c<br></di=
v><div dir=3D"ltr">@@ -55,7 +55,7 @@ static LINENUM&nbsp;&nbsp;&nbsp; p_max=
;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; /* max allowed value of p_end */<br>=
</div><div dir=3D"ltr"> static LINENUM&nbsp;&nbsp;&nbsp; p_context =3D 3;&n=
bsp;&nbsp;&nbsp; /* # of context lines */<br></div><div dir=3D"ltr"> static=
 LINENUM&nbsp;&nbsp;&nbsp; p_input_line =3D 0;&nbsp;&nbsp;&nbsp; /* current=
 line # from patch file */<br></div><div dir=3D"ltr"> static char&nbsp;&nbs=
p;&nbsp; **p_line =3D NULL;/* the text of the hunk */<br></div><div dir=3D"=
ltr">-static unsigned short&nbsp;&nbsp;&nbsp; *p_len =3D NULL; /* length of=
 each line */<br></div><div dir=3D"ltr">+static size_t&nbsp;&nbsp;&nbsp; *p=
_len =3D NULL;&nbsp;&nbsp;&nbsp; /* length of each line */<br></div><div di=
r=3D"ltr"> static char&nbsp;&nbsp;&nbsp; *p_char =3D NULL;&nbsp;&nbsp;&nbsp=
; /* +, -, and ! */<br></div><div dir=3D"ltr"> static int&nbsp;&nbsp;&nbsp;=
 hunkmax =3D INITHUNKMAX;&nbsp;&nbsp;&nbsp; /* size of above arrays to begi=
n with */<br></div><div dir=3D"ltr"> static int&nbsp;&nbsp;&nbsp; p_indent;=
&nbsp;&nbsp;&nbsp; /* indent to patch */<br></div><div dir=3D"ltr">@@ -137,=
7 +137,7 @@ set_hunkmax(void)<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp;=
 if (p_line =3D=3D NULL)<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; &nbs=
p;&nbsp;&nbsp; p_line =3D malloc(hunkmax * sizeof(char *));<br></div><div d=
ir=3D"ltr"> &nbsp;&nbsp;&nbsp; if (p_len =3D=3D NULL)<br></div><div dir=3D"=
ltr">-&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p_len =3D malloc(hunkmax * size=
of(unsigned short));<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; &nbsp;&n=
bsp;&nbsp; p_len =3D malloc(hunkmax * sizeof(size_t));<br></div><div dir=3D=
"ltr"> &nbsp;&nbsp;&nbsp; if (p_char =3D=3D NULL)<br></div><div dir=3D"ltr"=
> &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; p_char =3D malloc(hunkmax * sizeof(=
char));<br></div><div dir=3D"ltr"> }<br></div><div dir=3D"ltr">@@ -154,7 +1=
54,7 @@ grow_hunkmax(void)<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; &n=
bsp;&nbsp;&nbsp; fatal("Internal memory allocation error\n");<br></div><div=
 dir=3D"ltr"> <br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; p_line =3D rea=
llocf(p_line, new_hunkmax * sizeof(char *));<br></div><div dir=3D"ltr">-&nb=
sp;&nbsp;&nbsp; p_len =3D reallocf(p_len, new_hunkmax * sizeof(unsigned sho=
rt));<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; p_len =3D reallocf(p_le=
n, new_hunkmax * sizeof(size_t));<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&n=
bsp; p_char =3D reallocf(p_char, new_hunkmax * sizeof(char));<br></div><div=
 dir=3D"ltr"> <br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; if (p_line !=
=3D NULL &amp;&amp; p_len !=3D NULL &amp;&amp; p_char !=3D NULL) {<br></div=
><div dir=3D"ltr">@@ -1251,7 +1251,7 @@ bool<br></div><div dir=3D"ltr"> pch=
_swap(void)<br></div><div dir=3D"ltr"> {<br></div><div dir=3D"ltr"> &nbsp;&=
nbsp;&nbsp; char&nbsp;&nbsp;&nbsp; **tp_line;&nbsp;&nbsp;&nbsp; /* the text=
 of the hunk */<br></div><div dir=3D"ltr">-&nbsp;&nbsp;&nbsp; unsigned shor=
t&nbsp;&nbsp;&nbsp; *tp_len;/* length of each line */<br></div><div dir=3D"=
ltr">+&nbsp;&nbsp;&nbsp; size_t&nbsp;&nbsp;&nbsp; *tp_len;&nbsp;&nbsp;&nbsp=
; /* length of each line */<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; c=
har&nbsp;&nbsp;&nbsp; *tp_char;&nbsp;&nbsp;&nbsp; /* +, -, and ! */<br></di=
v><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; LINENUM&nbsp;&nbsp;&nbsp; i;<br></di=
v><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; LINENUM&nbsp;&nbsp;&nbsp; n;<br></di=
v><div dir=3D"ltr">@@ -1408,7 +1408,7 @@ pch_context(void)<br></div><div di=
r=3D"ltr"> /*<br></div><div dir=3D"ltr">&nbsp; * Return the length of a par=
ticular patch line.<br></div><div dir=3D"ltr">&nbsp; */<br></div><div dir=
=3D"ltr">-unsigned short<br></div><div dir=3D"ltr">+size_t<br></div><div di=
r=3D"ltr"> pch_line_len(LINENUM line)<br></div><div dir=3D"ltr"> {<br></div=
><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; return p_len[line];<br></div><div dir=
=3D"ltr">diff --git a/usr.bin/patch/pch.h b/usr.bin/patch/pch.h<br></div><d=
iv dir=3D"ltr">index 5ce4f72497c7..b6c6363155a5 100644<br></div><div dir=3D=
"ltr">--- a/usr.bin/patch/pch.h<br></div><div dir=3D"ltr">+++ b/usr.bin/pat=
ch/pch.h<br></div><div dir=3D"ltr">@@ -45,7 +45,7 @@ bool&nbsp;&nbsp;&nbsp;=
 &nbsp;&nbsp;&nbsp; there_is_another_patch(void);<br></div><div dir=3D"ltr"=
> bool&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; another_hunk(void);<br></div><d=
iv dir=3D"ltr"> bool&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pch_swap(void);<b=
r></div><div dir=3D"ltr"> char&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; *pfetch=
(LINENUM);<br></div><div dir=3D"ltr">-unsigned short&nbsp;&nbsp;&nbsp; pch_=
line_len(LINENUM);<br></div><div dir=3D"ltr">+size_t&nbsp;&nbsp;&nbsp; &nbs=
p;&nbsp;&nbsp; pch_line_len(LINENUM);<br></div><div dir=3D"ltr"> LINENUM&nb=
sp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pch_first(void);<br></div><div dir=3D"lt=
r"> LINENUM&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pch_ptrn_lines(void);<br><=
/div><div dir=3D"ltr"> LINENUM&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; pch_new=
first(void);<br></div><div dir=3D"ltr">diff --git a/usr.bin/patch/tests/uni=
fied_patch_test.sh b/usr.bin/patch/tests/unified_patch_test.sh<br></div><di=
v dir=3D"ltr">index 43b0d8373cfa..7d4b74182c41 100755<br></div><div dir=3D"=
ltr">--- a/usr.bin/patch/tests/unified_patch_test.sh<br></div><div dir=3D"l=
tr">+++ b/usr.bin/patch/tests/unified_patch_test.sh<br></div><div dir=3D"lt=
r">@@ -141,6 +141,24 @@ file_removal_body()<br></div><div dir=3D"ltr"> &nbs=
p;&nbsp;&nbsp; atf_check -o inline:"y\n" cat foo<br></div><div dir=3D"ltr">=
 }<br></div><div dir=3D"ltr"> <br></div><div dir=3D"ltr">+atf_test_case pli=
nelen<br></div><div dir=3D"ltr">+plinelen_body()<br></div><div dir=3D"ltr">=
+{<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; hello=3D"$(jot -b hello -s=
, 20000 | tee foo.txt)"<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; cp fo=
o.txt bar.txt<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; echo "world" &g=
t;&gt;bar.txt<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; cat &gt;foo.dif=
f &lt;&lt;EOF<br></div><div dir=3D"ltr">+--- foo.txt.orig<br></div><div dir=
=3D"ltr">++++ foo.txt<br></div><div dir=3D"ltr">+@@ -1,1 +1,2 @@<br></div><=
div dir=3D"ltr">+ $hello<br></div><div dir=3D"ltr">++world<br></div><div di=
r=3D"ltr">+EOF<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; atf_check -o m=
atch:"Hunk #1 succeeded" \<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp; &n=
bsp;&nbsp;&nbsp; &nbsp; patch &lt;foo.diff<br></div><div dir=3D"ltr">+&nbsp=
;&nbsp;&nbsp; atf_check -o file:bar.txt cat foo.txt<br></div><div dir=3D"lt=
r">+}<br></div><div dir=3D"ltr">+<br></div><div dir=3D"ltr"> atf_init_test_=
cases()<br></div><div dir=3D"ltr"> {<br></div><div dir=3D"ltr"> &nbsp;&nbsp=
;&nbsp; atf_add_test_case basic<br></div><div dir=3D"ltr">@@ -148,4 +166,5 =
@@ atf_init_test_cases()<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; atf_=
add_test_case file_creation<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; a=
tf_add_test_case file_nodupe<br></div><div dir=3D"ltr"> &nbsp;&nbsp;&nbsp; =
atf_add_test_case file_removal<br></div><div dir=3D"ltr">+&nbsp;&nbsp;&nbsp=
; atf_add_test_case plinelen<br></div><div dir=3D"ltr"> }<br></div></div>
            </div>
        </div></body></html>
------=_Part_1846856_2104703329.1707837288562--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1620767053.1846857.1707837288566>