[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
patch: do not emit trailing blanks in context header
From: |
Jim Meyering |
Subject: |
patch: do not emit trailing blanks in context header |
Date: |
Mon, 04 Sep 2006 11:16:32 +0200 |
Hi Paul,
Here's a little patch to avoid emitting trailing white space
in context headers:
2006-09-04 Jim Meyering <address@hidden>
* src/context.c (print_context_function): Do not print
trailing white space in a context header.
Index: src/context.c
===================================================================
RCS file: /sources/diffutils/diffutils/src/context.c,v
retrieving revision 1.18
diff -u -r1.18 context.c
--- src/context.c 7 May 2006 08:16:19 -0000 1.18
+++ src/context.c 4 Sep 2006 08:59:07 -0000
@@ -137,6 +137,9 @@
putc (' ', out);
for (i = 0; i < 40 && function[i] != '\n'; i++)
continue;
+ /* Trim any trailing white space. */
+ while (0 < i && isspace ((unsigned char) function[i - 1]))
+ --i;
fwrite (function, sizeof (char), i, out);
}
This doesn't really matter, of course, but when the only trailing blanks
in a diff are those in context headers, it's a little annoying.
You can demonstrate/test with these commands:
(printf '%-40s\n' f; printf '1\n') > 1
(printf '%-40s\n' f; printf '2\n') > 2
diff -u0 -p 1 2 | cat -A
diff.old -u0 -p 1 2 | cat -A
Here's the output I get:
--- 1^I2006-09-04 11:08:12.610304116 +0200$
+++ 2^I2006-09-04 11:08:12.621301533 +0200$
@@ -2 +2 @@ f$
-1$
+2$
--- 1^I2006-09-04 11:08:12.610304116 +0200$
+++ 2^I2006-09-04 11:08:12.621301533 +0200$
@@ -2 +2 @@ f $
-1$
+2$
- patch: do not emit trailing blanks in context header,
Jim Meyering <=
- Re: patch: do not emit trailing blanks in context header, Paul Eggert, 2006/09/05
- Re: patch: do not emit trailing blanks in context header, Paul Eggert, 2006/09/05
- Re: patch: do not emit trailing blanks in context header, Jim Meyering, 2006/09/05
- Re: patch: do not emit trailing blanks in context header, Chuck Swiger, 2006/09/05
- Re: patch: do not emit trailing blanks in context header, Paul Eggert, 2006/09/05