diff options
-rw-r--r-- | libq/atom_explode.c | 41 | ||||
-rwxr-xr-x | tests/qatom/dotest | 3 |
2 files changed, 26 insertions, 18 deletions
diff --git a/libq/atom_explode.c b/libq/atom_explode.c index 07d9cec..a4ba569 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) { diff --git a/tests/qatom/dotest b/tests/qatom/dotest index 01900e6..c879624 100755 --- a/tests/qatom/dotest +++ b/tests/qatom/dotest @@ -51,5 +51,8 @@ test f15 "app-emacs diff-mode-" \ test f16 "media-fonts font-adobe-100dpi 1.0.3 r1" \ -F '%{CATEGORY} %{PN} %{PV} %{PR}' \ "media-fonts/font-adobe-100dpi-1.0.3-r1" +test f17 "games-rpg eschalon-book-1-demo 106 r1" \ + -F '%{CATEGORY} %{PN} %{PV} %{PR}' \ + "games-rpg/eschalon-book-1-demo-106-r1" end |