Bug 2196671

Summary: diff -D NEW doesn't generate #ifdef lines
Product: [Fedora] Fedora Reporter: Ralph Campbell <ralphcampbell1>
Component: diffutilsAssignee: Tim Waugh <twaugh>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 38CC: twaugh
Target Milestone: ---Keywords: Regression
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: diffutils-3.10-1.fc38 Doc Type: ---
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-07-01 01:45:41 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Ralph Campbell 2023-05-09 19:51:28 UTC
I'm using diffutils 3.9. I also compiled from source and see the same issue.

file1:
Here is some old line.

file2:
Here is some new line.

% diff-3.8 -D NEW file1 file2
#ifndef NEW
Here is some old line.
#else /* NEW */
Here is some new line.
#endif /* NEW */

% diff-3.9 -D NEW file1 file2:
Here is some old line.
Here is some new line.


Reproducible: Always

Steps to Reproduce:
1. use "diff -D NEW file1 file2" where file1 and file2 are different
2.
3.
Actual Results:  
Here is some old line.
Here is some new line.

Expected Results:  
#ifndef NEW
Here is some old line.
#else /* NEW */
Here is some new line.
#endif /* NEW */

I compiled diffutils 3.8 from GNU and it works OK.

Comment 1 Ralph Campbell 2023-05-09 21:59:07 UTC
I see it is fixed in the upstream git tree: https://git.savannah.gnu.org/git/diffutils.git

The fix is to src/diff.c line 419: (in the diffutils-3.9 source)
< for (i = 0; i < sizeof sizeof C_ifdef_group_formats; i++)
> for (i = 0; i < sizeof C_ifdef_group_formats; i++)

Comment 2 Fedora Update System 2023-06-29 13:23:22 UTC
FEDORA-2023-40ec8ba630 has been submitted as an update to Fedora 38. https://bodhi.fedoraproject.org/updates/FEDORA-2023-40ec8ba630

Comment 3 Fedora Update System 2023-06-30 01:40:02 UTC
FEDORA-2023-40ec8ba630 has been pushed to the Fedora 38 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --refresh --advisory=FEDORA-2023-40ec8ba630`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2023-40ec8ba630

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 4 Fedora Update System 2023-07-01 01:45:41 UTC
FEDORA-2023-40ec8ba630 has been pushed to the Fedora 38 stable repository.
If problem still persists, please make note of it in this bug report.