From 1f4dd6178818d0950afe4eae0cfe97d0cd30f453 Mon Sep 17 00:00:00 2001 From: Alex 'AdUser' Z Date: Mon, 25 Jan 2021 11:31:36 +1000 Subject: [PATCH] * source/files : strip newline --- src/sources/files.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sources/files.c b/src/sources/files.c index 0490f91..7ffcee1 100644 --- a/src/sources/files.c +++ b/src/sources/files.c @@ -107,6 +107,7 @@ file_rotated(const cfg_t *cfg, f2b_file_t *file) { static bool file_getline(f2b_file_t *file, char *buf, size_t bufsize) { + char *p; assert(file != NULL); assert(buf != NULL); @@ -114,6 +115,8 @@ file_getline(f2b_file_t *file, char *buf, size_t bufsize) { clearerr(file->fd); /* fread()+EOF set is implementation defined */ if (fgets(buf, bufsize, file->fd) != NULL) { + if ((p = strchr(buf, '\n')) != NULL) + *p = '\0'; /* strip newline(s) */ file->lines++; return true; }