From: Michael Tremer Date: Sun, 5 Nov 2023 18:33:21 +0000 (+0000) Subject: parse: Remove any trailing line breaks X-Git-Url: http://git.ipfire.org/?p=pakfire.git;a=commitdiff_plain;h=96483cba176ed39d53575cb3da6b6e3cbde5aef6 parse: Remove any trailing line breaks Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/parse.c b/src/libpakfire/parse.c index 7745e9f5..64820f4b 100644 --- a/src/libpakfire/parse.c +++ b/src/libpakfire/parse.c @@ -46,6 +46,11 @@ int pakfire_parse_file(const char* path, pakfire_parse_line parse, void* data) { if (bytes_read < 0) break; + // Remove the trailing newline + if (line[length - 1] == '\n') + line[--length] = '\0'; + + // Call the parse callback function r = parse(line, length, data); if (r) goto ERROR;