Subject: bug#19825: unified output format, number of consecutive unaffected lines, and POSIX

From: Vincent Lefevre <[email-masked]>
Date: Tue, 10 Feb 2015 03:23:48 +0100

Concerning the unified output format, POSIX says in

  http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html

  "If -U n is specified, the output shall contain no more than
  n consecutive unaffected lines; and if the output contains an
  affected line and this line is adjacent to up to n consecutive
  unaffected lines in the corresponding file, the output shall
  contain these unaffected lines. -u shall act like -U3."

but with GNU diff and n = 3, one can get up to 6 consecutive
unaffected lines:

@@ -1,14 +1,14 @@
 1
 2
 3
-4
+4b
 5
 6
 7
 8
 9
 10
-11
+11b
 12
 13
 14

I actually think that the GNU diff behavior is better than POSIX.
And it is quite strange that POSIX specifies something different
because this format comes from GNU diff!

I think that the GNU diff manual should say something about this
difference. Or could this be regarded as a defect in POSIX?

Note: I noticed this after seeing that Subversion's internal diff
behaves again differently, with a behavior between GNU diff and
POSIX: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=777479#17

-- 
Vincent Lefèvre <[email-masked]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)