* [gentoo-commits] proj/portage-utils:master commit in: tests/qatom/, libq/
@ 2018-04-12 18:30 Fabian Groffen
0 siblings, 0 replies; 2+ messages in thread
From: Fabian Groffen @ 2018-04-12 18:30 UTC (permalink / raw
To: gentoo-commits
commit: 712cbd379172e444c399a48d08d76a402e822697
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 12 18:28:20 2018 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 12 18:28:20 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=712cbd37
atom_explode: try harder to find correct PV
It's not enough to find a hyphen followed by something that looks like a
version, it needs to be verified it really is, else it is part of the
package name.
Bug: https://bugs.gentoo.org/653032
libq/atom_explode.c | 51 ++++++++++++++++++++++++---------------------------
tests/qatom/dotest | 3 +++
2 files changed, 27 insertions(+), 27 deletions(-)
diff --git a/libq/atom_explode.c b/libq/atom_explode.c
index ec0fc5a..07d9cec 100644
--- a/libq/atom_explode.c
+++ b/libq/atom_explode.c
@@ -189,13 +189,31 @@ atom_explode(const char *atom)
* SLOT, REPO or '*'
* PN must not end in a hyphen followed by anything matching version
* syntax, version syntax starts with a number, so "-[0-9]" is a
- * separator from PN to PV* */
+ * separator from PN to PV* -- except it doesn't when the thing
+ * doesn't validate as version :( */
ptr = ret->PN;
while ((ptr = strchr(ptr, '-')) != NULL) {
+ char *pv;
ptr++;
- if (*ptr >= '0' && *ptr <= '9')
- break;
+ 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 */
+ }
+ ret->letter = '\0';
}
if (ptr == NULL) {
@@ -216,7 +234,7 @@ atom_explode(const char *atom)
}
break;
}
- --ptr;
+ ptr--;
}
strcpy(ret->P, ret->PN);
ret->PV[-1] = '\0';
@@ -256,29 +274,8 @@ atom_explode(const char *atom)
ret->suffixes[idx] = t;
}
- /* skip back to the "end" */
- for (ptr = ret->PV; *ptr != '\0' && *ptr != '_'; ptr++)
- ;
- ptr--;
-
- /* allow for 1 optional suffix letter */
- if (*ptr >= 'a' && *ptr <= 'z')
- ret->letter = *ptr--;
-
- /* eat the trailing version number [.0-9]+ */
- while (ptr > ret->PV) {
- if (*ptr != '.' && !isdigit(*ptr))
- break;
- ptr--;
- }
-
- if (ptr != ret->PV) {
- /* PV isn't exactly a number */
- ret->PV = ret->PVR = NULL;
- } else {
- ptr = stpcpy(ret->PVR, ret->PV);
- sprintf(ptr, "-r%i", ret->PR_int);
- }
+ ptr = stpcpy(ret->PVR, ret->PV);
+ sprintf(ptr, "-r%i", ret->PR_int);
return ret;
}
diff --git a/tests/qatom/dotest b/tests/qatom/dotest
index a0e6a34..01900e6 100755
--- a/tests/qatom/dotest
+++ b/tests/qatom/dotest
@@ -48,5 +48,8 @@ test f14 "foo-r1" -F '%{PN}' "foo-r1" # bug #526596
test f15 "app-emacs diff-mode-" \
-F '%{CATEGORY} %{PN}' \
"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"
end
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: tests/qatom/, libq/
@ 2018-05-18 16:58 Fabian Groffen
0 siblings, 0 replies; 2+ messages in thread
From: Fabian Groffen @ 2018-05-18 16:58 UTC (permalink / raw
To: gentoo-commits
commit: a7d916ac978023fe35dcd8666d7bc913bab3b0a9
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 18 16:55:58 2018 +0000
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 18 16:55:58 2018 +0000
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a7d916ac
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
libq/atom_explode.c | 41 +++++++++++++++++++++++------------------
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-18 16:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-18 16:58 [gentoo-commits] proj/portage-utils:master commit in: tests/qatom/, libq/ Fabian Groffen
-- strict thread matches above, loose matches on Subject: below --
2018-04-12 18:30 Fabian Groffen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox