<feed xmlns='http://www.w3.org/2005/Atom'>
<title>src/usr.bin/diff/diffreg.c, branch stable/14</title>
<subtitle>FreeBSD source tree</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/'/>
<entry>
<title>diff: Report I/O errors in Stone algorithm</title>
<updated>2026-02-10T14:24:20+00:00</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2026-02-05T17:41:56+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=37ceb8794c22d88a41e261d23d347bc7ac08b2c8'/>
<id>37ceb8794c22d88a41e261d23d347bc7ac08b2c8</id>
<content type='text'>
In the legacy Stone algorithm, we do a first pass over the files to
check if they're identical before we start diffing them.  That code
would correctly set the exit status if an I/O error was encountered,
but would not emit an error message.  Do so.

PR:		292198
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	thj
Differential Revision:	https://reviews.freebsd.org/D55125

(cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
In the legacy Stone algorithm, we do a first pass over the files to
check if they're identical before we start diffing them.  That code
would correctly set the exit status if an I/O error was encountered,
but would not emit an error message.  Do so.

PR:		292198
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	thj
Differential Revision:	https://reviews.freebsd.org/D55125

(cherry picked from commit f8c12e6e3874cdd353fb16785da6f4e7eb134cd9)
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: Don't compare a file or directory to itself</title>
<updated>2026-02-10T14:24:19+00:00</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2026-02-05T14:39:57+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=7f412c6f88edc3aafb53a83f1743ad49da4679a9'/>
<id>7f412c6f88edc3aafb53a83f1743ad49da4679a9</id>
<content type='text'>
While here, stop abusing struct dirent for something we don't even need
to store.

PR:		254455
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	thj, kevans
Differential Revision:	https://reviews.freebsd.org/D55113

(cherry picked from commit 590126789c841d80655869bc075c8980c173dd1c)

diff: Fix build

rc must be defined first.

Fixes:		590126789c84
MFC after:	1 week
X-MFC with:	590126789c84

(cherry picked from commit ee44ab936e84bacaa49847d36aabdf280f9fecce)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
While here, stop abusing struct dirent for something we don't even need
to store.

PR:		254455
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	thj, kevans
Differential Revision:	https://reviews.freebsd.org/D55113

(cherry picked from commit 590126789c841d80655869bc075c8980c173dd1c)

diff: Fix build

rc must be defined first.

Fixes:		590126789c84
MFC after:	1 week
X-MFC with:	590126789c84

(cherry picked from commit ee44ab936e84bacaa49847d36aabdf280f9fecce)
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: Fix integer overflows in Stone algorithm</title>
<updated>2026-02-10T14:24:19+00:00</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2026-02-05T14:39:43+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=237fd8dd96979412dd65ce95032aa9957463d069'/>
<id>237fd8dd96979412dd65ce95032aa9957463d069</id>
<content type='text'>
Fix integer overflows that may occur when the context window is very
large and add tests to exercise those conditions.

PR:		267032
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	thj, kevans
Differential Revision:	https://reviews.freebsd.org/D55110

(cherry picked from commit 5fc739eb5949620da911db2f87ca8faedc549d3a)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix integer overflows that may occur when the context window is very
large and add tests to exercise those conditions.

PR:		267032
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	thj, kevans
Differential Revision:	https://reviews.freebsd.org/D55110

(cherry picked from commit 5fc739eb5949620da911db2f87ca8faedc549d3a)
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: Fix integer overflow.</title>
<updated>2024-08-01T16:15:57+00:00</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2024-07-29T14:02:29+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=ea68175b07e0cd8e51249d2858749481352aa553'/>
<id>ea68175b07e0cd8e51249d2858749481352aa553</id>
<content type='text'>
The legacy Stone algorithm uses `int` to represent line numbers, array
indices, and array lengths.  If given inputs approaching `INT_MAX` lines,
it would overflow and attempt to allocate ridiculously large amounts of
memory.  To avoid this without penalizing non-pathological inputs,
switch a few variables to `size_t` and add checks while and immediately
after reading both inputs.

MFC after:	3 days
PR:		280371
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D46169

(cherry picked from commit 9317242469f1ca682626d9806f8caf65d143c09a)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The legacy Stone algorithm uses `int` to represent line numbers, array
indices, and array lengths.  If given inputs approaching `INT_MAX` lines,
it would overflow and attempt to allocate ridiculously large amounts of
memory.  To avoid this without penalizing non-pathological inputs,
switch a few variables to `size_t` and add checks while and immediately
after reading both inputs.

MFC after:	3 days
PR:		280371
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude
Differential Revision:	https://reviews.freebsd.org/D46169

(cherry picked from commit 9317242469f1ca682626d9806f8caf65d143c09a)
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: honour -B flag with -q</title>
<updated>2024-05-24T23:59:11+00:00</updated>
<author>
<name>Ed Maste</name>
<email>emaste@FreeBSD.org</email>
</author>
<published>2024-05-16T14:53:23+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1b7672ed992963e1c79ccc152f4afd72c91481f3'/>
<id>1b7672ed992963e1c79ccc152f4afd72c91481f3</id>
<content type='text'>
PR:		278988
Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45220

(cherry picked from commit fb623aab3927a6825ff7731198ec2e33426f7607)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
PR:		278988
Reviewed by:	bapt
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D45220

(cherry picked from commit fb623aab3927a6825ff7731198ec2e33426f7607)
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: Fix --expand-tabs and --side-by-side.</title>
<updated>2024-03-11T12:19:06+00:00</updated>
<author>
<name>Dag-Erling Smørgrav</name>
<email>des@FreeBSD.org</email>
</author>
<published>2024-02-26T18:08:06+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=da290528974846d3ed49138ca0f2de7fff02eaf6'/>
<id>da290528974846d3ed49138ca0f2de7fff02eaf6</id>
<content type='text'>
* Overhaul column width and padding calculation.
* Rewrite print_space() so it is now a) correct and b) understandable.
* Rewrite tab expansion in fetch() for the same reason.

This brings us in line with GNU diff for all cases I could think of.

Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44014

(cherry picked from commit 53de23f4d140becc3166e87665b0064f215a220e)

diff: Bump manual page date.

Sponsored by:	Klara, Inc.

(cherry picked from commit 312b1076c6b0aff9bbcaff058b93385eaf607685)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Overhaul column width and padding calculation.
* Rewrite print_space() so it is now a) correct and b) understandable.
* Rewrite tab expansion in fetch() for the same reason.

This brings us in line with GNU diff for all cases I could think of.

Sponsored by:	Klara, Inc.
Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D44014

(cherry picked from commit 53de23f4d140becc3166e87665b0064f215a220e)

diff: Bump manual page date.

Sponsored by:	Klara, Inc.

(cherry picked from commit 312b1076c6b0aff9bbcaff058b93385eaf607685)
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove $FreeBSD$: one-line .c pattern</title>
<updated>2023-08-16T17:54:42+00:00</updated>
<author>
<name>Warner Losh</name>
<email>imp@FreeBSD.org</email>
</author>
<published>2023-08-16T17:54:42+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=1d386b48a555f61cb7325543adbbb5c3f3407a66'/>
<id>1d386b48a555f61cb7325543adbbb5c3f3407a66</id>
<content type='text'>
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: Fully comment out the jackpot variable.</title>
<updated>2023-06-20T16:29:00+00:00</updated>
<author>
<name>John Baldwin</name>
<email>jhb@FreeBSD.org</email>
</author>
<published>2023-06-20T16:29:00+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=e8f740fbc261b953ea4f22b80846f55c54225710'/>
<id>e8f740fbc261b953ea4f22b80846f55c54225710</id>
<content type='text'>
This fixes a set but unused warning.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes a set but unused warning.
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: restyle loop a bit</title>
<updated>2022-12-14T01:31:21+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2022-12-14T01:31:21+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=54d65fdd5643f61a816c1d028b53039290ed1d92'/>
<id>54d65fdd5643f61a816c1d028b53039290ed1d92</id>
<content type='text'>
This is a bit more readable, and this loop is probably unlikely to gain
any `continue` or `break`s.

Suggested by:	pstef
Differential Revision:	https://reviews.freebsd.org/D37676
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is a bit more readable, and this loop is probably unlikely to gain
any `continue` or `break`s.

Suggested by:	pstef
Differential Revision:	https://reviews.freebsd.org/D37676
</pre>
</div>
</content>
</entry>
<entry>
<title>diff: fix side-by-side output with tabbed input</title>
<updated>2022-12-14T01:31:21+00:00</updated>
<author>
<name>Kyle Evans</name>
<email>kevans@FreeBSD.org</email>
</author>
<published>2022-12-14T01:31:21+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.freebsd.org/src/commit/?id=8bf187f35b6298b7848c5ecf45b0b714327090d9'/>
<id>8bf187f35b6298b7848c5ecf45b0b714327090d9</id>
<content type='text'>
The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)

Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.

Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count.  The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.

Reviewed by:	bapt, pstef
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37676
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The previous logic conflated some things... in this block:
- j: input characters rendered so far
- nc: number of characters in the line
- col: columns rendered so far
- hw: column width ((h)ard (w)idth?)

Comparing j to hw or col to nc are naturally wrong, as col and hw are
limits on their respective counters and nc is already brought down to hw
if the input line should be truncated to start with.

Right now, we end up easily truncating lines with tabs in them as we
count each tab for $tabwidth lines in the input line, but we really
should only be accounting for them in the column count.  The problem is
most easily demonstrated by the two input files added for the tests,
the two tabbed lines lose at least a word or two even though there's
plenty of space left in the row for each side.

Reviewed by:	bapt, pstef
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D37676
</pre>
</div>
</content>
</entry>
</feed>
