diff options
author | Dan McGee <dan@archlinux.org> | 2011-08-09 08:00:16 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-15 19:56:41 +0200 |
commit | a628feee46f2200db7d3303091813f050a61d0a3 (patch) | |
tree | 47e9924d205098c48a6ef3db33e4424b9845c0fc /lib/libalpm/deps.c | |
parent | bd5ec9cd8e23bba4334a7b3a5a73843c3667c085 (diff) | |
download | pacman-a628feee46f2200db7d3303091813f050a61d0a3.tar.gz pacman-a628feee46f2200db7d3303091813f050a61d0a3.tar.xz |
Parse conflicts/provides/replaces at database load time
We did this with depends way back in commit c244cfecf654d3 in 2007. We
can do it with these fields as well.
Of note is the inclusion of provides even though only '=' is supported-
we'll parse other things, but no guarantees are given as to behavior,
which is more or less similar to before since we only looked for the
equals sign.
Also of note is the non-inclusion of optdepends; this will likely be
resolved down the road.
The biggest benefactors of this change will be the resolving code that
formerly had to parse and reparse several of these fields; it only
happens once now at load time. This does lead to the disadvantage that
we will now always be parsing this information up front even if we never
need it in the split form, but as these are uncommon fields and our
parser is quite efficient it shouldn't be a big concern.
Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/deps.c')
-rw-r--r-- | lib/libalpm/deps.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index 992ebe23..6869087c 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -384,25 +384,19 @@ int _alpm_depcmp(alpm_pkg_t *pkg, alpm_depend_t *dep) } } - /* check provisions, format : "name=version" */ + /* check provisions, name and version if available */ for(i = alpm_pkg_get_provides(pkg); i && !satisfy; i = i->next) { - const char *provision = i->data; - const char *provver = strchr(provision, '='); - - if(provver == NULL) { /* no provision version */ - satisfy = (dep->mod == ALPM_DEP_MOD_ANY - && strcmp(provision, dep->name) == 0); - } else { - /* This is a bit tricker than the old code for performance reasons. To - * prevent the need to copy and duplicate strings, strncmp only the name - * portion if they are the same length, since there is a version and - * operator in play here. Cast is to silence sign conversion warning; - * we know provver >= provision if we are here. */ - size_t namelen = (size_t)(provver - provision); - provver += 1; - satisfy = (strlen(dep->name) == namelen - && strncmp(provision, dep->name, namelen) == 0 - && dep_vercmp(provver, dep->mod, dep->version)); + alpm_depend_t *provision = i->data; + + if(dep->mod == ALPM_DEP_MOD_ANY) { + /* any version will satisfy the requirement */ + satisfy = (provision->name_hash == dep->name_hash + && strcmp(provision->name, dep->name) == 0); + } else if (provision->mod == ALPM_DEP_MOD_EQ) { + /* provision specifies a version, so try it out */ + satisfy = (provision->name_hash == dep->name_hash + && strcmp(provision->name, dep->name) == 0 + && dep_vercmp(provision->version, dep->mod, dep->version)); } } |