Commit graph

9 commits

Author SHA1 Message Date
Dag-Erling Smørgrav
d58ab2ad94 diff: Drop unnecessary casts, fix none algo
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D55349

(cherry picked from commit d5404462f691230423dc8cc543c6fdc44f34ec31)
2026-02-26 04:02:28 +00:00
Dag-Erling Smørgrav
07f25fa320 diff: Print an error message on I/O error
If an error occurs while atomizing either file, immediately print an
error message using the error code returned by the atomizer, and set
the error bit in the exit status.

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

(cherry picked from commit 55f160fb07eaee977c89bdee7bdd83f4d21f5adf)
2026-02-10 14:24:08 +00:00
Dag-Erling Smørgrav
b97396baca libdiff: Simplify truncation detection
* Adjust the comment to reflect the fact that SIGBUS can occur not only
  if the file is truncated, but also if an I/O error occurs while paging
  in any part of it.

* Instead of setting a flag, just return EIO.

* Adjust the unit test accordingly.

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

(cherry picked from commit a689bfa4e25af8307709dc12f75b0e02a65abf18)
2026-02-10 14:24:07 +00:00
Baptiste Daroussin
c47b4439da diff: fix support for -l with new diff algorithm
MFC After: 3 days
Reviewed by:	des
Differential Revision:	https://reviews.freebsd.org/D55052

(cherry picked from commit 4d73b07d02d12cdff0558d3ca6c4b3224cae831f)
2026-02-05 15:10:44 +01:00
Dag-Erling Smørgrav
893839b119 diff: Fix device case.
We already fell back to Stone for FIFOs, but we actually need to fall
back to Stone for everything except regular files, because libdiff's
atomizer needs to know the size of its input in advance, and neither
FIFOs nor devices can be trusted to report their size.

MFC after:	1 week
Reported by:	mav
Reviewed by:	mav, allanjude
Differential Revision:	https://reviews.freebsd.org/D48181
2024-12-23 18:16:14 +01:00
Dag-Erling Smørgrav
4e859e67dd libdiff: Implement diff coloring.
This patch got accidentally left out when libdiff was imported.  The
rest of the code (command-line option etc.) was present, just not the
part that actually prints ANSI color codes.

Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D46873
2024-10-02 17:55:06 +02:00
Dag-Erling Smørgrav
b780b6508b diff: Warn if the atomizer detected truncation.
Sponsored by:	Klara, Inc.
Reviewed by:	allanjude, markj
Differential Revision:	https://reviews.freebsd.org/D45219
2024-05-20 15:26:46 +02:00
Dag-Erling Smørgrav
eea5f8d408 diff: Sort headers.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D45078
2024-05-03 17:03:50 +02:00
Dag-Erling Smørgrav
d9a9f23d0b diff: Integrate libdiff from OpenBSD GoT.
This adds support for two new diff algorithms, Myers diff and Patience
diff.

These algorithms perform a different form of search compared to the
classic Stone algorithm and support escapes when worst case scenarios
are encountered.

Add the -A flag to allow selection of the algorithm, but default to
using the new Myers diff implementation.

The libdiff implementation currently only supports a subset of input and
output options supported by diff.  When these options are used, but the
algorithm is not selected, automatically fallback to the classic Stone
algorithm until support for these modes can be added.

Based on work originally done by thj@ with contributions from kevans@.

Sponsored by:	Klara, Inc.
Reviewed by:	thj
Differential Revision:	https://reviews.freebsd.org/D44302
2024-03-27 11:03:33 +01:00