Subject: [PATCH] diff: fix regression affecting the counting of diff context lines
From: Gleb Fotengauer-Malinovskiy <[email-masked]>
To: [email-masked]
Cc: Gleb Fotengauer-Malinovskiy <[email-masked]>
Date: Thu, 14 Sep 2023 21:16:51 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

This regression was introduced on 2023-05-22 in commit
v3.10-9-gda1697dcb6 ("diff: C99 decl style in context.c") during a code
style change.

This regression was discovered using the GNU patch testsuite:
FAIL: preserve-c-function-names
FAIL: reject-format

 * src/context.c (minus_prefix_lines): Initialize with a reversed value.

Tiny-change: yes
---
 src/context.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/context.c b/src/context.c
index 8ee49ae961..34f046384c 100644
--- a/src/context.c
+++ b/src/context.c
@@ -186,7 +186,7 @@ pr_context_hunk (struct change *hunk)
 
   /* Include a context's width before and after.  */
 
-  lin minus_prefix_lines = curr.file[0].prefix_lines;
+  lin minus_prefix_lines = - curr.file[0].prefix_lines;
   first0 = MAX (first0 - context, minus_prefix_lines);
   first1 = MAX (first1 - context, minus_prefix_lines);
   if (last0 < curr.file[0].valid_lines - context)
-- 
glebfm