autoconf: 1999-10-05 Akim Demaille <akim@epita.fr> (7837b)

https://github.com/libsdl-org/autoconf/commit/7837bd5f25998f054b782bc96d7daaf4979bcc6c

From 7837bd5f25998f054b782bc96d7daaf4979bcc6c Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Tue, 5 Oct 1999 09:03:05 +0000
Subject: [PATCH] 1999-10-05  Akim Demaille  <akim@epita.fr>

	The sed quoting script depends on the shape of the commands used
	by AC_SUBST.  The latter was changed, but not the former.
	Bug triggered with FOO='%\c' AC_SUBST(FOO).

	* acgeneral.m4 (AC_OUTPUT_FILES): Fix the sed quoting script.
---
 ChangeLog               |  9 +++++++++
 acgeneral.m4            | 14 +++++++++++---
 lib/autoconf/general.m4 | 14 +++++++++++---
 3 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index aa69cb5c..0f5ff15d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,16 @@
+1999-10-05  Akim Demaille  <akim@epita.fr>
+
+	The sed quoting script depends on the shape of the commands used
+	by AC_SUBST.  The latter was changed, but not the former.
+	Bug triggered with FOO='%\c' AC_SUBST(FOO).
+
+	* acgeneral.m4 (AC_OUTPUT_FILES): Fix the sed quoting script.
+
 1999-10-05  Akim Demaille  <akim@epita.fr>
 
 	When you rely on the `t' flag of sed for the immediately
 	preceding substitution, use a combination of `: foo; t foo'.
+	Bug triggered if you AC_DEFINE(FOO, "%").
 	Additionally, work around a bug in IRIX sed.
 	Suggested by Ken Pizzini.
 
diff --git a/acgeneral.m4 b/acgeneral.m4
index 16fcda4c..eb178f7d 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -1826,9 +1826,12 @@ EOF
 dnl ### Setting output variables
 
 
+dnl AC_SUBST(VARIABLE)
+dnl ------------------
 dnl This macro protects VARIABLE from being diverted twice
 dnl if this macro is called twice for it.
-dnl AC_SUBST(VARIABLE)
+dnl Beware that if you change this macro, you also have to change the
+dnl sed script at the top of AC_OUTPUT_FILES.
 define(AC_SUBST,
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
@@ -1838,6 +1841,8 @@ AC_DIVERT_POP()dnl
 ])])
 
 dnl AC_SUBST_FILE(VARIABLE)
+dnl -----------------------
+dnl Read the comments of the preceding macro.
 define(AC_SUBST_FILE,
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
@@ -3137,9 +3142,12 @@ dnl Upon exit, no here document shall be opened.
 define(AC_OUTPUT_FILES,
 [cat >>$CONFIG_STATUS <<EOF
 # Protect against being on the right side of a sed subst in config.status.
+dnl Please, pay attention that this sed code depends a lot on the shape
+dnl of the sed commands issued by AC_SUBST.  So if you change one, change
+dnl the other too.
 changequote(, )dnl
-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
 changequote([, ])dnl
 dnl These here document variables are unquoted when configure runs
 dnl but quoted when config.status runs, so variables are expanded once.
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 16fcda4c..eb178f7d 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1826,9 +1826,12 @@ EOF
 dnl ### Setting output variables
 
 
+dnl AC_SUBST(VARIABLE)
+dnl ------------------
 dnl This macro protects VARIABLE from being diverted twice
 dnl if this macro is called twice for it.
-dnl AC_SUBST(VARIABLE)
+dnl Beware that if you change this macro, you also have to change the
+dnl sed script at the top of AC_OUTPUT_FILES.
 define(AC_SUBST,
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
@@ -1838,6 +1841,8 @@ AC_DIVERT_POP()dnl
 ])])
 
 dnl AC_SUBST_FILE(VARIABLE)
+dnl -----------------------
+dnl Read the comments of the preceding macro.
 define(AC_SUBST_FILE,
 [ifdef([AC_SUBST_$1], ,
 [define([AC_SUBST_$1], )dnl
@@ -3137,9 +3142,12 @@ dnl Upon exit, no here document shall be opened.
 define(AC_OUTPUT_FILES,
 [cat >>$CONFIG_STATUS <<EOF
 # Protect against being on the right side of a sed subst in config.status.
+dnl Please, pay attention that this sed code depends a lot on the shape
+dnl of the sed commands issued by AC_SUBST.  So if you change one, change
+dnl the other too.
 changequote(, )dnl
-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
 changequote([, ])dnl
 dnl These here document variables are unquoted when configure runs
 dnl but quoted when config.status runs, so variables are expanded once.