Gentoo Archives: gentoo-dev

From: Jan Chren <dev.rindeal@×××××.com>
To: gentoo-dev@l.g.o
Cc: Jan Chren <dev.rindeal@×××××.com>
Subject: [gentoo-dev] [PATCH] flag-o-matic.eclass: bugfix for get-flag()
Date: Sun, 15 May 2016 13:31:49
Message-Id: 1463319089-18877-1-git-send-email-dev.rindeal@gmail.com
1 - fix case:
2 - `CFLAGS='-O1 -O2'`
3 - `get-flag '-O*'`
4 - before `-O1`
5 - now `-O2`
6 - fix case:
7 - `CFLAGS='-W1,-O1'`
8 - `get-flag '-O*'`
9 - before `-W1,O1`
10 - now return 1
11
12 `get-flag march` == "i686" syntax still works.
13 ---
14 eclass/flag-o-matic.eclass | 13 +++++++++----
15 1 file changed, 9 insertions(+), 4 deletions(-)
16
17 diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
18 index e0b19e9..f670320 100644
19 --- a/eclass/flag-o-matic.eclass
20 +++ b/eclass/flag-o-matic.eclass
21 @@ -535,7 +535,7 @@ strip-unsupported-flags() {
22 # @DESCRIPTION:
23 # Find and echo the value for a particular flag. Accepts shell globs.
24 get-flag() {
25 - local f var findflag="$1"
26 + local var findflag="${1}"
27
28 # this code looks a little flaky but seems to work for
29 # everything we want ...
30 @@ -543,11 +543,16 @@ get-flag() {
31 # `get-flag -march` == "-march=i686"
32 # `get-flag march` == "i686"
33 for var in $(all-flag-vars) ; do
34 - for f in ${!var} ; do
35 - if [ "${f/${findflag}}" != "${f}" ] ; then
36 - printf "%s\n" "${f/-${findflag}=}"
37 + # reverse loop
38 + set -- ${!var}
39 + local i=$#
40 + while [ $i -gt 0 ] ; do
41 + local f="${!i}"
42 + if [ "${f#-${findflag#-}}" != "${f}" ] ; then
43 + printf "%s\n" "${f#-${findflag}=}"
44 return 0
45 fi
46 + ((i--))
47 done
48 done
49 return 1
50 --
51 2.7.3

Replies

Subject Author
Re: [gentoo-dev] [PATCH] flag-o-matic.eclass: bugfix for get-flag() "Michał Górny" <mgorny@g.o>