[gimp/gimp-2-10] configure.ac: improve compiler version string escaping



commit 28a0d91fd5c45582a72c81d3e7e2752c02399fe1
Author: Ell <ell_se yahoo com>
Date:   Mon May 20 03:06:02 2019 -0400

    configure.ac: improve compiler version string escaping
    
    In configure.ac, improve backslash escaping in the compiler
    version string.  Backslashes are currently not properly escaped in
    our Windows builds, leading to spurious (and, in particular, non-
    UTF8) characters in the compiler version string.
    
    (cherry picked from commit 04f9281bdd1ee05bed93eb98d9f697e38fcc94ea)

 configure.ac | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f2303fdc02..cf8e644364 100644
--- a/configure.ac
+++ b/configure.ac
@@ -575,23 +575,22 @@ WARNING: GCC 7.2.0 has a serious bug affecting GEGL/GIMP. We advise
          See https://bugzilla.gnome.org/show_bug.cgi?id=787222";
   fi
   # For GCC, use -v which has more information than --version.
-  CC_VERSION="`$CC -v 2>&1`"
+  CC_VERSION_OPTS="-v"
 else
   # This is the list of common options used by autotools to check
   # versions for various compilers.
-  CC_VERSION="`$CC --version 2>&1`"
-  if test $? != 0; then
-    CC_VERSION="`$CC -v 2>&1`"
-    if test $? != 0; then
-      CC_VERSION="`$CC -V 2>&1`"
-      if test $? != 0; then
-        CC_VERSION="`$CC -qversion 2>&1`"
-      fi
-    fi
-  fi
+  CC_VERSION_OPTS="--version -v -V -qversion"
 fi
-# Format and escape CC_VERSION
-CC_VERSION="\\t`echo "$CC_VERSION" | sed -e 's/\\\\/\\\\\\\\/g;s/$/\\\\n\\\\t/g' | tr -d '\n'`"
+
+for CC_VERSION_OPT in $CC_VERSION_OPTS; do
+  # We run $CC, and escape and format its output, in a single step,
+  # since some shells expand escape sequences in "echo" arguments.
+  CC_VERSION="`$CC $CC_VERSION_OPT 2>&1 | sed -e 's/\\\\/\\\\\\\\/g;s/^/\\\\t/;s/$/\\\\n/' | tr -d '\n'`"
+  if test $? -eq 0; then
+    break
+  fi
+done
+
 AC_SUBST(CC_VERSION)
 
 AC_HEADER_STDC


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]