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

https://github.com/libsdl-org/autoconf/commit/6768ab7157575d8ab1a3c7d4239ca363532e9094

From 6768ab7157575d8ab1a3c7d4239ca363532e9094 Mon Sep 17 00:00:00 2001
From: Akim Demaille <[EMAIL REDACTED]>
Date: Tue, 5 Oct 1999 08:48:23 +0000
Subject: [PATCH] 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'.
	Additionally, work around a bug in IRIX sed.
	Suggested by Ken Pizzini.

	* acgeneral.m4 (AC_OUTPUT_HEADER): Added a label and a test in the
	sed code of `$ac_cs_root.hdr'.
---
 ChangeLog               | 10 ++++++++++
 acgeneral.m4            | 17 +++++++++++++++++
 lib/autoconf/general.m4 | 17 +++++++++++++++++
 3 files changed, 44 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index ef5f37fd..aa69cb5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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'.
+	Additionally, work around a bug in IRIX sed.
+	Suggested by Ken Pizzini.
+
+	* acgeneral.m4 (AC_OUTPUT_HEADER): Added a label and a test in the
+	sed code of `$ac_cs_root.hdr'.
+
 1999-10-05  Akim Demaille  <akim@epita.fr>
 
 	Implement AC_PATH_TOOL.
diff --git a/acgeneral.m4 b/acgeneral.m4
index 9817860d..16fcda4c 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -3342,15 +3342,32 @@ EOF
 rm -f conftest.vals
 dnl Using a here document instead of a string reduces the quoting nightmare.
 dnl Putting comments in sed scripts is not portable.
+dnl
 dnl One may be tempted to use the same trick to speed up the sed script
 dnl as for CONFIG_FILES (combination of :t and t t).  Here we cannot,
 dnl because of the `#define' templates: we may enter in infinite loops
 dnl replacing `#define foo bar' by itself.
 dnl We ought to get rid of the #define templates.
+dnl
+dnl There are two labels in the following scripts, `cleanup' and `clear'.
+dnl
+dnl `cleanup' is used to avoid that the second main sed command (meant for
+dnl 0-ary CPP macros) applies to n-ary macro definitions.  So we use
+dnl `t cleanup' to jump over the second main sed command when it succeeded.
+dnl
+dnl But because in sed the `t' flag is set when there is a substitution
+dnl that succeeded before, and not *right* before (i.e., included the
+dnl first two small commands), we need to clear the `t' flag.  This is the
+dnl purpose of `t clear; : clear'.
+dnl
+dnl Additionally, this works around a bug of IRIX' sed which does not
+dnl clear the `t' flag between to cycles.
 cat > $ac_cs_root.hdr <<\EOF
 changequote(<<, >>)dnl
 s/[\\&%]/\\&/g
 s%[\\$`]%\\&%g
+t clear
+: clear
 s%^[ 	]*<<#>>[ 	]*define[ 	][ 	]*\(\([^ 	(][^ 	(]*\)([^)]*)\)[ 	]*\(.*\)$%${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD}%gp
 t cleanup
 s%^[ 	]*<<#>>[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index 9817860d..16fcda4c 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -3342,15 +3342,32 @@ EOF
 rm -f conftest.vals
 dnl Using a here document instead of a string reduces the quoting nightmare.
 dnl Putting comments in sed scripts is not portable.
+dnl
 dnl One may be tempted to use the same trick to speed up the sed script
 dnl as for CONFIG_FILES (combination of :t and t t).  Here we cannot,
 dnl because of the `#define' templates: we may enter in infinite loops
 dnl replacing `#define foo bar' by itself.
 dnl We ought to get rid of the #define templates.
+dnl
+dnl There are two labels in the following scripts, `cleanup' and `clear'.
+dnl
+dnl `cleanup' is used to avoid that the second main sed command (meant for
+dnl 0-ary CPP macros) applies to n-ary macro definitions.  So we use
+dnl `t cleanup' to jump over the second main sed command when it succeeded.
+dnl
+dnl But because in sed the `t' flag is set when there is a substitution
+dnl that succeeded before, and not *right* before (i.e., included the
+dnl first two small commands), we need to clear the `t' flag.  This is the
+dnl purpose of `t clear; : clear'.
+dnl
+dnl Additionally, this works around a bug of IRIX' sed which does not
+dnl clear the `t' flag between to cycles.
 cat > $ac_cs_root.hdr <<\EOF
 changequote(<<, >>)dnl
 s/[\\&%]/\\&/g
 s%[\\$`]%\\&%g
+t clear
+: clear
 s%^[ 	]*<<#>>[ 	]*define[ 	][ 	]*\(\([^ 	(][^ 	(]*\)([^)]*)\)[ 	]*\(.*\)$%${ac_dA}\2${ac_dB}\1${ac_dC}\3${ac_dD}%gp
 t cleanup
 s%^[ 	]*<<#>>[ 	]*define[ 	][ 	]*\([^ 	][^ 	]*\)[ 	]*\(.*\)$%${ac_dA}\1${ac_dB}\1${ac_dC}\2${ac_dD}%gp