if (!*array)
return 1;
- // Append s and terminate the array
- (*array)[length] = s;
+ // Copy the string to the heap
+ char* p = strdup(s);
+ if (!p)
+ return 1;
+
+ // Append p and terminate the array
+ (*array)[length] = p;
(*array)[length + 1] = NULL;
return 0;
struct pakfire_filelist* filelist = NULL;
int r = 1;
- char** files = NULL;
- const char** includes = NULL;
- const char** excludes = NULL;
+ char** includes = NULL;
+ char** excludes = NULL;
+ char* p = NULL;
// Fetch filelist from makefile
- files = pakfire_parser_get_split(makefile, namespace, "files", '\n');
+ char* files = pakfire_parser_get(makefile, namespace, "files");
// No files to package?
if (!files)
return 0;
+ const char* file = strtok_r(files, " \n", &p);
+
// Split into includes and excludes
- for (char** file = files; *file; file++) {
- if (**file == '!')
- r = append_to_array(&excludes, *file + 1);
+ while (file) {
+ if (*file == '!')
+ r = append_to_array(&excludes, file + 1);
else
- r = append_to_array(&includes, *file);
+ r = append_to_array(&includes, file);
if (r)
goto ERROR;
+
+ // Move on to the next token
+ file = strtok_r(NULL, " \n", &p);
}
// Allocate a new filelist
goto ERROR;
// Scan for files
- r = pakfire_filelist_scan(filelist, build->buildroot, includes, excludes);
+ r = pakfire_filelist_scan(filelist, build->buildroot,
+ (const char**)includes, (const char**)excludes);
if (r)
goto ERROR;
ERROR:
if (filelist)
pakfire_filelist_unref(filelist);
- if (buffer)
- free(buffer);
- if (includes)
+ if (files)
+ free(files);
+ if (includes) {
+ for (char** include = includes; *include; include++)
+ free(*include);
free(includes);
- if (excludes)
+ }
+ if (excludes) {
+ for (char** exclude = excludes; *exclude; exclude++)
+ free(*exclude);
free(excludes);
+ }
return r;
}