git: b780b6508b58 - main - diff: Warn if the atomizer detected truncation.

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Mon, 20 May 2024 13:33:15 UTC
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=b780b6508b586f52126037fd748fe74dbeb12495

commit b780b6508b586f52126037fd748fe74dbeb12495
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2024-05-20 13:26:46 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2024-05-20 13:26:46 +0000

    diff: Warn if the atomizer detected truncation.
    
    Sponsored by:   Klara, Inc.
    Reviewed by:    allanjude, markj
    Differential Revision:  https://reviews.freebsd.org/D45219
---
 usr.bin/diff/diffreg_new.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/usr.bin/diff/diffreg_new.c b/usr.bin/diff/diffreg_new.c
index 3b50dfd5940b..a7a40ec12ec9 100644
--- a/usr.bin/diff/diffreg_new.c
+++ b/usr.bin/diff/diffreg_new.c
@@ -218,10 +218,14 @@ diffreg_new(char *file1, char *file2, int flags, int capsicum)
 		rc = D_ERROR;
 		goto done;
 	}
+	if (left.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED)
+		warnx("%s truncated", file1);
 	if (diff_atomize_file(&right, cfg, f2, (uint8_t *)str2, st2.st_size, diff_flags)) {
 		rc = D_ERROR;
 		goto done;
 	}
+	if (right.atomizer_flags & DIFF_ATOMIZER_FILE_TRUNCATED)
+		warnx("%s truncated", file2);
 
 	result = diff_main(cfg, &left, &right);
 	if (result->rc != DIFF_RC_OK) {