From 134458b85ae8e2b1a7d2d9e9a130af0e85db44c3 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 31 Jan 2019 17:50:49 +0100 Subject: [PATCH] file processing: remove trailing spaces from line Such as a line feed left there by getline(). Signed-off-by: David Oberhollenzer --- main/cmd/pack/input_file.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main/cmd/pack/input_file.c b/main/cmd/pack/input_file.c index 3e88d92..75c0691 100644 --- a/main/cmd/pack/input_file.c +++ b/main/cmd/pack/input_file.c @@ -40,6 +40,15 @@ retry: if (ptr != f->line) memmove(f->line, ptr, strlen(ptr) + 1); + + ptr = f->line + strlen(f->line); + + while (ptr > f->line && isspace(ptr[-1])) + --ptr; + *ptr = '\0'; + + if (f->line[0] == '\0') + goto retry; return 0; }