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
This commit is contained in:
Dag-Erling Smørgrav
2024-03-27 11:03:33 +01:00
parent 5fbe8912d6
commit d9a9f23d0b
13 changed files with 502 additions and 22 deletions
+1
View File
@@ -16,6 +16,7 @@ SUBDIR_BOOTSTRAP= \
libc++ \
libc++experimental \
libcxxrt \
libdiff \
libelf \
libssp \
libssp_nonshared \
+15
View File
@@ -0,0 +1,15 @@
LIB= diff
INTERNALLIB= # API not published or supported.
.PATH: ${SRCTOP}/contrib/libdiff/compat
.PATH: ${SRCTOP}/contrib/libdiff/lib
SRCS= diff_atomize_text.c diff_main.c diff_myers.c \
diff_patience.c diff_output.c diff_output_plain.c \
diff_output_unidiff.c diff_output_edscript.c recallocarray.c
WARNS=
CFLAGS+= -I${SRCTOP}/contrib/libdiff/compat/include
CFLAGS+= -I${SRCTOP}/contrib/libdiff/include
.include <bsd.lib.mk>