]> git.ipfire.org Git - people/ms/pakfire.git/commitdiff
package: Split descriptions using strtok()
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Oct 2023 16:09:26 +0000 (16:09 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Oct 2023 16:09:26 +0000 (16:09 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/package.c

index 0209e596f9065becbf90a029a6e2b1eef4e49a65..dbe5298a87411d9871a406e185938ddd6dc5b8f9 100644 (file)
@@ -1490,12 +1490,24 @@ static void pakfire_package_dump_add_lines(char** str, const char* key, char** l
 }
 
 static void pakfire_package_dump_add_long_line(char** str, const char* key, const char* val) {
-       char** lines = pakfire_string_split(val, '\n');
-       if (!lines)
+       char* p = NULL;
+
+       // Copy the string onto the heap
+       char* buffer = strdupa(val);
+       if (!buffer)
                return;
 
-       pakfire_package_dump_add_lines(str, key, lines);
-       pakfire_strings_free(lines);
+       const char* line = strtok_r(buffer, "\n", &p);
+
+       while (line) {
+               pakfire_package_dump_add_line(str, key, line);
+
+               // Reset the key
+               key = NULL;
+
+               // Go to the next line
+               line = strtok_r(NULL, "\n", &p);
+       }
 }
 
 static void pakfire_package_dump_add_line_date(char** str, const char* key, time_t date) {