diff options
author | Tom Smeding <tom@tomsmeding.com> | 2024-09-08 16:55:17 +0200 |
---|---|---|
committer | Tom Smeding <tom@tomsmeding.com> | 2024-09-08 16:55:17 +0200 |
commit | 260c87e5166e00e90463b88b2a75862173a8dc44 (patch) | |
tree | 489ca7d3df8d8b9d285c31dbc3be7031c6785c0c /src | |
parent | 1a9c6854719b37f42390cbcb5670f67963c16767 (diff) |
grijp: Handel einde van de regel goed af
Diffstat (limited to 'src')
-rw-r--r-- | src/grijp.c | 4 |
1 files changed, 3 insertions, 1 deletions
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; |