qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, alex.bennee@linaro.org,
	Michael Tokarev <mjt@tls.msk.ru>,
	Laurent Vivier <laurent@vivier.eu>, Greg Kurz <groug@kaod.org>
Subject: [PATCH 2/2] configure: Fix excessive error detection when handling --cross-cc-FOO
Date: Fri, 23 Jul 2021 16:46:01 +0200	[thread overview]
Message-ID: <20210723144601.1038381-3-groug@kaod.org> (raw)
In-Reply-To: <20210723144601.1038381-1-groug@kaod.org>

Passing a --cross-cc-cflags-* option with a value that contains a '='
causes configure to exit:

$ ./configure --cross-cc-cflags-arm='-DFOO=bar'

ERROR: Passed bad --cross-cc-FOO option

This is an annoying limitation since '=' is frequently found
in CFLAGS.

This is caused by this line in the CC options parsing loop:

  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"

The '[!a-zA-Z0-9_-]' pattern matches the first '=' in the
option and the '=' pattern matches the other one. The '*'
patterns then match the rest.

The intent seems to be that we only want characters from the
range [a-zA-Z0-9_-] in the option name. Shell pattern matching
isn't powerful enough to do that with a single expression.

First, isolate the option name, i.e. before the first '=' character,
with a regular expression. Only error out if there's at least one
unwanted character in the name.

Fixes: d75402b5ee29 ("configure: add support for --cross-cc-FOO")
Cc: alex.bennee@linaro.org
Signed-off-by: Greg Kurz <groug@kaod.org>
---
 configure | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/configure b/configure
index 3a926ff8fc23..61a415e4dc61 100755
--- a/configure
+++ b/configure
@@ -472,16 +472,23 @@ for opt do
   ;;
   --disable-debug-info) debug_info="no"
   ;;
-  --cross-cc-*[!a-zA-Z0-9_-]*=*) error_exit "Passed bad --cross-cc-FOO option"
-  ;;
-  --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
-                      eval "cross_cc_cflags_${cc_arch}=\$optarg"
-                      cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
-  ;;
-  --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
-                cc_archs="$cc_archs $cc_arch"
-                eval "cross_cc_${cc_arch}=\$optarg"
-                cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
+  --cross-cc-*=*)
+    optname=$(expr "x$opt" : 'x\([^=]*\)=.*')
+    case "$optname" in
+    *[!a-zA-Z0-9_-]*) error_exit "Passed bad $optname option"
+    ;;
+    esac
+    case "$opt" in
+    --cross-cc-cflags-*) cc_arch=${opt#--cross-cc-cflags-}; cc_arch=${cc_arch%%=*}
+                         eval "cross_cc_cflags_${cc_arch}=\$optarg"
+                         cross_cc_vars="$cross_cc_vars cross_cc_cflags_${cc_arch}"
+    ;;
+    --cross-cc-*) cc_arch=${opt#--cross-cc-}; cc_arch=${cc_arch%%=*}
+                  cc_archs="$cc_archs $cc_arch"
+                  eval "cross_cc_${cc_arch}=\$optarg"
+                  cross_cc_vars="$cross_cc_vars cross_cc_${cc_arch}"
+    ;;
+    esac
   ;;
   esac
 done
-- 
2.31.1



      parent reply	other threads:[~2021-07-23 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-23 14:45 [PATCH 0/2] configure: Fixes for --cross-cc-FOO Greg Kurz
2021-07-23 14:46 ` [PATCH 1/2] configure: Fix trivial typo in --cross-cc-cflags-FOO Greg Kurz
2021-07-23 14:46 ` Greg Kurz [this message]

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=20210723144601.1038381-3-groug@kaod.org \
    --to=groug@kaod.org \
    --cc=alex.bennee@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=mjt@tls.msk.ru \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.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;
as well as URLs for NNTP newsgroup(s).