1 |
commit: e5ed806b4a2784ced621efd8c5b036bddef780f8 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Dec 28 16:12:54 2017 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Dec 28 16:12:54 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e5ed806b |
7 |
|
8 |
atom_explode: be more careful with eating suffix letters |
9 |
|
10 |
Make sure we don't just eat a char at the end of the atom, because if |
11 |
that char appears after a -, it will be seen as version part. An |
12 |
example is xerces-c, where the parsed atom form would just be xerces. |
13 |
|
14 |
Bug: https://bugs.gentoo.org/638816 |
15 |
|
16 |
libq/atom_explode.c | 7 +++++-- |
17 |
1 file changed, 5 insertions(+), 2 deletions(-) |
18 |
|
19 |
diff --git a/libq/atom_explode.c b/libq/atom_explode.c |
20 |
index 956ac49..057bfa1 100644 |
21 |
--- a/libq/atom_explode.c |
22 |
+++ b/libq/atom_explode.c |
23 |
@@ -218,9 +218,12 @@ atom_explode(const char *atom) |
24 |
ret->suffixes[idx] = t; |
25 |
} |
26 |
|
27 |
- /* allow for 1 optional suffix letter */ |
28 |
+ /* allow for 1 optional suffix letter, must be following a number |
29 |
+ * otherwise we eat stuff like -c, see bug #639978 */ |
30 |
ptr = ret->PN + strlen(ret->PN); |
31 |
- if (ptr[-1] >= 'a' && ptr[-1] <= 'z') { |
32 |
+ if (ptr[-1] >= 'a' && ptr[-1] <= 'z' && |
33 |
+ ptr - 2 > ret->PN && ptr[-2] >= '0' && ptr[-2] <= '9') |
34 |
+ { |
35 |
ret->letter = ptr[-1]; |
36 |
--ptr; |
37 |
} |