[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
19-fyi-as-init.patch
From: |
Akim Demaille |
Subject: |
19-fyi-as-init.patch |
Date: |
Mon, 08 Oct 2001 10:29:32 +0200 |
It's time to clean up M4sh a bit. One goal I'm aiming at is having
M4sh include the portable prolog only for features which are actually
used, thanks to m4_defun/m4_require.
In other words, finish decoupling Autoconf from M4sh, in particular in
the test suite (many M4sh features are still exercised at the Autoconf
level).
Index: ChangeLog
from Akim Demaille <address@hidden>
* lib/autoconf/general.m4 (_m4_divert(BODY)): Move to...
* lib/m4sugar/m4sh.m4: here.
(AS_INIT): Push the BODY diversion, set the #! /bin/sh line.
* lib/autoconf/general.m4 (AC_PLAIN_SCRIPT) : Remove.
(AT_INIT): Replace AC_PLAIN_SCRIPT with AS_INIT invocation,
include handle the m4_pattern_*, no longer push the
BODY diversion nor set the /bin/sh line, AS_INIT does it.
* lib/autotest/general.m4 (AT_INIT): Likewise.
* tests/base.at: Adjust the tests to use AS_INIT.
* tests/tools.at (AT_DATA_FORBIDDEN): New.
(autoconf: forbidden tokens): Adjust to work on M4sh instead of
Autoconf.
Index: lib/autoconf/general.m4
--- lib/autoconf/general.m4 Fri, 05 Oct 2001 19:29:25 +0200 akim
+++ lib/autoconf/general.m4 Fri, 05 Oct 2001 20:28:01 +0200 akim
@@ -120,15 +120,16 @@
# of little macros, but it then takes twice longer to run `autoconf'!
#
# From M4sugar:
-# -1. KILL
+# -1. KILL
+# 10000. GROW
#
# From M4sh:
-# 0. BINSH
-# 1. HEADER-REVISION
-# 2. HEADER-COMMENT
-# 3. HEADER-COPYRIGHT
-# 4. M4SH-INIT
-
+# 0. BINSH
+# 1. HEADER-REVISION
+# 2. HEADER-COMMENT
+# 3. HEADER-COPYRIGHT
+# 4. M4SH-INIT
+# 1000. BODY
m4_define([_m4_divert(DEFAULTS)], 10)
m4_define([_m4_divert(PARSE_ARGS)], 20)
@@ -147,8 +148,6 @@ m4_define([_m4_divert(VERSION_END)],
m4_define([_m4_divert(INIT_PREPARE)], 300)
-m4_define([_m4_divert(BODY)], 400)
-
# AC_DIVERT_PUSH(DIVERSION-NAME)
@@ -1263,26 +1262,6 @@ m4_define([_AC_INIT_PREPARE],
])
-# AC_PLAIN_SCRIPT
-# ---------------
-# Simulate AC_INIT, i.e., pretend this is the beginning of the `configure'
-# generation. This is used by some tests, and lets `autoconf' be used to
-# generate other scripts than `configure'.
-m4_define([AC_PLAIN_SCRIPT],
-[AS_INIT
-
-# Forbidden tokens and exceptions.
-m4_pattern_forbid([^_?A[CHUM]_])
-m4_pattern_forbid([_AC_])
-# Actually reserved by M4sh.
-m4_pattern_allow([^AS_FLAGS$])
-
-m4_divert_push([BODY])dnl
-m4_wrap([m4_divert_pop([BODY])[]])dnl
-])
-
-
-
# AC_INIT([PACKAGE, VERSION, [BUG-REPORT])
# ----------------------------------------
# Include the user macro files, prepare the diversions, and output the
@@ -1290,9 +1269,13 @@ m4_define([AC_PLAIN_SCRIPT],
# Note that the order is important: first initialize, then set the
# AC_CONFIG_SRCDIR.
m4_define([AC_INIT],
-[AC_PLAIN_SCRIPT
+[# Forbidden tokens and exceptions.
+m4_pattern_forbid([^_?A[CHUM]_])
+m4_pattern_forbid([_AC_])
+# Actually reserved by M4sh.
+m4_pattern_allow([^AS_FLAGS$])
+AS_INIT
m4_ifval([$2], [_AC_INIT_PACKAGE($@)])
-m4_divert_text([BINSH], address@hidden:@! /bin/sh])
_AC_INIT_DEFAULTS
_AC_INIT_PARSE_ARGS
_AC_INIT_SRCDIR
Index: lib/autotest/general.m4
--- lib/autotest/general.m4 Mon, 01 Oct 2001 16:36:39 +0200 akim
+++ lib/autotest/general.m4 Fri, 05 Oct 2001 20:33:43 +0200 akim
@@ -88,15 +88,14 @@ m4_define([AT_LINE],
# -------------------------
# Begin test suite.
m4_define([AT_INIT],
-[AS_INIT
-m4_pattern_forbid([^_?AT_])
+[m4_pattern_forbid([^_?AT_])
m4_pattern_forbid([PACKAGE_(BUGREPORT|STRING)$])
m4_define([AT_TESTSUITE_NAME],
m4_defn([PACKAGE_STRING])[ test suite]m4_ifval([$1], [: $1]))
m4_define([AT_ordinal], 0)
m4_define([AT_banner_ordinal], 0)
m4_define([AT_data_files], [stdout expout at-* stderr experr])
-m4_divert_text([BINSH], address@hidden:@! /bin/sh])
+AS_INIT
m4_divert_push([DEFAULT])dnl
AS_SHELL_SANITIZE
Index: lib/m4sugar/m4sh.m4
--- lib/m4sugar/m4sh.m4 Fri, 05 Oct 2001 19:47:35 +0200 akim
+++ lib/m4sugar/m4sh.m4 Fri, 05 Oct 2001 20:28:28 +0200 akim
@@ -66,7 +66,9 @@
# Copyright notice(s)
# - M4SH-INIT
# M4sh's initializations
-
+#
+# - BODY
+# The body of the script.
# _m4_divert(DIVERSION-NAME)
@@ -80,6 +82,7 @@ m4_define([_m4_divert(HEADER-REVISION)],
m4_define([_m4_divert(HEADER-COMMENT)], 2)
m4_define([_m4_divert(HEADER-COPYRIGHT)], 3)
m4_define([_m4_divert(M4SH-INIT)], 4)
+m4_define([_m4_divert(BODY)], 1000)
# Aaarg. Yet it starts with compatibility issues... Libtool wants to
# use NOTICE to insert its own LIBTOOL-INIT stuff. People should ask
@@ -906,4 +909,11 @@ m4_define([AS_INIT],
# Forbidden tokens and exceptions.
m4_pattern_forbid([^_?AS_])
+
+# Bangshe.
+m4_divert_text([BINSH], address@hidden:@! /bin/sh])
+
+# Let's go!
+m4_wrap([m4_divert_pop([BODY])[]])
+m4_divert_push([BODY])[]dnl
])
Index: tests/base.at
--- tests/base.at Fri, 28 Sep 2001 09:38:15 +0200 akim
+++ tests/base.at Fri, 05 Oct 2001 20:32:56 +0200 akim
@@ -49,7 +49,7 @@ AC_DEFUN([TEST3],
[REQUIRE_AND_CHECK([TEST2a])
test3=set])
-AC_PLAIN_SCRIPT()#! /bin/sh
+AS@&address@hidden
TEST1
test -z "$test1" &&
@@ -81,7 +81,7 @@ AC_DEFUN([MULTI_TEST],
AC_DEFUN_ONCE([SINGLE_TEST],
[single_test=".$single_test"])
-AC_PLAIN_SCRIPT()#! /bin/sh
+AS@&address@hidden
TEST
TEST
@@ -125,7 +125,7 @@ AC_DEFUN([MULTI_TEST],
AC_DEFUN_ONCE([SINGLE_TEST],
[single_test=".$single_test"])
-AC_PLAIN_SCRIPT()#! /bin/sh
+AS@&address@hidden
MULTI_TEST
MULTI_TEST
@@ -164,7 +164,7 @@ AC_DEFUN_ONCE([SINGLE_TEST],
AC_DEFUN([INNER_TEST],
[inner_test=".$inner_test"])
-AC_PLAIN_SCRIPT()#! /bin/sh
+AS@&address@hidden
AC_PROVIDE([INNER_TEST])
TEST
Index: tests/m4sh.at
--- tests/m4sh.at Fri, 05 Oct 2001 18:08:44 +0200 akim
+++ tests/m4sh.at Fri, 05 Oct 2001 20:32:56 +0200 akim
@@ -98,7 +98,7 @@ m4_define([AT_DATA_LINENO],
AT_SETUP([[AS_DIRNAME & AS_DIRNAME_SED]])
AT_DATA([configure.ac],
-[[AC_PLAIN_SCRIPT()#! /bin/sh
+[[AS@&address@hidden
_AS@&address@hidden
@@ -153,7 +153,7 @@ m4_define([DIRNAME_TEST],
AT_SETUP([[AS_BASENAME & AS_BASENAME_SED]])
AT_DATA([configure.ac],
-[[AC_PLAIN_SCRIPT()#! /bin/sh
+[[AS@&address@hidden
_AS@&address@hidden
@@ -213,7 +213,7 @@ m4_define([BASENAME_TEST],
AT_SETUP([[AS_MKDIR_P]])
AT_DATA([configure.ac],
-[[AC_PLAIN_SCRIPT()#! /bin/sh
+[[AS@&address@hidden
pwd=`pwd`
set -e
@@ -246,7 +246,7 @@ m4_define([BASENAME_TEST],
AT_SETUP([Negated classes in globbing])
AT_DATA([configure.ac],
-[[AC_PLAIN_SCRIPT()#! /bin/sh
+[[AS@&address@hidden
case 'with!two!bangs' in
*[[!a-z]]*) ;;
Index: tests/tools.at
--- tests/tools.at Sun, 23 Sep 2001 16:12:48 +0200 akim
+++ tests/tools.at Fri, 05 Oct 2001 20:48:49 +0200 akim
@@ -232,40 +232,39 @@ configure.ac:19:TRACE2:bar foo
-
## ---------------------------- ##
## autoconf: forbidden tokens. ##
## ---------------------------- ##
+# AT_DATA_FORBIDDEN(FILENAME, CONTENTS)
+# -------------------------------------
+# Escape the invalid tokens with @&address@hidden
+m4_define([AT_DATA_FORBIDDEN],
+[AT_DATA([$1], [m4_patsubst([$2], [\(m4\|AS\)_], [\1@&address@hidden)])])
+
# autoconf: forbidden tokens, basic
# ---------------------------------
AT_SETUP([autoconf: forbidden tokens, basic])
-m4_pattern_allow([^(m4_foo|_m4_bar|AS_FOO|_AS_BAR)$])
-AT_DATA([configure.ac],
-[[AC_PLAIN_SCRIPT()
-AC_FOO
-_AC_BAR
+AT_DATA_FORBIDDEN([configure.ac],
+[[AS_INIT
m4_foo
_m4_bar
-BAC_FOO
-B_AC_FOO
AS_FOO
_AS_BAR
[d@&address@hidden
]])
-AT_CHECK_AUTOCONF([], 1, [],
-[[configure.ac:2: error: possibly undefined macro: AC_FOO
-configure.ac:3: error: possibly undefined macro: _AC_BAR
-configure.ac:4: error: possibly undefined macro: m4_foo
-configure.ac:5: error: possibly undefined macro: _m4_bar
-configure.ac:7: error: possibly undefined macro: B_AC_FOO
-configure.ac:8: error: possibly undefined macro: AS_FOO
-configure.ac:9: error: possibly undefined macro: _AS_BAR
-configure.ac:10: error: possibly undefined macro: d@&address@hidden
+AT_DATA_FORBIDDEN([experr],
+[[configure.ac:2: error: possibly undefined macro: m4_foo
+configure.ac:3: error: possibly undefined macro: _m4_bar
+configure.ac:4: error: possibly undefined macro: AS_FOO
+configure.ac:5: error: possibly undefined macro: _AS_BAR
+configure.ac:6: error: possibly undefined macro: d@&address@hidden
]])
+AT_CHECK_AUTOCONF([], 1, [], experr)
+
AT_CLEANUP
@@ -273,37 +272,37 @@ configure.ac:10: error: possibly undefin
# --------------------------------------
AT_SETUP([autoconf: forbidden tokens, exceptions])
-AT_DATA([configure.ac],
-[[AC_PLAIN_SCRIPT
+AT_DATA_FORBIDDEN([configure.ac],
+[[AS_INIT
# This is allowed in spite of the name.
# It is on purpose that we check the case where there are several
# tokens on the same line.
-m4@&address@hidden([^AC_ALLOWED$])
-NOT_AC_ALLOWED AC_ALLOWED AC_ALLOWED_NOT
+m4_pattern_allow([^AS_ALLOWED$])
+NOT_AS_ALLOWED AS_ALLOWED AS_ALLOWED_NOT
# Test forbidding.
-m4@&address@hidden([^FORBIDDEN$])
+m4_pattern_forbid([^FORBIDDEN$])
NOT_FORBIDDEN FORBIDDEN FORBIDDEN_NOT
# Test Autoconf's patterns.
-AC_THIS_IS_INVALID and _AC_THIS_IS_INVALID_TOO
-BUT_AZ_THIS_IS_NOT ALTHOUGH_AC_THIS_IS
-# This is legal, although there is `AC_DEFINE' in there.
-BAC_DEFINE
-# AC_THIS_IS_A_COMMENT so just shut up.
-It would be very bad if Autoconf forgot to expand [AC_]OUTPUT!
+AS_THIS_IS_INVALID and _AS_THIS_IS_INVALID_TOO
+BUT_AZ_THIS_IS_NOT ALTHOUGH_AS_THIS_IS
+# This is legal, although there is `AS_DEFINE' in there.
+BAS_DEFINE
+# AS_THIS_IS_A_COMMENT so just shut up.
+It would be very bad if Autoconf forgot to expand [AS_]INIT!
]])
-AT_CHECK_AUTOCONF([], 1, [],
-[[configure.ac:7: error: possibly undefined macro: NOT_AC_ALLOWED
-configure.ac:7: error: possibly undefined macro: AC_ALLOWED_NOT
+AT_DATA_FORBIDDEN([experr],
+[[configure.ac:1: error: possibly undefined macro: AS_INIT
+configure.ac:7: error: possibly undefined macro: AS_ALLOWED_NOT
configure.ac:10: error: possibly undefined macro: FORBIDDEN
-configure.ac:14: error: possibly undefined macro: AC_THIS_IS_INVALID
-configure.ac:14: error: possibly undefined macro: _AC_THIS_IS_INVALID_TOO
-configure.ac:15: error: possibly undefined macro: ALTHOUGH_AC_THIS_IS
-configure:18: error: possibly undefined macro: AC_OUTPUT
+configure.ac:14: error: possibly undefined macro: AS_THIS_IS_INVALID
+configure.ac:14: error: possibly undefined macro: _AS_THIS_IS_INVALID_TOO
]])
+
+AT_CHECK_AUTOCONF([], 1, [], [experr])
AT_CLEANUP
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 19-fyi-as-init.patch,
Akim Demaille <=