[PATCH 3/3] Act on WS_WARN for ws_mode_trailing.

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

 



Signed-off-by: David Symonds <dsymonds@xxxxxxxxx>
---
 diff.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/diff.c b/diff.c
index 6f9b624..ebcc0f3 100644
--- a/diff.c
+++ b/diff.c
@@ -544,17 +544,22 @@ static void emit_line_with_ws(int nparents,
 	tail = len - 1;
 	if (line[tail] == '\n' && i < tail)
 		tail--;
-	while (i < tail) {
-		if (!isspace(line[tail]))
-			break;
-		tail--;
+	if (ws_mode_trailing != WS_OKAY) {
+		while (i < tail) {
+			if (!isspace(line[tail]))
+				break;
+			tail--;
+		}
 	}
 	if ((i < tail && line[tail + 1] != '\n')) {
 		/* This has whitespace between tail+1..len */
-		fputs(set, stdout);
-		fwrite(line + i, tail - i + 1, 1, stdout);
-		fputs(reset, stdout);
-		emit_line(ws, reset, line + tail + 1, len - tail - 1);
+		if (ws_mode_trailing == WS_WARN) {
+			fputs(set, stdout);
+			fwrite(line + i, tail - i + 1, 1, stdout);
+			fputs(reset, stdout);
+			emit_line(ws, reset, line + tail + 1, len - tail - 1);
+		}
+		/* TODO: handle WS_ERROR and WS_AUTOFIX */
 	}
 	else
 		emit_line(set, reset, line + i, len - i);
-- 
1.5.3.1
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux