From 109e8963f5f82641579f72e4367d427db54dae09 Mon Sep 17 00:00:00 2001 From: Jakob Kramer Date: Tue, 6 May 2014 13:37:05 +0200 Subject: [PATCH] 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)