* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-06 13:40 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-06 13:40 UTC (permalink / raw
To: gentoo-commits
commit: f7a0474438f6571cf105fe7aa8bf3831f8bddb09
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 6 13:31:56 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Sep 6 13:31:56 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7a04744
eapi7-ver.eclass: Shift component indexes to account for possible s0
eclass/eapi7-ver.eclass | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 2485c45637b..e9f2c453514 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -34,12 +34,17 @@ _version_parse_range() {
[[ ${start} -gt 0 ]] && [[ -z ${end} || ${start} -le ${end} ]] || die
}
+# RETURNS:
+# comp=( s0 c1 s1 c2 s2... )
+# where s - separator, c - component
_version_split() {
local v=$1 LC_ALL=C
+ comp=("")
+
# get first component
[[ ${v} =~ ^([A-Za-z]*|[0-9]*) ]] || die
- comp=("${BASH_REMATCH[1]}")
+ comp+=("${BASH_REMATCH[1]}")
v=${v:${#BASH_REMATCH[0]}}
# get remaining separators and components
@@ -59,9 +64,9 @@ version_cut() {
local IFS=
if [[ ${end} ]]; then
- echo "${comp[*]:(start-1)*2:(end-start)*2+1}"
+ echo "${comp[*]:(start-1)*2+1:(end-start)*2+1}"
else
- echo "${comp[*]:(start-1)*2}"
+ echo "${comp[*]:(start-1)*2+1}"
fi
}
@@ -74,7 +79,7 @@ version_rs() {
while [[ $# -ge 2 ]]; do
_version_parse_range "$1"
[[ ${end} && ${end} -le $((${#comp[@]}/2)) ]] || end=$((${#comp[@]}/2))
- for (( i = start*2 - 1; i < end*2; i+=2 )); do
+ for (( i = start*2; i <= end*2; i+=2 )); do
comp[i]=$2
done
shift 2
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-06 13:45 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-06 13:45 UTC (permalink / raw
To: gentoo-commits
commit: 2a1527cd4b327b9ed0da4e2705903e6bd6e69443
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 6 13:45:12 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Sep 6 13:45:12 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2a1527cd
eapi7-ver.eclass: Remove now-redundant vars
eclass/eapi7-ver.eclass | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 27571bc0d03..065a27974a9 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -51,7 +51,7 @@ _version_split() {
}
version_cut() {
- local start end istart
+ local start end
local -a comp
_version_parse_range "$1"
@@ -59,14 +59,12 @@ version_cut() {
local IFS=
if [[ ${start} -gt 0 ]]; then
- istart=$(( start*2 - 1 ))
- else
- istart=0
+ start=$(( start*2 - 1 ))
fi
if [[ ${end} ]]; then
- echo "${comp[*]:istart:end*2-istart}"
+ echo "${comp[*]:start:end*2-start}"
else
- echo "${comp[*]:istart}"
+ echo "${comp[*]:start}"
fi
}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-06 13:45 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-06 13:45 UTC (permalink / raw
To: gentoo-commits
commit: 0027cf6d4b6110dbaf5876ee0e891342fae3c984
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 6 13:44:17 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Sep 6 13:44:46 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0027cf6d
eapi7-ver.eclass: Use the power of maths to simplify splitting
eclass/eapi7-ver.eclass | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 70a1b3e9847..27571bc0d03 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -51,7 +51,7 @@ _version_split() {
}
version_cut() {
- local start end istart iend
+ local start end istart
local -a comp
_version_parse_range "$1"
@@ -59,14 +59,12 @@ version_cut() {
local IFS=
if [[ ${start} -gt 0 ]]; then
- istart=$(( (start-1)*2 + 1 ))
- iend=$(( (end-start)*2 + 1 ))
+ istart=$(( start*2 - 1 ))
else
istart=0
- iend=$(( (end-start)*2 ))
fi
if [[ ${end} ]]; then
- echo "${comp[*]:istart:iend}"
+ echo "${comp[*]:istart:end*2-istart}"
else
echo "${comp[*]:istart}"
fi
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-06 15:22 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-06 15:22 UTC (permalink / raw
To: gentoo-commits
commit: 3ed86fd971ba3f10751235f95921ebc7e01c2a3f
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 6 15:22:20 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed Sep 6 15:22:20 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3ed86fd9
eapi7-ver.eclass: Avoid regexps in _version_parse_range
eclass/eapi7-ver.eclass | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index fcbf012f0c4..fe85dfff031 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -28,10 +28,10 @@ case ${EAPI:-0} in
esac
_version_parse_range() {
- [[ $1 =~ ^([0-9]+)(-([0-9]*))?$ ]] || die
- start=${BASH_REMATCH[1]}
- [[ ${BASH_REMATCH[2]} ]] && end=${BASH_REMATCH[3]} || end=${start}
- [[ ${start} -ge 0 ]] && [[ -z ${end} || ${start} -le ${end} ]] || die
+ [[ ${1} == [0-9]* ]] || die
+ start=${1%-*}
+ [[ ${1} == *-* ]] && end=${1#*-} || end=${start}
+ [[ ${start} -ge 0 && ( -z ${end} || ${start} -le ${end} ) ]] || die
}
# RETURNS:
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-06 15:31 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-06 15:31 UTC (permalink / raw
To: gentoo-commits
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
}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-08 11:11 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-08 11:11 UTC (permalink / raw
To: gentoo-commits
commit: 5dd269904883223fbdc528ecaec37424421d1efa
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 8 11:04:35 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Sep 8 11:04:35 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5dd26990
eapi7-ver.eclass: Change prefix to ver_
eclass/eapi7-ver.eclass | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index b5d55eb38fd..fdaaac6d096 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -61,7 +61,7 @@ case ${EAPI:-0} in
die "${ECLASS}: EAPI=${EAPI} unknown";;
esac
-# @FUNCTION: _version_parse_range
+# @FUNCTION: _ver_parse_range
# @INTERNAL
# @USAGE: <range> <max>
# @DESCRIPTION:
@@ -69,7 +69,7 @@ esac
# to the appropriate bounds. <min> and <max> specify the appropriate
# lower and upper bound for the range; the user-specified value is
# truncated to this range.
-_version_parse_range() {
+_ver_parse_range() {
local range=${1}
local max=${2}
@@ -84,14 +84,14 @@ _version_parse_range() {
fi
}
-# @FUNCTION: _version_split
+# @FUNCTION: _ver_split
# @INTERNAL
# @USAGE: <version>
# @DESCRIPTION:
# Split the version string <version> into separator-component array.
# Sets 'comp' to an array of the form: ( s_0 c_1 s_1 c_2 s_2 c_3... )
# where s_i are separators and c_i are components.
-_version_split() {
+_ver_split() {
local v=${1} LC_ALL=C
comp=()
@@ -110,7 +110,7 @@ _version_split() {
done
}
-# @FUNCTION: version_cut
+# @FUNCTION: ver_cut
# @USAGE: <range> [<version>]
# @DESCRIPTION:
# Print the substring of the version string containing components
@@ -119,15 +119,15 @@ _version_split() {
#
# For the syntax of versions and ranges, please see the eclass
# description.
-version_cut() {
+ver_cut() {
local range=${1}
local v=${2:-${PV}}
local start end
local -a comp
- _version_split "${v}"
+ _ver_split "${v}"
local max=$((${#comp[@]}/2))
- _version_parse_range "${range}" "${max}"
+ _ver_parse_range "${range}" "${max}"
local IFS=
if [[ ${start} -gt 0 ]]; then
@@ -136,7 +136,7 @@ version_cut() {
echo "${comp[*]:start:end*2-start}"
}
-# @FUNCTION: version_rs
+# @FUNCTION: ver_rs
# @USAGE: <range> <repl> [<range> <repl>...] [<version>]
# @DESCRIPTION:
# Print the version string after substituting the specified version
@@ -146,17 +146,17 @@ version_cut() {
#
# For the syntax of versions and ranges, please see the eclass
# description.
-version_rs() {
+ver_rs() {
local v
(( ${#} & 1 )) && v=${@: -1} || v=${PV}
local start end i
local -a comp
- _version_split "${v}"
+ _ver_split "${v}"
local max=$((${#comp[@]}/2 - 1))
while [[ ${#} -ge 2 ]]; do
- _version_parse_range "${1}" "${max}"
+ _ver_parse_range "${1}" "${max}"
for (( i = start*2; i <= end*2; i+=2 )); do
[[ ${i} -eq 0 && -z ${comp[i]} ]] && continue
comp[i]=${2}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-08 11:11 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-08 11:11 UTC (permalink / raw
To: gentoo-commits
commit: ea9746eefda566501099367b226fd38c5a0f45e4
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 8 11:09:32 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Fri Sep 8 11:09:32 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ea9746ee
eapi7-ver.eclass: Reserve ver_test
eclass/eapi7-ver.eclass | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index fdaaac6d096..c82da6192c9 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -167,3 +167,15 @@ ver_rs() {
local IFS=
echo "${comp[*]}"
}
+
+# @FUNCTION: ver_test
+# @USAGE: [<v1>] <op> <v2>
+# @DESCRIPTION:
+# Check if the relation <v1> <op> <v2> is true. If <v1> is not specified,
+# default to ${PVR}. <op> can be -gt, -ge, -eq, -ne, -le, -lt.
+# Both versions must conform to the PMS version syntax (with optional
+# revision parts), and the comparison is performed according to
+# the algorithm specified in the PMS.
+ver_test() {
+ die "${FUNCNAME}: not implemented"
+}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-12 16:37 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-12 16:37 UTC (permalink / raw
To: gentoo-commits
commit: 6ebc5bb7e23966afaf46e9a9a568ba131ce6a019
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 12 09:31:16 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Sep 12 16:35:58 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=6ebc5bb7
eapi7-ver.eclass: Fix eclass documentation.
- Reorder function tags in order not to confuse eclass-to-manpage.awk.
- @ROFF tags for subheadings, since ==== underlines won't be properly
rendered.
- Two spaces after full stops to make nroff happy.
eclass/eapi7-ver.eclass | 32 ++++++++++++++++++--------------
1 file changed, 18 insertions(+), 14 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 5e8479dfdcd..1e8e3c5e55b 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -10,7 +10,7 @@
# @BLURB: Testing implementation of EAPI 7 version manipulators
# @DESCRIPTION:
# A stand-alone implementation of the version manipulation functions
-# aimed for EAPI 7. Intended to be used for wider testing of
+# aimed for EAPI 7. Intended to be used for wider testing of
# the proposed functions and to allow ebuilds to switch to the new
# model early, with minimal change needed for actual EAPI 7.
#
@@ -18,28 +18,30 @@
#
# Note: version comparison function is not included currently.
#
+# @ROFF .SS
# Version strings
-# ===============
+#
# The functions support arbitrary version strings consisting of version
# components interspersed with (possibly empty) version separators.
#
# A version component can either consist purely of digits ([0-9]+)
-# or purely of uppercase and lowercase letters ([A-Za-z]+). A version
+# or purely of uppercase and lowercase letters ([A-Za-z]+). A version
# separator is either a string of any other characters ([^A-Za-z0-9]+),
# or it occurs at the transition between a sequence of letters
# and a sequence of digits, or vice versa. In the latter case,
# the version separator is an empty string.
#
# The version is processed left-to-right, and each successive component
-# is assigned numbers starting with 1. The components are either split
+# is assigned numbers starting with 1. The components are either split
# on version separators or on boundaries between digits and letters
# (in which case the separator between the components is empty).
# Version separators are assigned numbers starting with 1 for
-# the separator between 1st and 2nd components. As a special case,
+# the separator between 1st and 2nd components. As a special case,
# if the version string starts with a separator, it is assigned index 0.
#
# Examples:
#
+# @CODE
# 1.2b-alpha4 -> 1 . 2 '' b - alpha '' 4
# c s c s c s c s c
# 1 1 2 2 3 3 4 4 5
@@ -47,12 +49,14 @@
# .11. -> . 11 .
# s c s
# 0 1 1
+# @CODE
#
+# @ROFF .SS
# Ranges
-# ======
+#
# A range can be specified as 'm' for m-th version component, 'm-'
# for all components starting with m-th or 'm-n' for components starting
-# at m-th and ending at n-th (inclusive). If the range spans outside
+# at m-th and ending at n-th (inclusive). If the range spans outside
# the version string, it is truncated silently.
case ${EAPI:-0} in
@@ -65,11 +69,11 @@ case ${EAPI:-0} in
esac
# @FUNCTION: _ver_parse_range
-# @INTERNAL
# @USAGE: <range> <max>
+# @INTERNAL
# @DESCRIPTION:
# Parse the range string <range>, setting 'start' and 'end' variables
-# to the appropriate bounds. <min> and <max> specify the appropriate
+# to the appropriate bounds. <min> and <max> specify the appropriate
# lower and upper bound for the range; the user-specified value is
# truncated to this range.
_ver_parse_range() {
@@ -90,8 +94,8 @@ _ver_parse_range() {
}
# @FUNCTION: _ver_split
-# @INTERNAL
# @USAGE: <version>
+# @INTERNAL
# @DESCRIPTION:
# Split the version string <version> into separator-component array.
# Sets 'comp' to an array of the form: ( s_0 c_1 s_1 c_2 s_2 c_3... )
@@ -145,8 +149,8 @@ ver_cut() {
# @USAGE: <range> <repl> [<range> <repl>...] [<version>]
# @DESCRIPTION:
# Print the version string after substituting the specified version
-# separators at <range> with <repl> (string). Multiple '<range> <repl>'
-# pairs can be specified. Processes <version> if specified,
+# separators at <range> with <repl> (string). Multiple '<range> <repl>'
+# pairs can be specified. Processes <version> if specified,
# ${PV} otherwise.
#
# For the syntax of versions and ranges, please see the eclass
@@ -176,8 +180,8 @@ ver_rs() {
# @FUNCTION: ver_test
# @USAGE: [<v1>] <op> <v2>
# @DESCRIPTION:
-# Check if the relation <v1> <op> <v2> is true. If <v1> is not specified,
-# default to ${PVR}. <op> can be -gt, -ge, -eq, -ne, -le, -lt.
+# Check if the relation <v1> <op> <v2> is true. If <v1> is not specified,
+# default to ${PVR}. <op> can be -gt, -ge, -eq, -ne, -le, -lt.
# Both versions must conform to the PMS version syntax (with optional
# revision parts), and the comparison is performed according to
# the algorithm specified in the PMS.
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-12 16:37 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-12 16:37 UTC (permalink / raw
To: gentoo-commits
commit: f7175ff54a078ebb70cbd865ffc96b9440bc10db
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 12 09:27:29 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Tue Sep 12 16:35:56 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=f7175ff5
eapi7-ver.eclass: Wrap overlong lines.
eclass/eapi7-ver.eclass | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 93069d03fc8..5e8479dfdcd 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -76,11 +76,13 @@ _ver_parse_range() {
local range=${1}
local max=${2}
- [[ ${range} == [0-9]* ]] || die "${FUNCNAME}: range must start with a number"
+ [[ ${range} == [0-9]* ]] \
+ || die "${FUNCNAME}: range must start with a number"
start=${range%-*}
[[ ${range} == *-* ]] && end=${range#*-} || end=${start}
if [[ ${end} ]]; then
- [[ ${start} -le ${end} ]] || die "${FUNCNAME}: end of range must be >= start"
+ [[ ${start} -le ${end} ]] \
+ || die "${FUNCNAME}: end of range must be >= start"
[[ ${end} -le ${max} ]] || end=${max}
else
end=${max}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-20 21:19 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-20 21:19 UTC (permalink / raw
To: gentoo-commits
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
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-21 7:04 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-21 7:04 UTC (permalink / raw
To: gentoo-commits
commit: dacc65a567e8d2fe9fd553e69160131054e41717
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 21 06:33:07 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Sep 21 07:04:27 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dacc65a5
eapi7-ver.eclass: Special-case -r0
eclass/eapi7-ver.eclass | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index aeb9dedd78b..e833835a56e 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -207,6 +207,10 @@ ver_test() {
*) die "${FUNCNAME}: invalid operator: ${op}" ;;
esac
+ # explicitly strip -r0[00000...] to avoid overcomplexifying the algo
+ [[ ${va} == *-r0* && 10#${va#*-r} -eq 0 ]] && va=${va%-r*}
+ [[ ${vb} == *-r0* && 10#${vb#*-r} -eq 0 ]] && vb=${vb%-r*}
+
local comp compb
_ver_split "${vb}"
compb=( "${comp[@]}" )
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-21 7:38 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-21 7:38 UTC (permalink / raw
To: gentoo-commits
commit: 393b8445925585a5ce192f9fde89720e8b37055a
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 21 07:34:19 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Sep 21 07:37:14 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=393b8445
eapi7-ver.eclass: Simplify version validation.
This also speeds ver_test up by about 20%.
eclass/eapi7-ver.eclass | 82 +++----------------------------------------------
1 file changed, 4 insertions(+), 78 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index e0eede869d4..7cfbf7e88d2 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -176,81 +176,6 @@ ver_rs() {
echo "${comp[*]}"
}
-# @FUNCTION: _ver_validate
-# @USAGE: <comp[0]>...
-# @DESCRIPTION:
-# Verify that the version component array passed as the argument
-# validates according to the PMS version rules. Returns 0 if it does,
-# 1 otherwise.
-_ver_validate() {
- local prev=start
-
- while [[ ${1} || ${2} ]]; do
- local s=${1}
- local c=${2}
-
- if [[ -z ${s} ]]; then
- if [[ ${c} == [0-9]* ]]; then
- # number without preceding sep may be either:
- case ${prev} in
- # a. 1st version number
- start) prev=numeric;;
- # b. _foo suffix number
- suffix) prev=suffix_num;;
- # c. -rN revision number
- revision) prev=revision_num;;
- *) return 1;;
- esac
- elif [[ -n ${c} ]]; then
- # letter without preceding sep = letter after version
- [[ ${prev} == numeric ]] || return 1
- [[ ${#c} -eq 1 ]] || return 1
- prev=letter
- fi
- elif [[ -z ${c} ]]; then
- # trailing suffix?
- return 1
- elif [[ ${s} == . ]]; then
- # number preceded by dot = numeric component
- [[ ${prev} == numeric ]] || return 1
- elif [[ ${s} == _ ]]; then
- # _ implies _foo suffix
- case ${prev} in
- numeric|letter|suffix|suffix_num) ;;
- *) return 1;;
- esac
-
- case ${c} in
- alpha) ;;
- beta) ;;
- rc) ;;
- pre) ;;
- p) ;;
- *) return 1;;
- esac
- prev=suffix
- elif [[ ${s} == - ]]; then
- # - implies revision
- case ${prev} in
- numeric|letter|suffix|suffix_num) ;;
- *) return 1;;
- esac
-
- [[ ${c} == r ]] || return 1
- prev=revision
- else
- return 1
- fi
-
- shift 2
- done
-
- # empty version string?
- [[ ${prev} != start ]] || return 1
-
- return 0
-}
-
# @FUNCTION: ver_test
# @USAGE: [<v1>] <op> <v2>
# @DESCRIPTION:
@@ -280,6 +205,10 @@ ver_test() {
*) die "${FUNCNAME}: invalid operator: ${op}" ;;
esac
+ local re="^[0-9]+(\.[0-9]+)*[a-z]?((_alpha|_beta|_pre|_rc|_p)[0-9]*)*(-r[0-9]+)?$"
+ [[ ${va} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${va}"
+ [[ ${vb} =~ ${re} ]] || die "${FUNCNAME}: invalid version: ${vb}"
+
# explicitly strip -r0[00000...] to avoid overcomplexifying the algo
[[ ${va} == *-r0* && 10#${va#*-r} -eq 0 ]] && va=${va%-r*}
[[ ${vb} == *-r0* && 10#${vb#*-r} -eq 0 ]] && vb=${vb%-r*}
@@ -289,9 +218,6 @@ ver_test() {
compb=( "${comp[@]}" )
_ver_split "${va}"
- _ver_validate "${comp[@]}" || die "${FUNCNAME}: invalid version: ${va}"
- _ver_validate "${compb[@]}" || die "${FUNCNAME}: invalid version: ${vb}"
-
local i sa sb ca cb wa wb result=0
for (( i = 0;; i += 2 )); do
sa=${comp[i]}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-21 12:57 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-21 12:57 UTC (permalink / raw
To: gentoo-commits
commit: 0d4831f9da9cb30979407e9144c042d181ce9ef8
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 21 12:52:02 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Sep 21 12:52:02 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0d4831f9
eapi7-ver.eclass: Fix some ugliness.
eclass/eapi7-ver.eclass | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 7cfbf7e88d2..3ddd8954556 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -188,7 +188,7 @@ ver_test() {
local LC_ALL=C
local va op vb
- if [[ ${#} -eq 3 ]]; then
+ if [[ $# -eq 3 ]]; then
va=${1}
shift
else
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-21 13:26 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-21 13:26 UTC (permalink / raw
To: gentoo-commits
commit: bfcf85946d2ad8f28ced9bf13ee12a4031c6ac4f
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 21 13:26:16 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Thu Sep 21 13:26:16 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=bfcf8594
eapi7-ver.eclass: Fix typo.
eclass/eapi7-ver.eclass | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index c64870cc1fe..53302631405 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -234,8 +234,8 @@ _ver_compare() {
[[ ${al} < ${bl} ]] && return 1
# Compare suffixes (PMS algorithm 3.5)
- as=${as#_}${as+_}
- bs=${bs#_}${bs+_}
+ as=${as#_}${as:+_}
+ bs=${bs#_}${bs:+_}
while [[ -n ${as} && -n ${bs} ]]; do
# Compare each suffix (PMS algorithm 3.6)
a=${as%%_*}
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-21 14:04 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-21 14:04 UTC (permalink / raw
To: gentoo-commits
commit: 11e4c9be5892527f03525a05b164c9abf665c715
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 21 13:44:25 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Sep 21 13:44:25 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=11e4c9be
eapi7-ver.eclass: Optimize last suffix comparison
eclass/eapi7-ver.eclass | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 53302631405..4cba67f8491 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -254,11 +254,9 @@ _ver_compare() {
bs=${bs#*_}
done
if [[ -n ${as} ]]; then
- a=${as%%_*}
- [[ ${a%%[0-9]*} == p ]] && return 3 || return 1
+ [[ ${as} == p[_0-9]* ]] && return 3 || return 1
elif [[ -n ${bs} ]]; then
- b=${bs%%_*}
- [[ ${b%%[0-9]*} == p ]] && return 1 || return 3
+ [[ ${bs} == p[_0-9]* ]] && return 1 || return 3
fi
# Compare revision components (PMS algorithm 3.7)
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-21 14:04 Michał Górny
0 siblings, 0 replies; 19+ messages in thread
From: Michał Górny @ 2017-09-21 14:04 UTC (permalink / raw
To: gentoo-commits
commit: fd2d1bbb85fe0c19617b33f5ee6729b9fe936965
Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 21 13:55:00 2017 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Thu Sep 21 14:03:38 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=fd2d1bbb
eapi7-ver.eclass: Optimize numeric comparison
eclass/eapi7-ver.eclass | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 4cba67f8491..ead9fac5e80 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -207,10 +207,10 @@ _ver_compare() {
[[ 10#${a} -gt 10#${b} ]] && return 3
[[ 10#${a} -lt 10#${b} ]] && return 1
- an=${an}.; an=${an#*.}
- bn=${bn}.; bn=${bn#*.}
- while [[ -n ${an} && -n ${bn} ]]; do
+ while [[ ${an} == *.* && ${bn} == *.* ]]; do
# Other components (PMS algorithm 3.3)
+ an=${an#*.}
+ bn=${bn#*.}
a=${an%%.*}
b=${bn%%.*}
if [[ ${a} == 0* || ${b} == 0* ]]; then
@@ -223,11 +223,9 @@ _ver_compare() {
[[ ${a} -gt ${b} ]] && return 3
[[ ${a} -lt ${b} ]] && return 1
fi
- an=${an#*.}
- bn=${bn#*.}
done
- [[ -n ${an} ]] && return 3
- [[ -n ${bn} ]] && return 1
+ [[ ${an} == *.* ]] && return 3
+ [[ ${bn} == *.* ]] && return 1
# Compare letter components (PMS algorithm 3.4)
[[ ${al} > ${bl} ]] && return 3
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-22 16:10 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-22 16:10 UTC (permalink / raw
To: gentoo-commits
commit: 02edb2c082e17b4e8b2338be7ce0e7a20f997e5d
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 22 16:09:58 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Sep 22 16:09:58 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=02edb2c0
eapi7-ver.eclass: Fixup: Remove stale comment.
eclass/eapi7-ver.eclass | 2 --
1 file changed, 2 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index ead9fac5e80..7c5216c4b0a 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -16,8 +16,6 @@
#
# https://bugs.gentoo.org/482170
#
-# Note: version comparison function is not included currently.
-#
# @ROFF .SS
# Version strings
#
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-22 21:28 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-22 21:28 UTC (permalink / raw
To: gentoo-commits
commit: ad4d0511fbbecb1a1134f4d4dacb48454577e59a
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 22 21:24:46 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Fri Sep 22 21:24:46 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=ad4d0511
eapi7-ver.eclass: Fixup: Assign LC_ALL in the right function.
eclass/eapi7-ver.eclass | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index 7c5216c4b0a..d1d98231002 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -182,7 +182,7 @@ ver_rs() {
# Compare two versions <va> and <vb>. If <va> is less than, equal to,
# or greater than <vb>, return 1, 2, or 3 as exit status, respectively.
_ver_compare() {
- local va=${1} vb=${2} a an al as ar b bn bl bs br re
+ local va=${1} vb=${2} a an al as ar b bn bl bs br re LC_ALL=C
re="^([0-9]+(\.[0-9]+)*)([a-z]?)((_(alpha|beta|pre|rc|p)[0-9]*)*)(-r[0-9]+)?$"
@@ -271,7 +271,6 @@ _ver_compare() {
# revision parts), and the comparison is performed according to
# the algorithm specified in the PMS.
ver_test() {
- local LC_ALL=C
local va op vb
if [[ $# -eq 3 ]]; then
^ permalink raw reply related [flat|nested] 19+ messages in thread
* [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/
@ 2017-09-23 5:46 Ulrich Müller
0 siblings, 0 replies; 19+ messages in thread
From: Ulrich Müller @ 2017-09-23 5:46 UTC (permalink / raw
To: gentoo-commits
commit: 3cdc17858512146c01a4476e690efbd8c7229c07
Author: Ulrich Müller <ulm <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 23 05:39:55 2017 +0000
Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
CommitDate: Sat Sep 23 05:39:55 2017 +0000
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3cdc1785
eapi7-ver.eclass: Fixup: Use regexp matching rather than loop.
eclass/eapi7-ver.eclass | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/eclass/eapi7-ver.eclass b/eclass/eapi7-ver.eclass
index d1d98231002..5ca8b8143af 100644
--- a/eclass/eapi7-ver.eclass
+++ b/eclass/eapi7-ver.eclass
@@ -212,9 +212,9 @@ _ver_compare() {
a=${an%%.*}
b=${bn%%.*}
if [[ ${a} == 0* || ${b} == 0* ]]; then
- # Remove trailing zeros
- while [[ ${a} == *0 ]]; do a=${a::-1}; done
- while [[ ${b} == *0 ]]; do b=${b::-1}; done
+ # Remove any trailing zeros
+ [[ ${a} =~ 0+$ ]] && a=${a%"${BASH_REMATCH[0]}"}
+ [[ ${b} =~ 0+$ ]] && b=${b%"${BASH_REMATCH[0]}"}
[[ ${a} > ${b} ]] && return 3
[[ ${a} < ${b} ]] && return 1
else
^ permalink raw reply related [flat|nested] 19+ messages in thread
end of thread, other threads:[~2017-09-23 5:46 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-22 21:28 [gentoo-commits] repo/gentoo:eapi7-ver commit in: eclass/ Ulrich Müller
-- strict thread matches above, loose matches on Subject: below --
2017-09-23 5:46 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-20 21:19 Ulrich Müller
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
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox