GNU bug report logs - #79240
Space inside C-strings

Previous Next

Package: diffutils;

Reported by: Gisle Vanem <gvanem <at> yahoo.no>

Date: Fri, 15 Aug 2025 08:28:02 UTC

Severity: normal

To reply to this bug, email your comments to 79240 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-diffutils <at> gnu.org:
bug#79240; Package diffutils. (Fri, 15 Aug 2025 08:28:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Gisle Vanem <gvanem <at> yahoo.no>:
New bug report received and forwarded. Copy sent to bug-diffutils <at> gnu.org. (Fri, 15 Aug 2025 08:28:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Gisle Vanem <gvanem <at> yahoo.no>
To: bug-diffutils <at> gnu.org
Subject: Space inside C-strings
Date: Fri, 15 Aug 2025 10:27:06 +0200
I seem that "diff --ignore-space-change file1 file2"
ignores space-changes *inside* a C-string.

Like with file-1.c:
  char strFl[7] = "  ";
  char strTt[5] = "  ";
  char strGs[5] = "  ";

and file-2.c:
  char strFl[7] = " ";
  char strTt[5] = " ";
  char strGs[5] = " ";

"diff.exe -u3 -b file-1.c file-2.c" gives nothing.

I think this case should be OK for
"--ignore-all-space", not "-b" or "--ignore-space-change".
The manual does not mention spaces inside ""-strings AFAICS.

So how can I use diff to *not* ignore spaces inside C-stings,
but ignore trailing/leading spaces? A regular expression?

-- 
--gv




Information forwarded to bug-diffutils <at> gnu.org:
bug#79240; Package diffutils. (Fri, 15 Aug 2025 23:49:02 GMT) Full text and rfc822 format available.

Message #8 received at 79240 <at> debbugs.gnu.org (full text, mbox):

From: Robert Webb <ro.webbdg <at> gmail.com>
To: 79240 <at> debbugs.gnu.org
Subject: Re: [bug-diffutils] bug#79240: Space inside C-strings
Date: Fri, 15 Aug 2025 16:48:20 -0700
On Fri, Aug 15, 2025 at 1:28 AM Gisle Vanem via bug-diffutils via All
diffutils discussion. <bug-diffutils <at> gnu.org> wrote:
> [...]
> So how can I use diff to *not* ignore spaces inside C-stings,
> but ignore trailing/leading spaces? A regular expression?

In bash:

  sedexpr='s/^  *//;s/  *$//'
  diff <(sed "$sedexpr" file-1.c) <(sed "$sedexpr" file-2.c)

-- 
Robert Webb




This bug report was last modified 21 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.