From 53f5d329a01a8b09658423009837c146759bce2d Mon Sep 17 00:00:00 2001 From: Waldemar Brodkorb Date: Fri, 18 Oct 2013 19:05:53 +0200 Subject: man page of strdup says it: These functions modify their first argument., fix multiple PKG_{HOST,SYSTEM,LIBC,ARCH}_DEPENDS for subpackages --- tools/adk/pkgmaker.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/adk/pkgmaker.c b/tools/adk/pkgmaker.c index e83c581a8..2be187a40 100644 --- a/tools/adk/pkgmaker.c +++ b/tools/adk/pkgmaker.c @@ -273,7 +273,7 @@ int main() { char *pkg_need_cxx, *pkg_need_java, *pkgname; char *pkg_libc_depends, *pkg_host_depends, *pkg_system_depends, *pkg_arch_depends, *pkg_flavours, *pkg_flavours_string, *pkg_choices, *pseudo_name; char *packages, *pkg_name_u, *pkgs; - char *saveptr, *p_ptr, *s_ptr; + char *saveptr, *p_ptr, *s_ptr, *pkg_helper; int result; StrMap *pkgmap, *sectionmap; @@ -297,6 +297,7 @@ int main() { pkg_need_cxx = NULL; pkg_need_java = NULL; pkgname = NULL; + pkg_helper = NULL; p_ptr = NULL; s_ptr = NULL; @@ -617,7 +618,8 @@ int main() { /* create package target system dependency information */ if (pkg_system_depends != NULL) { - token = strtok(pkg_system_depends, " "); + pkg_helper = strdup(pkg_system_depends); + token = strtok(pkg_helper, " "); fprintf(cfg, "\tdepends on "); sp = ""; while (token != NULL) { @@ -631,10 +633,13 @@ int main() { token = strtok(NULL, " "); } fprintf(cfg, "\n"); + free(pkg_helper); + pkg_helper = NULL; } /* create package host dependency information */ if (pkg_host_depends != NULL) { - token = strtok(pkg_host_depends, " "); + pkg_helper = strdup(pkg_host_depends); + token = strtok(pkg_helper, " "); fprintf(cfg, "\tdepends on "); sp = ""; while (token != NULL) { @@ -648,11 +653,14 @@ int main() { token = strtok(NULL, " "); } fprintf(cfg, "\n"); + free(pkg_helper); + pkg_helper = NULL; } /* create package libc dependency information */ if (pkg_libc_depends != NULL) { - token = strtok(pkg_libc_depends, " "); + pkg_helper = strdup(pkg_libc_depends); + token = strtok(pkg_helper, " "); fprintf(cfg, "\tdepends on "); sp = ""; while (token != NULL) { @@ -666,10 +674,13 @@ int main() { token = strtok(NULL, " "); } fprintf(cfg, "\n"); + free(pkg_helper); + pkg_helper = NULL; } /* create package target architecture dependency information */ if (pkg_arch_depends != NULL) { - token = strtok(pkg_arch_depends, " "); + pkg_helper = strdup(pkg_arch_depends); + token = strtok(pkg_helper, " "); fprintf(cfg, "\tdepends on "); sp = ""; while (token != NULL) { @@ -683,6 +694,8 @@ int main() { token = strtok(NULL, " "); } fprintf(cfg, "\n"); + free(pkg_helper); + pkg_helper = NULL; } /* create package dependency information */ -- cgit v1.2.3