git: 4d73b07d02d1 - main - diff: fix support for -l with new diff algorithm
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 02 Feb 2026 16:13:27 UTC
The branch main has been updated by bapt:
URL: https://cgit.FreeBSD.org/src/commit/?id=4d73b07d02d12cdff0558d3ca6c4b3224cae831f
commit 4d73b07d02d12cdff0558d3ca6c4b3224cae831f
Author: Baptiste Daroussin <bapt@FreeBSD.org>
AuthorDate: 2026-02-02 15:43:29 +0000
Commit: Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2026-02-02 16:13:16 +0000
diff: fix support for -l with new diff algorithm
MFC After: 3 days
Reviewed by: des
Differential Revision: https://reviews.freebsd.org/D55052
---
usr.bin/diff/diff.c | 1 +
usr.bin/diff/diff.h | 1 +
usr.bin/diff/diffreg_new.c | 7 +++++++
3 files changed, 9 insertions(+)
diff --git a/usr.bin/diff/diff.c b/usr.bin/diff/diff.c
index 83aa20c52cf3..1aba09f7a5f7 100644
--- a/usr.bin/diff/diff.c
+++ b/usr.bin/diff/diff.c
@@ -249,6 +249,7 @@ main(int argc, char **argv)
usage();
break;
case 'l':
+ dflags |= D_PAGINATION;
lflag = true;
break;
case 'N':
diff --git a/usr.bin/diff/diff.h b/usr.bin/diff/diff.h
index 74be55db8a33..4bea23db1ab8 100644
--- a/usr.bin/diff/diff.h
+++ b/usr.bin/diff/diff.h
@@ -80,6 +80,7 @@
#define D_STRIPCR 0x400 /* Strip trailing cr */
#define D_SKIPBLANKLINES 0x800 /* Skip blank lines */
#define D_MATCHLAST 0x1000 /* Display last line matching provided regex */
+#define D_PAGINATION 0x2000 /* Paginate via pr(1) */
/* Features supported by new algorithms */
#define D_NEWALGO_FLAGS (D_FORCEASCII | D_PROTOTYPE | D_IGNOREBLANKS)
diff --git a/usr.bin/diff/diffreg_new.c b/usr.bin/diff/diffreg_new.c
index f54cd554ccad..d932764bb6da 100644
--- a/usr.bin/diff/diffreg_new.c
+++ b/usr.bin/diff/diffreg_new.c
@@ -33,6 +33,7 @@
#include <time.h>
#include <unistd.h>
+#include "pr.h"
#include "diff.h"
#include <arraylist.h>
#include <diff_main.h>
@@ -146,6 +147,7 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum)
{
char *str1, *str2;
FILE *f1, *f2;
+ struct pr *pr = NULL;
struct stat st1, st2;
struct diff_input_info info;
struct diff_data left = {}, right = {};
@@ -178,6 +180,9 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum)
f1 = openfile(file1, &str1, &st1);
f2 = openfile(file2, &str2, &st2);
+ if (flags & D_PAGINATION)
+ pr = start_pr(file1, file2);
+
if (capsicum) {
cap_rights_init(&rights_ro, CAP_READ, CAP_FSTAT, CAP_SEEK);
if (caph_rights_limit(fileno(f1), &rights_ro) < 0)
@@ -271,6 +276,8 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum)
status |= 1;
}
done:
+ if (pr != NULL)
+ stop_pr(pr);
diff_result_free(result);
diff_data_free(&left);
diff_data_free(&right);