without this it would sort a blank line *after*
lines that have leading white space.
>From 8dcf7e1a8070661280436c3cf8b5caa53a75dce6 Mon Sep 17 00:00:00 2001
From: Jakob Kramer <jakob.kra...@gmx.de>
Date: Tue, 6 May 2014 13:37:05 +0200
Subject: [PATCH 2/3] sort: ignore trailing newline while sorting

---
 sort.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sort.c b/sort.c
index 1d5f325..26d287d 100644
--- a/sort.c
+++ b/sort.c
@@ -245,7 +245,8 @@ columns(char *line, const struct keydef *kd)
 		else
 			end = end_column(end);
 	} else {
-		end = line + strlen(line);
+		if((end = strchr(line, '\n')) == NULL)
+			end = strchr(line, '\0');
 	}
 
 	if((res = strndup(start, end - start)) == NULL)
-- 
1.8.5.1

Reply via email to