From: Michael Tremer Date: Mon, 2 Oct 2023 16:09:26 +0000 (+0000) Subject: package: Split descriptions using strtok() X-Git-Tag: 0.9.30~1564 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=45f9e649c2c1e2f3f5bc1e9d3af4d0de51450d14;p=pakfire.git package: Split descriptions using strtok() Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/package.c b/src/libpakfire/package.c index 0209e596f..dbe5298a8 100644 --- a/src/libpakfire/package.c +++ b/src/libpakfire/package.c @@ -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) {