autotools: tidy-up if expressions

- drop x-hacks for curl internal variables and certain autotools ones
  that do not hold custom values.
- make x-hacks consistently use `"x$var" = "xval"` style.
- add a few x-hacks for input/external variables that may hold custom
  values.
- prefer `-z` and `-n` to test empty/non-empty.
  This also makes some x-hacks unnecessary.
- optimized negated test `-z` and `-n` options.
- prefer `&&` and `||` over `-a` and `-o`.
  For better POSIX compatibility:
  https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
- quote variables passed to `test`, where missing.
- quote string literals in comparisons.
- fix some indentation, whitespace.

Note that a few `case` statements also use the x-hack, which looks
unnecessary. This patch does not change them.

Verified by comparing feature detection results with a reference CI run
from before this patch (PR #19922).

Refs:
https://www.shellcheck.net/wiki/SC2268
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
https://www.vidarholen.net/contents/blog/?p=1035
https://mywiki.wooledge.org/BashPitfalls#A.5B_.24foo_.3D_.22bar.22_.5D

Closes #18189
This commit is contained in:
Viktor Szakats 2025-08-05 16:07:21 +02:00
parent cc285649dc
commit 8db0e286b3
No known key found for this signature in database
GPG key ID: B5ABD165E2AEF201
19 changed files with 478 additions and 477 deletions

View file

@ -59,8 +59,8 @@ case "x$enable_static" in @%:@ (
xc_lt_want_enable_static='no'
;;
esac
if test "x$xc_lt_want_enable_shared" = 'xno' &&
test "x$xc_lt_want_enable_static" = 'xno'; then
if test "$xc_lt_want_enable_shared" = "no" &&
test "$xc_lt_want_enable_static" = "no"; then
AC_MSG_ERROR([can not disable shared and static libraries simultaneously])
fi
@ -71,8 +71,8 @@ fi
# must be used in order to build a proper static library.
#
if test "x$xc_lt_want_enable_shared" = 'xyes' &&
test "x$xc_lt_want_enable_static" = 'xyes'; then
if test "$xc_lt_want_enable_shared" = "yes" &&
test "$xc_lt_want_enable_static" = "yes"; then
case $host_os in @%:@ (
os2* | aix*)
xc_lt_want_enable_static='no'
@ -117,7 +117,7 @@ esac
# be overridden using 'configure --disable-shared --without-pic'.
#
if test "x$xc_lt_want_with_pic" = 'xdefault'; then
if test "$xc_lt_want_with_pic" = "default"; then
case $host_cpu in @%:@ (
x86_64 | amd64 | ia64)
case $host_os in @%:@ (
@ -229,7 +229,7 @@ m4_define([_XC_CHECK_LT_SHLIB_USE_VERSION_INFO],
AC_MSG_CHECKING([whether to build shared libraries with -version-info])
xc_lt_shlib_use_version_info='yes'
if test "x$version_type" = 'xnone'; then
if test "$version_type" = "none"; then
xc_lt_shlib_use_version_info='no'
fi
case $host_os in @%:@ (
@ -259,9 +259,9 @@ m4_define([_XC_CHECK_LT_SHLIB_USE_NO_UNDEFINED],
AC_MSG_CHECKING([whether to build shared libraries with -no-undefined])
xc_lt_shlib_use_no_undefined='no'
if test "x$allow_undefined" = 'xno'; then
if test "x$allow_undefined" = "xno"; then
xc_lt_shlib_use_no_undefined='yes'
elif test "x$allow_undefined_flag" = 'xunsupported'; then
elif test "x$allow_undefined_flag" = "xunsupported"; then
xc_lt_shlib_use_no_undefined='yes'
fi
case $host_os in @%:@ (
@ -293,7 +293,7 @@ AC_MSG_CHECKING([whether to build shared libraries with -mimpure-text])
xc_lt_shlib_use_mimpure_text='no'
case $host_os in @%:@ (
solaris2*)
if test "x$GCC" = 'xyes'; then
if test "x$GCC" = "xyes"; then
xc_lt_shlib_use_mimpure_text='yes'
fi
;;
@ -367,8 +367,8 @@ m4_define([_XC_CHECK_LT_BUILD_SINGLE_VERSION],
#
AC_MSG_CHECKING([whether to build shared libraries only])
if test "$xc_lt_build_shared" = 'yes' &&
test "$xc_lt_build_static" = 'no'; then
if test "$xc_lt_build_shared" = "yes" &&
test "$xc_lt_build_static" = "no"; then
xc_lt_build_shared_only='yes'
else
xc_lt_build_shared_only='no'
@ -380,8 +380,8 @@ AC_MSG_RESULT([$xc_lt_build_shared_only])
#
AC_MSG_CHECKING([whether to build static libraries only])
if test "$xc_lt_build_static" = 'yes' &&
test "$xc_lt_build_shared" = 'no'; then
if test "$xc_lt_build_static" = "yes" &&
test "$xc_lt_build_shared" = "no"; then
xc_lt_build_static_only='yes'
else
xc_lt_build_static_only='no'