bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

diff-2.7.7 creates non POSIX compliant context diff


From: Bruno Haible
Subject: diff-2.7.7 creates non POSIX compliant context diff
Date: Wed, 17 Apr 2002 16:34:49 +0200 (CEST)

Here is a case where "diff" creates a patch that is not compliant to
POSIX:2001.

$ cat > foo.bak << EOF
one
two
three
EOF
$ cat > foo << EOF
one
EOF
$ diff --version | head -1
diff (GNU diffutils) 2.7.7
$ diff -c foo.bak foo
*** foo.bak     2002-04-17 01:32:09.000000000 +0200
--- foo 2002-04-17 01:32:13.000000000 +0200
***************
*** 1,3 ****
  one
- two
- three
--- 1 ----

Two things are wrong with this output. I'm referring to XCU section "diff",
subsection "Diff -c or -C Output Format".

1) The line "--- 1 ----" should read "--- 1,1 ----" because POSIX says:

   Next, the range of lines in file2 shall be written in the following format:

   "--- %d,%d ----\n", <beginning line number>, <ending line number>

Note: This is a real interoperability problem: My contextdiff to unidiff
converter [ftp://ftp.ilog.fr/pub/Users/haible/gnu/diffconvert-1.2.tar.gz]
produces correct output when fed with the "--- 1,1 ----" line but incorrect
output (rejected by "patch") when fed with the "--- 1 ----" line.

2) A line from file foo, containing "one", is missing at the end. It has been
   traditional behaviour of "diff" to omit the line range from file2 if there
   were only removals in this hunk, and to omit the line range from file1 if
   there have been only additions in this hunk. But POSIX:2001 doesn't allow
   this kind of shortcut.

Bruno



reply via email to

[Prev in Thread] Current Thread [Next in Thread]