]> git.ipfire.org Git - pakfire.git/commitdiff
parse: Remove any trailing line breaks
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Nov 2023 18:33:21 +0000 (18:33 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 5 Nov 2023 18:33:21 +0000 (18:33 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/parse.c

index 7745e9f5f9d9f5ddcc1e97d175d32936f699078c..64820f4b9158d96690f5f0cafd628eb833c13154 100644 (file)
@@ -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;