aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2018-05-18 18:55:58 +0200
committerFabian Groffen <grobian@gentoo.org>2018-05-18 18:55:58 +0200
commita7d916ac978023fe35dcd8666d7bc913bab3b0a9 (patch)
tree18bea27ad57589ecf70e330c484fa82f448a10e2 /libq/atom_explode.c
parentqtegrity: fix signedness warning (diff)
downloadportage-utils-a7d916ac978023fe35dcd8666d7bc913bab3b0a9.tar.gz
portage-utils-a7d916ac978023fe35dcd8666d7bc913bab3b0a9.tar.bz2
portage-utils-a7d916ac978023fe35dcd8666d7bc913bab3b0a9.zip
atom_explode: find the last version-like component
We need to keep on searching until we reached the end of the package/version string, since package names may contain things which are valid versions, as long as they don't end with them. Bug: https://bugs.gentoo.org/567336
Diffstat (limited to 'libq/atom_explode.c')
-rw-r--r--libq/atom_explode.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/libq/atom_explode.c b/libq/atom_explode.c
index 07d9cecd..a4ba5690 100644
--- a/libq/atom_explode.c
+++ b/libq/atom_explode.c
@@ -193,27 +193,32 @@ atom_explode(const char *atom)
* doesn't validate as version :( */
ptr = ret->PN;
- while ((ptr = strchr(ptr, '-')) != NULL) {
+ {
+ char *lastpv = NULL;
char *pv;
- ptr++;
- if (!isdigit(*ptr))
- continue;
- /* so we should have something like "-2" here, see if this
- * checks out as valid version string */
- pv = ptr;
- while (*++ptr != '\0') {
- if (*ptr != '.' && !isdigit(*ptr))
- break;
- }
- /* allow for 1 optional suffix letter */
- if (*ptr >= 'a' && *ptr <= 'z')
- ret->letter = *ptr++;
- if (*ptr == '_' || *ptr == '\0' || *ptr == '-') {
- ptr = pv;
- break; /* valid */
+ while ((ptr = strchr(ptr, '-')) != NULL) {
+ ptr++;
+ if (!isdigit(*ptr))
+ continue;
+
+ /* so we should have something like "-2" here, see if this
+ * checks out as valid version string */
+ pv = ptr;
+ while (*++ptr != '\0') {
+ if (*ptr != '.' && !isdigit(*ptr))
+ break;
+ }
+ /* allow for 1 optional suffix letter */
+ if (*ptr >= 'a' && *ptr <= 'z')
+ ret->letter = *ptr++;
+ if (*ptr == '_' || *ptr == '\0' || *ptr == '-') {
+ lastpv = pv;
+ continue; /* valid, keep searching */
+ }
+ ret->letter = '\0';
}
- ret->letter = '\0';
+ ptr = lastpv;
}
if (ptr == NULL) {