From 336ace7f8239bc18a52a1a21fedf8a27f870e55a Mon Sep 17 00:00:00 2001 From: Alexander Larsson Date: Mon, 15 Jun 2015 09:20:58 +0200 Subject: [PATCH] Pass key into parse_package_key so it can be set early We will need this to properly pick up environment-overridden per-package vairables. https://bugs.freedesktop.org/show_bug.cgi?id=90917 --- parse.c | 3 ++- parse.h | 2 +- pkg.c | 34 ++++++++++++++++++---------------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/parse.c b/parse.c index b69f9fc..96beda8 100644 --- a/parse.c +++ b/parse.c @@ -1079,7 +1079,7 @@ parse_line (Package *pkg, const char *untrimmed, const char *path, } Package* -parse_package_file (const char *path, gboolean ignore_requires, +parse_package_file (const char *key, const char *path, gboolean ignore_requires, gboolean ignore_private_libs, gboolean ignore_requires_private) { @@ -1101,6 +1101,7 @@ parse_package_file (const char *path, gboolean ignore_requires, debug_spew ("Parsing package file '%s'\n", path); pkg = g_new0 (Package, 1); + pkg->key = g_strdup (key); if (path) { diff --git a/parse.h b/parse.h index 3169090..8cbbdec 100644 --- a/parse.h +++ b/parse.h @@ -22,7 +22,7 @@ #include "pkg.h" -Package *parse_package_file (const char *path, gboolean ignore_requires, +Package *parse_package_file (const char *key, const char *path, gboolean ignore_requires, gboolean ignore_private_libs, gboolean ignore_requires_private); diff --git a/pkg.c b/pkg.c index a8980f0..a3c5d88 100644 --- a/pkg.c +++ b/pkg.c @@ -267,6 +267,7 @@ static Package * internal_get_package (const char *name, gboolean warn) { Package *pkg = NULL; + char *key; const char *location; GList *iter; @@ -318,21 +319,8 @@ internal_get_package (const char *name, gboolean warn) return NULL; } - debug_spew ("Reading '%s' from file '%s'\n", name, location); - pkg = parse_package_file (location, ignore_requires, ignore_private_libs, - ignore_requires_private); - - if (pkg == NULL) - { - debug_spew ("Failed to parse '%s'\n", location); - return NULL; - } - - if (strstr (location, "uninstalled.pc")) - pkg->uninstalled = TRUE; - if (location != name) - pkg->key = g_strdup (name); + key = g_strdup (name); else { /* need to strip package name out of the filename */ @@ -344,10 +332,24 @@ internal_get_package (const char *name, gboolean warn) --start; g_assert (end >= start); - - pkg->key = g_strndup (start, end - start); + + key = g_strndup (start, end - start); } + debug_spew ("Reading '%s' from file '%s'\n", name, location); + pkg = parse_package_file (key, location, ignore_requires, ignore_private_libs, + ignore_requires_private); + g_free (key); + + if (pkg == NULL) + { + debug_spew ("Failed to parse '%s'\n", location); + return NULL; + } + + if (strstr (location, "uninstalled.pc")) + pkg->uninstalled = TRUE; + pkg->path_position = GPOINTER_TO_INT (g_hash_table_lookup (path_positions, pkg->key)); -- 2.4.2