!21 fix diff -D option failed

From: @jiayi0118 
Reviewed-by: @licunlong 
Signed-off-by: @licunlong
This commit is contained in:
openeuler-ci-bot 2023-03-08 02:29:34 +00:00 committed by Gitee
commit 75eb9d5bb4
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 167 additions and 1 deletions

View File

@ -0,0 +1,112 @@
From ba08fbbb0ca5da455bf695236c57bc50e7faed50 Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Fri, 10 Feb 2023 15:33:40 -0800
Subject: diff: fix bug where -D does not work
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Problem reported by Robert Webb (bug#61193).
* NEWS: Mention this.
* src/diff.c (main): Omit stray sizeof.
* tests/ifdef: New test.
* tests/Makefile.am (TESTS): Add it.
Reference:https://git.savannah.gnu.org/cgit/diffutils.git/commit/?id=ba08fbbb0ca5da455bf695236c57bc50e7faed50
Conflict:NA
---
NEWS | 5 +++++
src/diff.c | 2 +-
tests/Makefile.am | 1 +
tests/ifdef | 37 +++++++++++++++++++++++++++++++++++++
4 files changed, 44 insertions(+), 1 deletion(-)
create mode 100755 tests/ifdef
diff --git a/NEWS b/NEWS
index ad9c6cc..f146730 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,11 @@ GNU diffutils NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Bug fixes
+
+ diff -D no longer fails to output #ifndef lines.
+ [bug#61193 introduced in 3.9]
+
* Noteworthy changes in release 3.9 (2023-01-15) [stable]
diff --git a/src/diff.c b/src/diff.c
index dd6f63b..2b4834f 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -416,7 +416,7 @@ main (int argc, char **argv)
char *base = b;
int changes = 0;
- for (i = 0; i < sizeof sizeof C_ifdef_group_formats; i++)
+ for (i = 0; i < sizeof C_ifdef_group_formats; i++)
{
char ch = C_ifdef_group_formats[i];
switch (ch)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index d98df82..624192d 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -10,6 +10,7 @@ TESTS = \
diff3 \
excess-slash \
help-version \
+ ifdef \
invalid-re \
function-line-vs-leading-space \
ignore-matching-lines \
diff --git a/tests/ifdef b/tests/ifdef
new file mode 100755
index 0000000..d3b05dd
--- /dev/null
+++ b/tests/ifdef
@@ -0,0 +1,37 @@
+#!/bin/sh
+# --ifdef
+
+# Bug reported by Robert Webb in <http://bugs.gnu.org/61193>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+
+fail=0
+
+cat <<'EOF' >a
+1
+2
+3
+4
+5
+EOF
+
+cat <<'EOF' >b
+1
+4
+5
+EOF
+
+cat <<'EOF' >exp
+1
+#ifndef ZZZ
+2
+3
+#endif /* ! ZZZ */
+4
+5
+EOF
+
+returns_ 1 diff -D ZZZ a b >out 2>err || fail=1
+compare exp out || fail=1
+
+Exit $fail
--
cgit v1.1

View File

@ -0,0 +1,45 @@
From aa13187f2a982a2d3d46c93cd08691960915ac74 Mon Sep 17 00:00:00 2001
From: Jim Meyering <meyering@meta.com>
Date: Sun, 15 Jan 2023 13:25:29 -0800
Subject: maint: post-release administrivia
* NEWS: Add header line for next release.
* cfg.mk (old_NEWS_hash): Auto-update.
Reference:https://git.savannah.gnu.org/cgit/diffutils.git/commit/?id=aa13187f2a982a2d3d46c93cd08691960915ac74
Conflict:remove change on .prev-version
---
NEWS | 3 +++
cfg.mk | 2 +-
2 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/NEWS b/NEWS
index b410596..ad9c6cc 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,8 @@
GNU diffutils NEWS -*- outline -*-
+* Noteworthy changes in release ?.? (????-??-??) [?]
+
+
* Noteworthy changes in release 3.9 (2023-01-15) [stable]
** Bug fixes
diff --git a/cfg.mk b/cfg.mk
index 142a9ce..3c10efb 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -36,7 +36,7 @@ announcement_Cc_ = $(translation_project_), $(PACKAGE)-devel@gnu.org
# Now that we have better tests, make this the default.
export VERBOSE = yes
-old_NEWS_hash = 94e919f647d397a84992078ccedba212
+old_NEWS_hash = cf070086af56e7394cc5a0c862d0cd11
# Tell maint.mk's syntax-check rules that diff gets config.h directly or
# via diff.h or system.h.
--
cgit v1.1

View File

@ -1,6 +1,6 @@
Name: diffutils
Version: 3.9
Release: 1
Release: 2
Summary: A GNU collection of diff utilities
URL: http://www.gnu.org/software/diffutils/diffutils.html
Source: ftp://ftp.gnu.org/gnu/diffutils/diffutils-%{version}.tar.xz
@ -8,6 +8,9 @@ Patch1: diffutils-cmp-s-empty.patch
Patch2: diffutils-i18n.patch
Patch3: diff3-set-flagging-to-true-in-X-option.patch
Patch4: backport-maint-post-release-administrivia.patch
Patch5: backport-diff-fix-bug-where--D-does-not-work.patch
License: GPLv3+
Provides: bundled(gnulib)
BuildRequires: gcc, help2man, gettext-devel
@ -55,6 +58,12 @@ cat tests/test-suite.log
%exclude %{_infodir}/dir
%changelog
* Wed Mar 8 2023 Jiayi Chen <chenjiayi22@huawei.com> - 3.9-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:fix diff -D option failed
* Sat Jan 28 2023 Jiayi Chen <chenjiayi22@huawei.com> - 3.9-1
- Type:enhancement
- ID:NA