index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-08-28 23:29:53 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-29 19:54:18 -0500 |
commit | 499e09734bc6f4a121b3363d88aeb085bcfd9ce9 (patch) | |
tree | 029709f8e021f17a6f9c57100af92e45b91ff87f /lib/libalpm/deps.c | |
parent | b3c0ae5205ee9615af077ff00b1a01be3aab4eb6 (diff) |
-rw-r--r-- | lib/libalpm/deps.c | 32 |
diff --git a/lib/libalpm/deps.c b/lib/libalpm/deps.c index e268157a..639f14ba 100644 --- a/lib/libalpm/deps.c +++ b/lib/libalpm/deps.c @@ -410,31 +410,37 @@ alpm_depend_t *_alpm_splitdep(const char *depstring) { alpm_depend_t *depend; const char *ptr, *version = NULL; + size_t deplen; if(depstring == NULL) { return NULL; } CALLOC(depend, 1, sizeof(alpm_depend_t), return NULL); + deplen = strlen(depstring); /* Find a version comparator if one exists. If it does, set the type and * increment the ptr accordingly so we can copy the right strings. */ - if((ptr = strstr(depstring, ">="))) { - depend->mod = ALPM_DEP_MOD_GE; - version = ptr + 2; - } else if((ptr = strstr(depstring, "<="))) { - depend->mod = ALPM_DEP_MOD_LE; - version = ptr + 2; - } else if((ptr = strstr(depstring, "="))) { + if((ptr = memchr(depstring, '<', deplen))) { + if(ptr[1] == '=') { + depend->mod = ALPM_DEP_MOD_LE; + version = ptr + 2; + } else { + depend->mod = ALPM_DEP_MOD_LT; + version = ptr + 1; + } + } else if((ptr = memchr(depstring, '>', deplen))) { + if(ptr[1] == '=') { + depend->mod = ALPM_DEP_MOD_GE; + version = ptr + 2; + } else { + depend->mod = ALPM_DEP_MOD_GT; + version = ptr + 1; + } + } else if((ptr = memchr(depstring, '=', deplen))) { /* Note: we must do =,<,> checks after <=, >= checks */ depend->mod = ALPM_DEP_MOD_EQ; version = ptr + 1; - } else if((ptr = strstr(depstring, "<"))) { - depend->mod = ALPM_DEP_MOD_LT; - version = ptr + 1; - } else if((ptr = strstr(depstring, ">"))) { - depend->mod = ALPM_DEP_MOD_GT; - version = ptr + 1; } else { /* no version specified, leave version and ptr NULL */ depend->mod = ALPM_DEP_MOD_ANY; |