public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH] flag-o-matic.eclass: bugfix for get-flag()
@ 2016-05-15 13:31 Jan Chren
  2016-05-15 15:59 ` Michał Górny
  0 siblings, 1 reply; 10+ messages in thread
From: Jan Chren @ 2016-05-15 13:31 UTC (permalink / raw
  To: gentoo-dev; +Cc: Jan Chren

- fix case:
  - `CFLAGS='-O1 -O2'`
  - `get-flag '-O*'`
  - before `-O1`
  - now `-O2`
- fix case:
  - `CFLAGS='-W1,-O1'`
  - `get-flag '-O*'`
  - before `-W1,O1`
  - now return 1

`get-flag march` == "i686" syntax still works.
---
 eclass/flag-o-matic.eclass | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/eclass/flag-o-matic.eclass b/eclass/flag-o-matic.eclass
index e0b19e9..f670320 100644
--- a/eclass/flag-o-matic.eclass
+++ b/eclass/flag-o-matic.eclass
@@ -535,7 +535,7 @@ strip-unsupported-flags() {
 # @DESCRIPTION:
 # Find and echo the value for a particular flag.  Accepts shell globs.
 get-flag() {
-	local f var findflag="$1"
+	local var findflag="${1}"
 
 	# this code looks a little flaky but seems to work for
 	# everything we want ...
@@ -543,11 +543,16 @@ get-flag() {
 	# `get-flag -march` == "-march=i686"
 	# `get-flag march` == "i686"
 	for var in $(all-flag-vars) ; do
-		for f in ${!var} ; do
-			if [ "${f/${findflag}}" != "${f}" ] ; then
-				printf "%s\n" "${f/-${findflag}=}"
+		# reverse loop
+		set -- ${!var}
+		local i=$#
+		while [ $i -gt 0 ] ; do
+			local f="${!i}"
+			if [ "${f#-${findflag#-}}" != "${f}" ] ; then
+				printf "%s\n" "${f#-${findflag}=}"
 				return 0
 			fi
+			((i--))
 		done
 	done
 	return 1
-- 
2.7.3



^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2016-06-05 12:14 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-15 13:31 [gentoo-dev] [PATCH] flag-o-matic.eclass: bugfix for get-flag() Jan Chren
2016-05-15 15:59 ` Michał Górny
2016-05-15 19:35   ` rindeal
2016-05-15 19:41     ` Michał Górny
2016-05-15 20:19       ` rindeal
2016-05-15 23:23     ` Ulrich Mueller
2016-05-16 12:17       ` rindeal
2016-05-20  3:15         ` Mike Frysinger
2016-06-05 12:13         ` rindeal
2016-05-16  6:23     ` [gentoo-dev] " Ryan Hill

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox