Make the (debug & 2) output more useful

* src/pch.c (another_hunk): In the (debug & 2) output, fix how empty
lines that are not part of the patch context are printed.  Also, add
newlines to lines that are missing them to keep the output readable.
This commit is contained in:
Xibo.Wang 2022-12-29 18:05:24 +08:00
parent fbf3f4b4d7
commit e43fc93428
2 changed files with 52 additions and 1 deletions

View File

@ -0,0 +1,47 @@
From 4be3ee4d25fc777a2508fdd03dc8f701cf4ca91d Mon Sep 17 00:00:00 2001
From: Andreas Gruenbacher <agruen@gnu.org>
Date: Fri, 17 Aug 2018 10:31:22 +0200
Subject: [PATCH] Make the (debug & 2) output more useful
* src/pch.c (another_hunk): In the (debug & 2) output, fix how empty
lines that are not part of the patch context are printed. Also, add
newlines to lines that are missing them to keep the output readable.
Signed-off-by: Xibo.Wang <wangxb12@chinatelecom.cn>
---
src/pch.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/src/pch.c b/src/pch.c
index 4368561..aa0caf4 100644
--- a/src/pch.c
+++ b/src/pch.c
@@ -1923,8 +1923,13 @@ another_hunk (enum diff difftype, bool rev)
lin i;
for (i = 0; i <= p_end + 1; i++) {
- fprintf (stderr, "%s %c",
- format_linenum (numbuf0, i),
+ fputs (format_linenum (numbuf0, i), stderr);
+ if (p_Char[i] == '\n')
+ {
+ fputc('\n', stderr);
+ continue;
+ }
+ fprintf (stderr, " %c",
p_Char[i]);
if (p_Char[i] == '*')
fprintf (stderr, " %s,%s\n",
@@ -1937,7 +1942,8 @@ another_hunk (enum diff difftype, bool rev)
else if (p_Char[i] != '^')
{
fputs(" |", stderr);
- pch_write_line (i, stderr);
+ if (! pch_write_line (i, stderr))
+ fputc('\n', stderr);
}
else
fputc('\n', stderr);
--
1.8.3.1

View File

@ -1,6 +1,6 @@
Name: patch
Version: 2.7.6
Release: 17
Release: 18
Summary: Utiliity which applies a patch file to original files.
License: GPLv3+
URL: http://www.gnu.org/software/patch/patch.html
@ -18,6 +18,7 @@ Patch9: Avoid-set_file_attributes-sign-conversion-warnings.patch
Patch10: Test-suite-compatibility-fixes.patch
Patch11: Test-suite-fix-Korn-shell-incompatibility.patch
Patch12: backport-maint-avoid-warnings-from-GCC8.patch
Patch13: backport-Make-the-debug-2-output-more-useful.patch
BuildRequires: gcc libselinux-devel libattr-devel ed
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-root
@ -60,6 +61,9 @@ CFLAGS="$RPM_OPT_FLAGS -D_GNU_SOURCE"
%{_mandir}/man1/*
%changelog
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-18
- Make the (debug & 2) output more useful
* Wed Dec 28 2022 Xibo.Wang <wangxb12@chinatelecom.cn> - 2.7.6-17
- maint: avoid warnings from GCC8