commit: 1e68066e762b533245eeda9e1f900499bb4620c2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed Sep 6 15:31:37 2017 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed Sep 6 15:31:37 2017 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1e68066e
eapi7-ver.eclass: Avoid regexps in _version_split eclass/eapi7-ver.eclass | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass index fe85dfff031..d71a2427dd7 100644 --- a/eclass/eapi7-ver.eclass +++ b/eclass/eapi7-ver.eclass @@ -43,10 +43,16 @@ _version_split() { comp=() # get separators and components + local s c while [[ ${v} ]]; do - [[ ${v} =~ ^([^A-Za-z0-9]*)([A-Za-z]*|[0-9]*) ]] || die - comp+=("${BASH_REMATCH[@]:1:2}") - v=${v:${#BASH_REMATCH[0]}} + # cut the separator + s="${v%%[a-zA-Z0-9]*}" + v=${v:${#s}} + # cut the next component; it can be either digits or letters + [[ ${v} == [0-9]* ]] && c=${v%%[^0-9]*} || c=${v%%[^a-zA-Z]*} + v=${v:${#c}} + + comp+=( "${s}" "${c}" ) done }