From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 34C5A1396D0 for ; Wed, 20 Sep 2017 21:19:05 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 8645AE07F6; Wed, 20 Sep 2017 21:19:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5747FE07F6 for ; Wed, 20 Sep 2017 21:19:04 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3170133C6B6 for ; Wed, 20 Sep 2017 21:19:03 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id B9522907F for ; Wed, 20 Sep 2017 21:19:01 +0000 (UTC) From: "Ulrich Müller" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Ulrich Müller" Message-ID: <1505942304.8dd01b6820e62f84f1703370ccd146d83b917347.ulm@gentoo> Subject: [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/eapi7-ver.eclass X-VCS-Directories: eclass/ X-VCS-Committer: ulm X-VCS-Committer-Name: Ulrich Müller X-VCS-Revision: 8dd01b6820e62f84f1703370ccd146d83b917347 X-VCS-Branch: eapi7-ver Date: Wed, 20 Sep 2017 21:19:01 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: f946ab82-8a19-4453-ba5a-39a173cc7744 X-Archives-Hash: efa90c7a0a2e39241f1a71ba8cb39aec commit: 8dd01b6820e62f84f1703370ccd146d83b917347 Author: Ulrich Müller gentoo org> AuthorDate: Wed Sep 20 21:18:24 2017 +0000 Commit: Ulrich Müller gentoo org> CommitDate: Wed Sep 20 21:18:24 2017 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=8dd01b68 eapi7-ver.eclass: Get rid of versions array. eclass/eapi7-ver.eclass | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass index 83777a1f129..53563e326e5 100644 --- a/eclass/eapi7-ver.eclass +++ b/eclass/eapi7-ver.eclass @@ -185,8 +185,8 @@ ver_rs() { # revision parts), and the comparison is performed according to # the algorithm specified in the PMS. ver_test() { - local op result cur tail i j - local -a v vcomp + local v1 v2 op i tail result + local -a v1comp v2comp local match=( "+([0-9])*(.+([0-9]))" # numeric components "[a-z]" # letter component @@ -198,14 +198,14 @@ ver_test() { shopt -s extglob if [[ $# -eq 2 ]]; then - v=("${PVR}" "$2") - op=$1 + v1=${PVR} elif [[ $# -eq 3 ]]; then - v=("$1" "$3") - op=$2 + v1=$1; shift else die "${FUNCNAME}: bad number of arguments" fi + op=$1 + v2=$2 case ${op} in -eq|-ne|-lt|-le|-gt|-ge) ;; @@ -213,18 +213,18 @@ ver_test() { esac # Test for both versions being valid, and split them into parts - for (( i=0; i<2; i++ )); do - cur=${v[i]} - for (( j=0; j<4; j++ )); do - tail=${cur##${match[j]}} - vcomp[i*4+j]=${cur%"${tail}"} - cur=${tail} - done - # There must not be any remaining tail, and the numeric part - # must be non-empty. All other parts are optional. - [[ -z ${cur} ]] || die "${FUNCNAME}: could not parse version: ${v[i]}" - [[ -n ${vcomp[i*4]} ]] || die "${FUNCNAME}: invalid version: ${v[i]}" + for (( i=0; i<4; i++ )); do + tail=${v1##${match[i]}} + v1comp[i]=${v1%"${tail}"} + v1=${tail} + tail=${v2##${match[i]}} + v2comp[i]=${v2%"${tail}"} + v2=${tail} done + # There must not be any remaining tail, and the numeric part + # must be non-empty. All other parts are optional. + [[ -z ${v1} && -z ${v2} && -n ${v1comp[0]} && -n ${v2comp[0]} ]] \ + || die "${FUNCNAME}: invalid version" # Compare numeric components (PMS algorithm 3.2) _ver_cmp_num() { @@ -293,10 +293,10 @@ ver_test() { } # Version comparison top-level logic (PMS algorithm 3.1) - _ver_cmp_num "${vcomp[0]}" "${vcomp[4]}" && - _ver_cmp_let "${vcomp[1]}" "${vcomp[5]}" && - _ver_cmp_suf "${vcomp[2]}" "${vcomp[6]}" && - _ver_cmp_rev "${vcomp[3]}" "${vcomp[7]}" + _ver_cmp_num "${v1comp[0]}" "${v2comp[0]}" && + _ver_cmp_let "${v1comp[1]}" "${v2comp[1]}" && + _ver_cmp_suf "${v1comp[2]}" "${v2comp[2]}" && + _ver_cmp_rev "${v1comp[3]}" "${v2comp[3]}" case $? in 0) result=0 ;; # a = b