diff options
Diffstat (limited to 'system/pkgconf/personality.patch')
-rw-r--r-- | system/pkgconf/personality.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/system/pkgconf/personality.patch b/system/pkgconf/personality.patch new file mode 100644 index 000000000..e7ff9ad9a --- /dev/null +++ b/system/pkgconf/personality.patch @@ -0,0 +1,55 @@ +From d926e75b345a6948e4e976828d3331cd7f0db660 Mon Sep 17 00:00:00 2001 +From: Emil Renner Berthing <esmil@mailme.dk> +Date: Wed, 6 Mar 2019 16:03:32 +0100 +Subject: [PATCH] main: fix personalities when argv[0] contains path + +--- + cli/main.c | 31 ++++++++++++++++++++----------- + 1 file changed, 20 insertions(+), 11 deletions(-) + +diff --git a/cli/main.c b/cli/main.c +index b52cc85..caa2525 100644 +--- a/cli/main.c ++++ b/cli/main.c +@@ -740,21 +740,30 @@ dump_personality(const pkgconf_cross_personality_t *p) + static pkgconf_cross_personality_t * + deduce_personality(char *argv[]) + { +- char *workbuf = strdup(argv[0]), *i; +- pkgconf_cross_personality_t *out = pkgconf_cross_personality_default(), *deduced; ++ const char *argv0 = argv[0]; ++ char *i, *prefix; ++ pkgconf_cross_personality_t *out; ++ ++ i = strrchr(argv0, '/'); ++ if (i != NULL) ++ argv0 = i + 1; ++ ++#if defined(_WIN32) || defined(_WIN64) ++ i = strrchr(argv0, '\\'); ++ if (i != NULL) ++ argv0 = i + 1; ++#endif + +- i = strstr(workbuf, "-pkg"); ++ i = strstr(argv0, "-pkg"); + if (i == NULL) +- goto finish; +- +- *i = 0; ++ return pkgconf_cross_personality_default(); + +- deduced = pkgconf_cross_personality_find(workbuf); +- if (deduced != NULL) +- out = deduced; ++ prefix = strndup(argv0, i - argv0); ++ out = pkgconf_cross_personality_find(prefix); ++ free(prefix); ++ if (out == NULL) ++ return pkgconf_cross_personality_default(); + +-finish: +- free(workbuf); + return out; + } + |