From 432442d71c748717d8555ebac61c26cf312e3d89 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 8 May 2025 21:42:18 -0400 Subject: [PATCH 1/8] F43+: drop spec-file conditionals and allow branches to diverge --- unifdef.spec | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/unifdef.spec b/unifdef.spec index cd98891..789f77e 100644 --- a/unifdef.spec +++ b/unifdef.spec @@ -1,9 +1,3 @@ -# The upstream Makefile installs unifdefall.sh as unifdefall, which makes -# sense. Older versions of this package installed it as unifdefall.sh; for -# compatibility on stable branches that had such older versions, we still -# provide that path via a symlink. -%bcond all_sh %[ %{defined fc42} || %{defined fc41} || %{defined el10} ] - Name: unifdef Version: 2.12 Release: %autorelease @@ -58,7 +52,6 @@ additional text that they delimit, while otherwise leaving the file alone. # simplify the License, since unifdef.1 is still BSD-3-Clause. rm -rv FreeBSD/ -%if %{undefined fc41} && %{undefined el10} && %{undefined el9} && %{undefined el8} # Test regressions with GCC 15 / C23 default. # Reported upstream by email 2025-05-08. # Described in: @@ -67,21 +60,14 @@ for test in whitespace-1 whitespace-2 do mv "tests/${test}.sh" "tests/${test}.sh.disabled" done -%endif %build -# Implicit in Fedora and EPEL10+; still needed in EPEL8/9. -%set_build_flags - %make_build %install %make_install prefix='%{_prefix}' -%if %{with all_sh} -ln -s unifdefall '%{buildroot}%{_bindir}/unifdefall.sh' -%endif %check @@ -100,9 +86,6 @@ PATH="%{buildroot}%{_bindir}:${PATH}" %make_build test %{_bindir}/unifdef %{_bindir}/unifdefall -%if %{with all_sh} -%{_bindir}/unifdefall.sh -%endif %{_mandir}/man1/unifdef.1* %{_mandir}/man1/unifdefall.1* From ba0a0c1545600bd6c4c163e0d7d16952dc79cada Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Thu, 8 May 2025 22:17:14 -0400 Subject: [PATCH 2/8] F41/EPEL10: drop spec-file conditionals and allow branches to diverge --- unifdef.spec | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/unifdef.spec b/unifdef.spec index cd98891..08f7731 100644 --- a/unifdef.spec +++ b/unifdef.spec @@ -2,7 +2,7 @@ # sense. Older versions of this package installed it as unifdefall.sh; for # compatibility on stable branches that had such older versions, we still # provide that path via a symlink. -%bcond all_sh %[ %{defined fc42} || %{defined fc41} || %{defined el10} ] +%bcond all_sh 1 Name: unifdef Version: 2.12 @@ -58,22 +58,8 @@ additional text that they delimit, while otherwise leaving the file alone. # simplify the License, since unifdef.1 is still BSD-3-Clause. rm -rv FreeBSD/ -%if %{undefined fc41} && %{undefined el10} && %{undefined el9} && %{undefined el8} -# Test regressions with GCC 15 / C23 default. -# Reported upstream by email 2025-05-08. -# Described in: -# https://github.com/fanf2/unifdef/pull/19#issuecomment-2863148452 -for test in whitespace-1 whitespace-2 -do - mv "tests/${test}.sh" "tests/${test}.sh.disabled" -done -%endif - %build -# Implicit in Fedora and EPEL10+; still needed in EPEL8/9. -%set_build_flags - %make_build From 4f24d78a5e1fe4a12f5d0641b386c37be595073e Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Fri, 9 May 2025 22:10:00 -0400 Subject: [PATCH 3/8] Apply a patch for whitespace test regressions --- 15.patch | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ unifdef.spec | 16 ++++----- 2 files changed, 98 insertions(+), 9 deletions(-) create mode 100644 15.patch diff --git a/15.patch b/15.patch new file mode 100644 index 0000000..51412a1 --- /dev/null +++ b/15.patch @@ -0,0 +1,91 @@ +From 9791614057fe7fc72babd78708fdd07857fef9cf Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Wed, 10 Aug 2022 10:06:55 +0200 +Subject: [PATCH] Fix fgets(..., size=1) + +I noticed the following 2 tests are failing with -O1 +-D_FORTIFY_SOURCE=1: + +[ 44s] FAILED: whitespace-1.out: unifdef -DFOO whitespace.c +[ 44s] FAILED: whitespace-2.out: unifdef -DBAR whitespace.c + +It's caused by fact that: + +fgets returns '\0' if n == 1: + +char * +_IO_fgets (char *buf, int n, FILE *fp) +{ + size_t count; + char *result; + int old_error; + CHECK_FILE (fp, NULL); + if (n <= 0) + return NULL; + if (__glibc_unlikely (n == 1)) + { + /* Another irregular case: since we have to store a NUL byte and + there is only room for exactly one byte, we don't have to + read anything. */ + buf[0] = '\0'; + return buf; + } +--- + tests/whitespace-1.experr | 2 -- + tests/whitespace-1.expout | 5 +++++ + tests/whitespace-1.exprc | 2 +- + tests/whitespace-2.expout | 3 ++- + unifdef.c | 3 ++- + 5 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/tests/whitespace-1.experr b/tests/whitespace-1.experr +index cb23fce..e69de29 100644 +--- a/tests/whitespace-1.experr ++++ b/tests/whitespace-1.experr +@@ -1,2 +0,0 @@ +-unifdef: whitespace.c: 4: Obfuscated preprocessor control line (#if line 1 depth 1) +-unifdef: Output may be truncated +diff --git a/tests/whitespace-1.expout b/tests/whitespace-1.expout +index 257cc56..14dd150 100644 +--- a/tests/whitespace-1.expout ++++ b/tests/whitespace-1.expout +@@ -1 +1,6 @@ + foo ++ //spong ++ ++#ifdef BAR ++bar ++#endif +diff --git a/tests/whitespace-1.exprc b/tests/whitespace-1.exprc +index 0cfbf08..d00491f 100644 +--- a/tests/whitespace-1.exprc ++++ b/tests/whitespace-1.exprc +@@ -1 +1 @@ +-2 ++1 +diff --git a/tests/whitespace-2.expout b/tests/whitespace-2.expout +index 84cabfe..43f6399 100644 +--- a/tests/whitespace-2.expout ++++ b/tests/whitespace-2.expout +@@ -1,5 +1,6 @@ + #ifdef FOO + foo +-#endif //spong ++#endif ++ //spong + + bar +diff --git a/unifdef.c b/unifdef.c +index dc145a2..b7335aa 100644 +--- a/unifdef.c ++++ b/unifdef.c +@@ -846,7 +846,8 @@ parseline(void) + newline or if there is too much whitespace in a directive */ + if (linestate == LS_HASH) { + long len = cp - tline; +- if (fgets(tline + len, MAXLINE - len, input) == NULL) { ++ const char *line = fgets(tline + len, MAXLINE - len, input); ++ if (line == NULL || *line == '\0') { + if (ferror(input)) + err(2, "can't read %s", filename); + debug("parser insert newline at EOF", linenum); diff --git a/unifdef.spec b/unifdef.spec index 789f77e..e86f8b8 100644 --- a/unifdef.spec +++ b/unifdef.spec @@ -32,6 +32,13 @@ Source: https://dotat.at/prog/unifdef/unifdef-%{version}.tar.xz # https://github.com/fanf2/unifdef/pull/14 Patch: %{forgeurl}/pull/14.patch +# Fix fgets(..., size=1) +# https://github.com/fanf2/unifdef/pull/15 +# +# Further discussion in https://github.com/fanf2/unifdef/pull/19 and +# https://gcc.gnu.org/PR120205. +Patch: %{forgeurl}/pull/15.patch + # Don't use C23 constexpr keyword # https://github.com/fanf2/unifdef/pull/19 # Fixes compatibility with GCC 15, which defaults to C23 @@ -52,15 +59,6 @@ additional text that they delimit, while otherwise leaving the file alone. # simplify the License, since unifdef.1 is still BSD-3-Clause. rm -rv FreeBSD/ -# Test regressions with GCC 15 / C23 default. -# Reported upstream by email 2025-05-08. -# Described in: -# https://github.com/fanf2/unifdef/pull/19#issuecomment-2863148452 -for test in whitespace-1 whitespace-2 -do - mv "tests/${test}.sh" "tests/${test}.sh.disabled" -done - %build %make_build From 2b9802c81adeca34784e1527b5b49d835f62cd34 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Fri, 9 May 2025 22:10:00 -0400 Subject: [PATCH 4/8] Apply a patch for whitespace test regressions --- 15.patch | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++ unifdef.spec | 7 ++++ 2 files changed, 98 insertions(+) create mode 100644 15.patch diff --git a/15.patch b/15.patch new file mode 100644 index 0000000..51412a1 --- /dev/null +++ b/15.patch @@ -0,0 +1,91 @@ +From 9791614057fe7fc72babd78708fdd07857fef9cf Mon Sep 17 00:00:00 2001 +From: Martin Liska +Date: Wed, 10 Aug 2022 10:06:55 +0200 +Subject: [PATCH] Fix fgets(..., size=1) + +I noticed the following 2 tests are failing with -O1 +-D_FORTIFY_SOURCE=1: + +[ 44s] FAILED: whitespace-1.out: unifdef -DFOO whitespace.c +[ 44s] FAILED: whitespace-2.out: unifdef -DBAR whitespace.c + +It's caused by fact that: + +fgets returns '\0' if n == 1: + +char * +_IO_fgets (char *buf, int n, FILE *fp) +{ + size_t count; + char *result; + int old_error; + CHECK_FILE (fp, NULL); + if (n <= 0) + return NULL; + if (__glibc_unlikely (n == 1)) + { + /* Another irregular case: since we have to store a NUL byte and + there is only room for exactly one byte, we don't have to + read anything. */ + buf[0] = '\0'; + return buf; + } +--- + tests/whitespace-1.experr | 2 -- + tests/whitespace-1.expout | 5 +++++ + tests/whitespace-1.exprc | 2 +- + tests/whitespace-2.expout | 3 ++- + unifdef.c | 3 ++- + 5 files changed, 10 insertions(+), 5 deletions(-) + +diff --git a/tests/whitespace-1.experr b/tests/whitespace-1.experr +index cb23fce..e69de29 100644 +--- a/tests/whitespace-1.experr ++++ b/tests/whitespace-1.experr +@@ -1,2 +0,0 @@ +-unifdef: whitespace.c: 4: Obfuscated preprocessor control line (#if line 1 depth 1) +-unifdef: Output may be truncated +diff --git a/tests/whitespace-1.expout b/tests/whitespace-1.expout +index 257cc56..14dd150 100644 +--- a/tests/whitespace-1.expout ++++ b/tests/whitespace-1.expout +@@ -1 +1,6 @@ + foo ++ //spong ++ ++#ifdef BAR ++bar ++#endif +diff --git a/tests/whitespace-1.exprc b/tests/whitespace-1.exprc +index 0cfbf08..d00491f 100644 +--- a/tests/whitespace-1.exprc ++++ b/tests/whitespace-1.exprc +@@ -1 +1 @@ +-2 ++1 +diff --git a/tests/whitespace-2.expout b/tests/whitespace-2.expout +index 84cabfe..43f6399 100644 +--- a/tests/whitespace-2.expout ++++ b/tests/whitespace-2.expout +@@ -1,5 +1,6 @@ + #ifdef FOO + foo +-#endif //spong ++#endif ++ //spong + + bar +diff --git a/unifdef.c b/unifdef.c +index dc145a2..b7335aa 100644 +--- a/unifdef.c ++++ b/unifdef.c +@@ -846,7 +846,8 @@ parseline(void) + newline or if there is too much whitespace in a directive */ + if (linestate == LS_HASH) { + long len = cp - tline; +- if (fgets(tline + len, MAXLINE - len, input) == NULL) { ++ const char *line = fgets(tline + len, MAXLINE - len, input); ++ if (line == NULL || *line == '\0') { + if (ferror(input)) + err(2, "can't read %s", filename); + debug("parser insert newline at EOF", linenum); diff --git a/unifdef.spec b/unifdef.spec index 08f7731..71e02ec 100644 --- a/unifdef.spec +++ b/unifdef.spec @@ -38,6 +38,13 @@ Source: https://dotat.at/prog/unifdef/unifdef-%{version}.tar.xz # https://github.com/fanf2/unifdef/pull/14 Patch: %{forgeurl}/pull/14.patch +# Fix fgets(..., size=1) +# https://github.com/fanf2/unifdef/pull/15 +# +# Further discussion in https://github.com/fanf2/unifdef/pull/19 and +# https://gcc.gnu.org/PR120205. +Patch: %{forgeurl}/pull/15.patch + # Don't use C23 constexpr keyword # https://github.com/fanf2/unifdef/pull/19 # Fixes compatibility with GCC 15, which defaults to C23 From fe14acf4df70d24c131d808c377228c3a60b52dd Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 25 Jul 2025 19:46:58 +0000 Subject: [PATCH 5/8] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild From 81bc193b20987fa7157b33253ae6e590269882ac Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sat, 17 Jan 2026 19:36:24 +0000 Subject: [PATCH 6/8] Rebuilt for https://fedoraproject.org/wiki/Fedora_44_Mass_Rebuild From 5421eae066f93fbfa0132386ca519de125ee2289 Mon Sep 17 00:00:00 2001 From: "Benjamin A. Beasley" Date: Sun, 24 May 2026 09:20:27 +0100 Subject: [PATCH 7/8] Use various long options --- unifdef.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unifdef.spec b/unifdef.spec index e86f8b8..86e07f3 100644 --- a/unifdef.spec +++ b/unifdef.spec @@ -57,7 +57,7 @@ additional text that they delimit, while otherwise leaving the file alone. %autosetup -p1 # Show that we do not use the sources in FreeBSD – even though this does not # simplify the License, since unifdef.1 is still BSD-3-Clause. -rm -rv FreeBSD/ +rm --recursive --verbose FreeBSD/ %build From 36488bf88c3ae4296162a46461de7d1282e35328 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 17 Jul 2026 08:11:02 +0000 Subject: [PATCH 8/8] Rebuilt for https://fedoraproject.org/wiki/Fedora_45_Mass_Rebuild