Respect path ordering for unversioned requires

svn path=/trunk/; revision=778
This commit is contained in:
Colin Walters 2008-10-21 18:41:36 +00:00
parent 727bb01805
commit adc6a3e2ef

View File

@ -858,6 +858,7 @@ compare_version (const char *v1,
struct NamespaceVersionCandidadate struct NamespaceVersionCandidadate
{ {
GMappedFile *mfile; GMappedFile *mfile;
int path_index;
char *path; char *path;
char *version; char *version;
}; };
@ -867,12 +868,24 @@ compare_candidate_reverse (struct NamespaceVersionCandidadate *c1,
struct NamespaceVersionCandidadate *c2) struct NamespaceVersionCandidadate *c2)
{ {
int result = compare_version (c1->version, c2->version); int result = compare_version (c1->version, c2->version);
/* First, check the version */
if (result > 0) if (result > 0)
return -1; return -1;
else if (result < 0) else if (result < 0)
return 1; return 1;
else else
return 0; {
/* Now check the path index, which says how early in the search path
* we found it. This ensures that of equal version targets, we
* pick the earlier one.
*/
if (c1->path_index == c2->path_index)
return 0;
else if (c1->path_index > c2->path_index)
return 1;
else
return -1;
}
} }
static void static void
@ -895,13 +908,15 @@ find_namespace_latest (const gchar *namespace,
char *namespace_typelib; char *namespace_typelib;
GSList *candidates = NULL; GSList *candidates = NULL;
GMappedFile *result = NULL; GMappedFile *result = NULL;
int index;
*version_ret = NULL; *version_ret = NULL;
*path_ret = NULL; *path_ret = NULL;
namespace_dash = g_strdup_printf ("%s-", namespace); namespace_dash = g_strdup_printf ("%s-", namespace);
namespace_typelib = g_strdup_printf ("%s.typelib", namespace); namespace_typelib = g_strdup_printf ("%s.typelib", namespace);
index = 0;
for (ldir = search_path; ldir; ldir = ldir->next) for (ldir = search_path; ldir; ldir = ldir->next)
{ {
GDir *dir; GDir *dir;
@ -947,11 +962,13 @@ find_namespace_latest (const gchar *namespace,
} }
candidate = g_new0 (struct NamespaceVersionCandidadate, 1); candidate = g_new0 (struct NamespaceVersionCandidadate, 1);
candidate->mfile = mfile; candidate->mfile = mfile;
candidate->path_index = index;
candidate->path = path; candidate->path = path;
candidate->version = version; candidate->version = version;
candidates = g_slist_prepend (candidates, candidate); candidates = g_slist_prepend (candidates, candidate);
} }
g_dir_close (dir); g_dir_close (dir);
index++;
} }
if (candidates != NULL) if (candidates != NULL)