From: Michael Tremer Date: Mon, 2 Oct 2023 16:03:14 +0000 (+0000) Subject: dist: No longer use pakfire_parser_get_split() X-Git-Tag: 0.9.30~1566 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6bf130f35f57f84098755db04b857989fd2a5131;p=pakfire.git dist: No longer use pakfire_parser_get_split() Signed-off-by: Michael Tremer --- diff --git a/src/libpakfire/dist.c b/src/libpakfire/dist.c index 05d7afc46..0be7044d8 100644 --- a/src/libpakfire/dist.c +++ b/src/libpakfire/dist.c @@ -298,12 +298,16 @@ static int pakfire_dist_add_source(struct pakfire* pakfire, struct pakfire_packa static int pakfire_dist_add_sources(struct pakfire* pakfire, struct pakfire_packager* packager, struct pakfire_package* pkg, struct pakfire_parser* makefile) { + char* sources = NULL; + char* p = NULL; + int r; + // Fetch sources - char** sources = pakfire_parser_get_split(makefile, NULL, "sources", ' '); + sources = pakfire_parser_get(makefile, NULL, "sources"); // Nothing to do if this variable is empty if (!sources) - return 1; + return 0; struct pakfire_downloader* downloader = NULL; struct pakfire_mirrorlist* mirrorlist = NULL; @@ -315,14 +319,18 @@ static int pakfire_dist_add_sources(struct pakfire* pakfire, struct pakfire_pack goto ERROR; // Add all files one by one - for (char** source = sources; *source; source++) { - DEBUG(pakfire, "Adding source file %s\n", *source); + // Add all mirrors + const char* source = strtok_r(sources, " ", &p); + while (source) { + DEBUG(pakfire, "Adding source file %s\n", source); - r = pakfire_dist_add_source(pakfire, packager, pkg, downloader, mirrorlist, *source); + r = pakfire_dist_add_source(pakfire, packager, pkg, downloader, mirrorlist, source); if (r) { - ERROR(pakfire, "Could not add '%s' to package: %m\n", *source); + ERROR(pakfire, "Could not add '%s' to package: %m\n", source); goto ERROR; } + + source = strtok_r(NULL, " ", &p); } // Success @@ -333,12 +341,8 @@ ERROR: pakfire_downloader_unref(downloader); if (mirrorlist) pakfire_mirrorlist_unref(mirrorlist); - - if (sources) { - for (char** source = sources; *source; source++) - free(*source); + if (sources) free(sources); - } return r; }