autoconf: 1999-10-07 Akim Demaille <akim@epita.fr>

https://github.com/libsdl-org/autoconf/commit/d42abb04f224c8ec0af495870ad332dd3740c100

From d42abb04f224c8ec0af495870ad332dd3740c100 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Thu, 7 Oct 1999 09:21:50 +0000
Subject: [PATCH] 1999-10-07  Akim Demaille  <akim@epita.fr>

	* acspecific.m4 (AC_CHECK_HEADER_DIRENT): Reintroduce its
	AC_DEFUN.
---
 ChangeLog                |  5 +++++
 TODO                     |  4 ----
 acspecific.m4            |  1 +
 configure                | 45 ++++++++++++++++++++--------------------
 lib/autoconf/specific.m4 |  1 +
 5 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 7a879d1f..c1bf93dd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+1999-10-07  Akim Demaille  <akim@epita.fr>
+
+	* acspecific.m4 (AC_CHECK_HEADER_DIRENT): Reintroduce its
+	AC_DEFUN.
+
 1999-10-05  Andreas Schwab  <schwab@issan.cs.uni-dortmund.de>
 
 	Shell meta characters in an argument causes the configure script
diff --git a/TODO b/TODO
index fdcf7b42..dfd8aee4 100644
--- a/TODO
+++ b/TODO
@@ -25,10 +25,6 @@ so that we  can run ./config.status name-of-the command.
 
 ** Allow --header, --command, --file to config.status.
 
-** Fix the two sed quoting snippets for config.status.
-That of #defines has in addition a problem of sed portability on Irix.
-That of the AC_SUBST is broken since when went from s%%%g to s%%%;t t.
-
 ** Move AM_PROG_CC_STDC into Autoconf.
 Autoconf should provide the means to determine the ANSIsm of the
 compiler, not Automake.
diff --git a/acspecific.m4 b/acspecific.m4
index d945a850..2f2f79f5 100644
--- a/acspecific.m4
+++ b/acspecific.m4
@@ -831,6 +831,7 @@ dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
 dnl ----------------------------------------------------
 dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
 dnl defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
+AC_DEFUN(AC_CHECK_HEADER_DIRENT,
 [ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
 AC_MSG_CHECKING([for $1 that defines DIR])
 AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
diff --git a/configure b/configure
index a0d98550..2ce59952 100755
--- a/configure
+++ b/configure
@@ -101,23 +101,23 @@ do
     datadir="$ac_optarg" ;;
 
   -disable-* | --disable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*disable-//'`
+    ac_feature=`echo "$ac_option"|sed -e 's/-*disable-//'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then
+    if test -n "`echo "$ac_feature"| sed 's/[-a-zA-Z0-9_]//g'`"; then
       { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
     fi
     ac_feature=`echo $ac_feature| sed 's/-/_/g'`
     eval "enable_${ac_feature}=no" ;;
 
   -enable-* | --enable-*)
-    ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'`
+    ac_feature=`echo "$ac_option"|sed -e 's/-*enable-//' -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then
+    if test -n "`echo "$ac_feature"| sed 's/[-_a-zA-Z0-9]//g'`"; then
       { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; }
     fi
     ac_feature=`echo $ac_feature| sed 's/-/_/g'`
     case "$ac_option" in
-      *=*) ;;
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
     eval "enable_${ac_feature}='$ac_optarg'" ;;
@@ -357,22 +357,22 @@ Some of the influent environment variables:$ac_arg_var_help"
     exit 0 ;;
 
   -with-* | --with-*)
-    ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'`
+    ac_package=`echo "$ac_option"|sed -e 's/-*with-//' -e 's/=.*//'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then
+    if test -n "`echo "$ac_package"| sed 's/[-_a-zA-Z0-9]//g'`"; then
       { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
     fi
     ac_package=`echo $ac_package| sed 's/-/_/g'`
     case "$ac_option" in
-      *=*) ;;
+      *=*) ac_optarg=`echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"`;;
       *) ac_optarg=yes ;;
     esac
     eval "with_${ac_package}='$ac_optarg'" ;;
 
   -without-* | --without-*)
-    ac_package=`echo $ac_option|sed -e 's/-*without-//'`
+    ac_package=`echo "$ac_option"|sed -e 's/-*without-//'`
     # Reject names that are not valid shell variable names.
-    if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then
+    if test -n "`echo "$ac_package"| sed 's/[-a-zA-Z0-9_]//g'`"; then
       { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; }
     fi
     ac_package=`echo $ac_package| sed 's/-/_/g'`
@@ -409,7 +409,7 @@ Some of the influent environment variables:$ac_arg_var_help"
     export $ac_envvar ;;
 
   *)
-    if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then
+    if test -n "`echo "$ac_option"| sed 's/[-a-z0-9.]//g'`"; then
       echo "configure: warning: $ac_option: invalid host type" 1>&2
     fi
     if test "x$nonopt" != xNONE; then
@@ -458,6 +458,7 @@ do
   -no-recursion | --no-recursion | --no-recursio | --no-recursi \
   | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;;
   *" "*|*"	"*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*)
+  ac_arg=`echo "$ac_arg"|sed "s/'/'\\\\\\\\''/g"`
   ac_configure_args="$ac_configure_args '$ac_arg'" ;;
   *) ac_configure_args="$ac_configure_args $ac_arg" ;;
   esac
@@ -487,7 +488,7 @@ if test -z "$srcdir"; then
   ac_srcdir_defaulted=yes
   # Try the directory containing this script, then its parent.
   ac_prog=$0
-  ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
+  ac_confdir=`echo "$ac_prog"|sed 's%/[^/][^/]*$%%'`
   test "x$ac_confdir" = "x$ac_prog" && ac_confdir=.
   srcdir=$ac_confdir
   if test ! -r $srcdir/$ac_unique_file; then
@@ -576,7 +577,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word... $ac_c" 1>&6
-echo "configure:580: checking for $ac_word" 1>&5
+echo "configure:581: checking for $ac_word" 1>&5
 if test "${ac_cv_path_M4+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -589,7 +590,7 @@ else
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
+    if test -f "$ac_dir/$ac_word"; then
       ac_cv_path_M4="$ac_dir/$ac_word"
       break
     fi
@@ -610,7 +611,7 @@ done
 test -n "$M4" || M4="m4"
 
 echo $ac_n "checking whether we are using GNU m4... $ac_c" 1>&6
-echo "configure:614: checking whether we are using GNU m4" 1>&5
+echo "configure:615: checking whether we are using GNU m4" 1>&5
 if test "${acac_cv_gnu_m4+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -630,7 +631,7 @@ do
 # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
 echo $ac_n "checking for $ac_word... $ac_c" 1>&6
-echo "configure:634: checking for $ac_word" 1>&5
+echo "configure:635: checking for $ac_word" 1>&5
 if test "${ac_cv_prog_AWK+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -663,7 +664,7 @@ done
 # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
 echo $ac_n "checking for $ac_word... $ac_c" 1>&6
-echo "configure:667: checking for $ac_word" 1>&5
+echo "configure:668: checking for $ac_word" 1>&5
 if test "${ac_cv_path_PERL+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
 else
@@ -676,7 +677,7 @@ else
   ac_dummy="$PATH"
   for ac_dir in $ac_dummy; do
     test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/$ac_word; then
+    if test -f "$ac_dir/$ac_word"; then
       ac_cv_path_PERL="$ac_dir/$ac_word"
       break
     fi
@@ -734,7 +735,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure.
 # SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
 # ./install, which can be erroneously created by make from ./install.sh.
 echo $ac_n "checking for a BSD compatible install... $ac_c" 1>&6
-echo "configure:738: checking for a BSD compatible install" 1>&5
+echo "configure:739: checking for a BSD compatible install" 1>&5
 if test -z "$INSTALL"; then
 if test "${ac_cv_path_install+set}" = set; then
   echo $ac_n "(cached) $ac_c" 1>&6
@@ -942,7 +943,7 @@ for ac_option
 do
   case "\$ac_option" in
   -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
-    echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion"
+    echo "running \${CONFIG_SHELL-/bin/sh} $0 `echo "$ac_configure_args" | sed 's/[\\"\`\$]/\\\\&/g'` --no-create --no-recursion"
     exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;;
   -version | --version | --versio | --versi | --vers | --ver | --ve | --v)
     echo "\$ac_cs_version"; exit 0 ;;
@@ -1002,8 +1003,8 @@ EOF
 
 cat >>$CONFIG_STATUS <<EOF
 # Protect against being on the right side of a sed subst in config.status.
-sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g;
- s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > \$ac_cs_root.subs <<\\CEOF
+sed 's/%@/@@/; s/@%/@@/; s/%;t t\$/@;t t/; /@;t t\$/s/[\\\\&%]/\\\\&/g;
+ s/@@/%@/; s/@@/@%/; s/@;t t\$/%;t t/' > \$ac_cs_root.subs <<\\CEOF
 s%@SHELL@%$SHELL%;t t
 s%@CFLAGS@%$CFLAGS%;t t
 s%@CPPFLAGS@%$CPPFLAGS%;t t
diff --git a/lib/autoconf/specific.m4 b/lib/autoconf/specific.m4
index d945a850..2f2f79f5 100644
--- a/lib/autoconf/specific.m4
+++ b/lib/autoconf/specific.m4
@@ -831,6 +831,7 @@ dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND)
 dnl ----------------------------------------------------
 dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE
 dnl defines the type `DIR'.  dirent.h on NextStep 3.2 doesn't.
+AC_DEFUN(AC_CHECK_HEADER_DIRENT,
 [ac_safe=`echo "$1" | sed 'y%./+-%__p_%'`
 AC_MSG_CHECKING([for $1 that defines DIR])
 AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,