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

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

Re: patch: do not emit trailing blanks in context header


From: Paul Eggert
Subject: Re: patch: do not emit trailing blanks in context header
Date: Tue, 05 Sep 2006 16:09:44 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Chuck Swiger <address@hidden> writes:

> Would the existing -b, -w, or -B options to diff help?

No, because they affect only input.

Jim had good arguments.  I installed this change, and have filed a
change request with the POSIX committee, since diff -u will be
standardized in the next major release.  See
<https://www.opengroup.org/sophocles/show_mail.tpl?source=L&listname=austin-review-l&id=2140>.


2006-09-05  Paul Eggert  <address@hidden>

        * NEWS: diff -u no longer outputs trailing white space unless the
        input data has it.  Suggested by Jim Meyering.
        * doc/diff.texi (Detailed Unified): Document this.
        * src/context.c (pr_unidiff_hunk): Implement this.

--- NEWS.~1.24.~        2006-01-04 23:23:46.000000000 -0800
+++ NEWS        2006-09-05 16:01:26.000000000 -0700
@@ -1,5 +1,8 @@
 User-visible changes since 2.8.7 (in "version" 2.8.7-cvs):
 
+* When reporting an unchanged empty line, diff -u now outputs an
+  empty line instead of a line consisting of a single space character.
+
 * Bring back support for `diff -NUM', where NUM is a number,
   even when conforming to POSIX 1003.1-2001.  This change reverts to
   the behavior of GNU diff 2.7 and earlier.  This is a change only
--- doc/diff.texi       26 Jul 2006 06:20:59 -0000      1.28
+++ doc/diff.texi       5 Sep 2006 22:44:15 -0000
@@ -836,7 +836,8 @@ line numbers look like @address@hidden
 its end line number appears.  An empty hunk is considered to end at
 the line that precedes the hunk.
 
-The lines common to both files begin with a space character.  The lines
+Lines common to both files begin with a space character, except that
+the space is omitted if its line is empty.  Lines
 that actually differ between the two files have one of the following
 indicator characters in the left print column:
 
--- src/context.c       5 Sep 2006 14:04:57 -0000       1.19
+++ src/context.c       5 Sep 2006 22:44:15 -0000
@@ -337,8 +337,10 @@ pr_unidiff_hunk (struct change *hunk)
 
       if (!next || i < next->line0)
        {
-         putc (initial_tab ? '\t' : ' ', out);
-         print_1_line (NULL, &files[0].linbuf[i++]);
+         char const *const *line = &files[0].linbuf[i++];
+         if (**line != '\n')
+           putc (initial_tab ? '\t' : ' ', out);
+         print_1_line (NULL, line);
          j++;
        }
       else




reply via email to

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