summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-05-08 05:28:13 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-10-13 08:14:35 -0700
commit3f1f6e79b7ebf246906a6539901571b88bb74067 (patch)
treeb4b50a953124521776ab261dda19309d2d654da3 /parse.c
parent6ecf318c927ffe89a028b8b9cb70d0535673c550 (diff)
Delay converting Requires entries to Packages until after parsing
When the parser encounters Requires or Requires.private, it immediately tries to sees if we have a parsed package for that entry. If not it tries to locate the needed file and parse it out. If there's a circular dependency, this will eventually error opening too many files. Instead, just store the requires entries so the parsing completes and the package is added to the database. After parsing, the entries can be resolved into Packages and any circular requires entries will find the first package in the database. This is a partial fix for Freedesktop #7331.
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c76
1 files changed, 4 insertions, 72 deletions
diff --git a/parse.c b/parse.c
index 76a994c..671ad71 100644
--- a/parse.c
+++ b/parse.c
@@ -523,10 +523,8 @@ parse_module_list (Package *pkg, const char *str, const char *path)
static void
parse_requires (Package *pkg, const char *str, const char *path)
{
- GSList *parsed;
- GSList *iter;
char *trimmed;
-
+
if (pkg->requires)
{
verbose_error ("Requires field occurs twice in '%s'\n", path);
@@ -535,45 +533,15 @@ parse_requires (Package *pkg, const char *str, const char *path)
}
trimmed = trim_and_sub (pkg, str, path);
- parsed = parse_module_list (pkg, trimmed, path);
+ pkg->requires_entries = parse_module_list (pkg, trimmed, path);
g_free (trimmed);
-
- iter = parsed;
- while (iter != NULL)
- {
- Package *req;
- RequiredVersion *ver = iter->data;
-
- req = get_package (ver->name);
-
- if (req == NULL)
- {
- verbose_error ("Package '%s', required by '%s', not found\n",
- ver->name, pkg->name ? pkg->name : path);
-
- exit (1);
- }
-
- if (pkg->required_versions == NULL)
- pkg->required_versions = g_hash_table_new (g_str_hash, g_str_equal);
-
- g_hash_table_insert (pkg->required_versions, ver->name, ver);
-
- pkg->requires = g_slist_prepend (pkg->requires, req);
-
- iter = g_slist_next (iter);
- }
-
- g_slist_free (parsed);
}
static void
parse_requires_private (Package *pkg, const char *str, const char *path)
{
- GSList *parsed;
- GSList *iter;
char *trimmed;
-
+
if (pkg->requires_private)
{
verbose_error ("Requires.private field occurs twice in '%s'\n", path);
@@ -582,36 +550,8 @@ parse_requires_private (Package *pkg, const char *str, const char *path)
}
trimmed = trim_and_sub (pkg, str, path);
- parsed = parse_module_list (pkg, trimmed, path);
+ pkg->requires_private_entries = parse_module_list (pkg, trimmed, path);
g_free (trimmed);
-
- iter = parsed;
- while (iter != NULL)
- {
- Package *req;
- RequiredVersion *ver = iter->data;
-
- req = get_package (ver->name);
-
- if (req == NULL)
- {
- verbose_error ("Package '%s', required by '%s', not found\n",
- ver->name, pkg->name ? pkg->name : path);
-
- exit (1);
- }
-
- if (pkg->required_versions == NULL)
- pkg->required_versions = g_hash_table_new (g_str_hash, g_str_equal);
-
- g_hash_table_insert (pkg->required_versions, ver->name, ver);
-
- pkg->requires_private = g_slist_prepend (pkg->requires_private, req);
-
- iter = g_slist_next (iter);
- }
-
- g_slist_free (parsed);
}
static void
@@ -1152,14 +1092,6 @@ parse_package_file (const char *path, gboolean ignore_requires,
g_string_free (str, TRUE);
fclose(f);
- /* make ->requires_private include a copy of the public requires too */
- pkg->requires_private = g_slist_concat(g_slist_copy (pkg->requires),
- pkg->requires_private);
-
- pkg->requires = g_slist_reverse (pkg->requires);
-
- pkg->requires_private = g_slist_reverse (pkg->requires_private);
-
pkg->I_cflags = g_slist_reverse (pkg->I_cflags);
pkg->other_cflags = g_slist_reverse (pkg->other_cflags);