]> git.ipfire.org Git - pakfire.git/commitdiff
dist: No longer use pakfire_parser_get_split()
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Oct 2023 16:03:14 +0000 (16:03 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 2 Oct 2023 16:03:14 +0000 (16:03 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/dist.c

index 05d7afc46368d0128b42003556733b0efd75833f..0be7044d8d49de1d60842e1a4b13cb3524264a2f 100644 (file)
@@ -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;
 }