public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Ulrich Müller" <ulm@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
Date: Wed, 20 Sep 2017 21:19:01 +0000 (UTC)	[thread overview]
Message-ID: <1505942304.8dd01b6820e62f84f1703370ccd146d83b917347.ulm@gentoo> (raw)

commit:     8dd01b6820e62f84f1703370ccd146d83b917347
Author:     Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 20 21:18:24 2017 +0000
Commit:     Ulrich Müller <ulm <AT> gentoo <DOT> 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


             reply	other threads:[~2017-09-20 21:19 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20 21:19 Ulrich Müller [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-09-23  5:46 [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/ Ulrich Müller
2017-09-22 21:28 Ulrich Müller
2017-09-22 16:10 Ulrich Müller
2017-09-21 14:04 Michał Górny
2017-09-21 14:04 Michał Górny
2017-09-21 13:26 Ulrich Müller
2017-09-21 12:57 Ulrich Müller
2017-09-21  7:38 Ulrich Müller
2017-09-21  7:04 Michał Górny
2017-09-12 16:37 Ulrich Müller
2017-09-12 16:37 Ulrich Müller
2017-09-08 11:11 Michał Górny
2017-09-08 11:11 Michał Górny
2017-09-06 15:31 Michał Górny
2017-09-06 15:22 Michał Górny
2017-09-06 13:45 Michał Górny
2017-09-06 13:45 Michał Górny
2017-09-06 13:40 Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1505942304.8dd01b6820e62f84f1703370ccd146d83b917347.ulm@gentoo \
    --to=ulm@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox