[Bug 270643] Malformed output when comparing files with lines longer than 512 characters

From: <bugzilla-noreply_at_freebsd.org>
Date: Tue, 04 Apr 2023 17:05:08 UTC

            Bug ID: 270643
           Summary: Malformed output when comparing files with lines
                    longer than 512 characters
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: siegel@barebones.com

Created attachment 241299
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=241299&action=edit
Zip archive containing example files and output

When comparing files which have lines longer than 512 characters, the output
generated by `diff` truncates the long line, *and* fails to add a line break
after it. This causes the next diff indicator to be missed.

- unzip the attached archive ("VenturaDiffBug.zip").

- open a Terminal window, and cd into the resulting folder.

- run this command:

      `diff --text file2.txt file1.txt`

Expected result:

=> The output should look like:

< -     617149952       616901632       616308736       615692800      
615050752       614669312       613733120       612807680       612417792      
611426560       611000320       610260480       609772544       609525504      
609511936       609338880... (remainder omitted for brevity)
> -	617149952	616901632	

Actual result:

=> The first "<" diff gets truncated at exactly 512 characters, and then the
second diff is appended immediately thereafter with no intervening line break,
so the output looks like this (see `diffoutput.txt` in the archive):

< -     617149952       616901632       [...omitted for brevity...] 604445442a2
> -	617149952	616901632	

Note the "`2a2`" at the end of the first line of context; this should start on
a new line, but doesn't. Consequently, interpreting the diff output presents
incorrect results to the user.

You are receiving this mail because:
You are the assignee for the bug.