[PATCH 3/8] Store the original prefix value in the package

Dan Nicholson dbn.lists at gmail.com
Sat Apr 20 07:42:20 PDT 2013


Avoids making implicit assumptions about parse ordering needed to store
the original prefix as a static file local variable.
---
 parse.c | 16 +++++++---------
 pkg.h   |  3 +++
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/parse.c b/parse.c
index 6c48e94..2809735 100644
--- a/parse.c
+++ b/parse.c
@@ -855,10 +855,6 @@ parse_url (Package *pkg, const char *str, const char *path)
   pkg->url = trim_and_sub (pkg, str, path);
 }
 
-#ifdef G_OS_WIN32
-static char *orig_prefix = NULL;
-#endif
-
 static void
 parse_line (Package *pkg, const char *untrimmed, const char *path,
 	    gboolean ignore_requires, gboolean ignore_private_libs,
@@ -971,7 +967,8 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
               gchar *q;
               gchar *prefix;
 	      
-              orig_prefix = g_strdup (p);
+              /* Keep track of the original prefix value. */
+              pkg->orig_prefix = g_strdup (p);
 
               /* Get grandparent directory for new prefix. */
               q = g_path_get_dirname (pkg->pcfiledir);
@@ -1005,13 +1002,14 @@ parse_line (Package *pkg, const char *untrimmed, const char *path,
 	    }
 	}
       else if (define_prefix &&
-	       orig_prefix != NULL &&
-	       strncmp (p, orig_prefix, strlen (orig_prefix)) == 0 &&
-	       G_IS_DIR_SEPARATOR (p[strlen (orig_prefix)]))
+	       pkg->orig_prefix != NULL &&
+	       strncmp (p, pkg->orig_prefix, strlen (pkg->orig_prefix)) == 0 &&
+	       G_IS_DIR_SEPARATOR (p[strlen (pkg->orig_prefix)]))
 	{
 	  char *oldstr = str;
 
-	  p = str = g_strconcat (g_hash_table_lookup (pkg->vars, prefix_variable), p + strlen (orig_prefix), NULL);
+	  p = str = g_strconcat (g_hash_table_lookup (pkg->vars, prefix_variable),
+				 p + strlen (pkg->orig_prefix), NULL);
 	  g_free (oldstr);
 	}
 #endif
diff --git a/pkg.h b/pkg.h
index 74687dc..fe50e87 100644
--- a/pkg.h
+++ b/pkg.h
@@ -85,6 +85,9 @@ struct _Package
   int libs_num; /* Number of times the "Libs" header has been seen */
   int libs_private_num;  /* Number of times the "Libs.private" header has been seen */
   gboolean in_requires_chain; /* package is in current Requires chain */
+#ifdef G_OS_WIN32
+  char *orig_prefix; /* original prefix value before redefinition */
+#endif
 };
 
 Package *get_package               (const char *name);
-- 
1.8.1.4



More information about the pkg-config mailing list