From 260c87e5166e00e90463b88b2a75862173a8dc44 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Sun, 8 Sep 2024 16:55:17 +0200 Subject: grijp: Handel einde van de regel goed af --- src/grijp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/grijp.c') diff --git a/src/grijp.c b/src/grijp.c index a17e295..d94cba8 100644 --- a/src/grijp.c +++ b/src/grijp.c @@ -139,7 +139,7 @@ static void print_match(char *fname, char *line) { printf("%s:", fname); } - printf("%s", line); + printf("%s\n", line); } static int process(char *fname, bool isstdin) { @@ -157,6 +157,8 @@ static int process(char *fname, bool isstdin) { ssize_t nread = 0; while ((errno = 0, nread = getline(&line, &linecap, stream)) != -1) { + if (nread > 0 && line[nread-1] == '\n') line[--nread] = '\0'; + for (size_t i = 0; i < npat; i++) { bool matches = false; -- cgit v1.2.3-70-g09d2