Store the original prefix value in the package

Avoids making implicit assumptions about parse ordering needed to store
the original prefix as a static file local variable.
This commit is contained in:
Dan Nicholson 2013-04-17 07:56:19 -07:00
parent a65d5cff5f
commit f655cf91a0
2 changed files with 10 additions and 9 deletions

16
parse.c
View file

@ -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

3
pkg.h
View file

@ -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);