Bug 230049 - OpenBSD diff (WITHOUT_GNU_DIFF) --strip-trailing-cr is incorrect
Summary: OpenBSD diff (WITHOUT_GNU_DIFF) --strip-trailing-cr is incorrect
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Only Me
Assignee: Xin LI
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-07-26 05:57 UTC by maskray
Modified: 2018-07-27 05:30 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description maskray 2018-07-26 05:57:54 UTC
% printf 'a\nb\r\nc\n' > a
% printf 'a\r\nb\r\nc\r\n' > b
% diff --strip-trailing-cr a b
...
@@ -1,3 +1,3 @@
 a
b
-c
+

GNU diff would report no difference.

The --strip-trailing-cr issue caused an LLVM test test/MC/AsmParser/preserve-comments-crlf.s to fail.
Comment 1 Xin LI freebsd_committer freebsd_triage 2018-07-26 08:46:20 UTC
Please try: https://reviews.freebsd.org/D16451
Comment 2 commit-hook freebsd_committer freebsd_triage 2018-07-27 05:21:49 UTC
A commit references this bug:

Author: delphij
Date: Fri Jul 27 05:21:20 UTC 2018
New revision: 336754
URL: https://svnweb.freebsd.org/changeset/base/336754

Log:
  Improve --strip-trailing-cr handling:

   - Advance ctold for f1 and ctnew for f2
   - ungetc() if the character is unexpected
   - Don't break early when we hit the combination on one side

  PR:		230049
  Reported by:	maskray <emacsray gmail com>
  Reviewed by:	bapt, maskray
  MFC after:	2 weeks
  Differential Revision:	https://reviews.freebsd.org/D16451

Changes:
  head/usr.bin/diff/diffreg.c
  head/usr.bin/diff/tests/diff_test.sh