Hello,
  let me remind that AC_FOREACH is like m4_foreach, but it operates
on a whitespace separated list.

Some autoconf macros use m4_foreach, some AC_FOREACH, and the difference
is only in the syntax of the list.  Thus I think the different
``namespaces'' are not justified.

So I  moved it to m4sugar, under the name m4_foreach_w.
(I found one place where it can be used within m4sugar, which is another
proof it belongs there.)

Then I replaced all usages of AC_FOREACH and obsolated AC_FOREACH.
I think this is OK, as AC_FOREACH was never documented.

Patch attached; it passed make check.

OK to commit?

Have a nice day,
Stepan Kasal
2005-05-24  Stepan Kasal  <[EMAIL PROTECTED]>

        * lib/autoconf/general.m4 (AC_FOREACH): Make obsolete; it's
        replaced ...
        * lib/m4sugar/m4sugar.m4 (m4_foreach_w): ... by this new macro.

Index: lib/autoconf/functions.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/functions.m4,v
retrieving revision 1.93
diff -u -r1.93 functions.m4
--- lib/autoconf/functions.m4   14 May 2005 18:33:30 -0000      1.93
+++ lib/autoconf/functions.m4   24 May 2005 06:38:55 -0000
@@ -78,7 +78,7 @@
 # AC_CHECK_FUNCS(FUNCTION..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # ---------------------------------------------------------------------
 AC_DEFUN([AC_CHECK_FUNCS],
-[AC_FOREACH([AC_Func], [$1],
+[m4_foreach_w([AC_Func], [$1],
   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Func),
               [Define to 1 if you have the `]AC_Func[' function.])])dnl
 for ac_func in $1
@@ -93,7 +93,7 @@
 # AC_REPLACE_FUNCS(FUNCTION...)
 # -----------------------------
 AC_DEFUN([AC_REPLACE_FUNCS],
-[AC_FOREACH([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
+[m4_foreach_w([AC_Func], [$1], [AC_LIBSOURCE(AC_Func.c)])dnl
 AC_CHECK_FUNCS([$1], , [_AC_LIBOBJ($ac_func)])
 ])
 
Index: lib/autoconf/general.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/general.m4,v
retrieving revision 1.858
diff -u -r1.858 general.m4
--- lib/autoconf/general.m4     24 May 2005 06:12:10 -0000      1.858
+++ lib/autoconf/general.m4     24 May 2005 06:38:55 -0000
@@ -190,22 +190,9 @@
 ## ----------------------------- ##
 
 
-# AC_FOREACH(VARIABLE, LIST, EXPRESSION)
-# --------------------------------------
-#
-# Compute EXPRESSION assigning to VARIABLE each value of the LIST.
-# LIST is a /bin/sh list, i.e., it has the form ` item_1 item_2
-# ... item_n ': white spaces are separators, and leading and trailing
-# spaces are meaningless.
-#
-# This macro is robust to active symbols:
-#    AC_FOREACH([Var], [ active
-#    b act\
-#    ive  ], [-Var-])end
-#    => -active--b--active-end
-m4_define([AC_FOREACH],
-[m4_foreach([$1], m4_split(m4_normalize([$2])), [$3])])
-
+# AU::AC_FOREACH(VARIABLE, LIST, EXPRESSION)
+# ------------------------------------------
+AU_ALIAS([AC_FOREACH], [m4_foreach_w])
 
 
 
@@ -2425,7 +2412,7 @@
 # AC_CHECK_FILES(FILE..., [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # -----------------------------------------------------------------
 AC_DEFUN([AC_CHECK_FILES],
-[AC_FOREACH([AC_FILE_NAME], [$1],
+[m4_foreach_w([AC_FILE_NAME], [$1],
   [AC_CHECK_FILE(AC_FILE_NAME,
                 [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_[]AC_FILE_NAME), 1,
                                    [Define to 1 if you have the
Index: lib/autoconf/headers.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/headers.m4,v
retrieving revision 1.43
diff -u -r1.43 headers.m4
--- lib/autoconf/headers.m4     14 May 2005 07:00:40 -0000      1.43
+++ lib/autoconf/headers.m4     24 May 2005 06:38:55 -0000
@@ -185,7 +185,7 @@
 # AH_CHECK_HEADERS(HEADER-FILE...)
 # --------------------------------
 m4_define([AH_CHECK_HEADERS],
-[AC_FOREACH([AC_Header], [$1],
+[m4_foreach_w([AC_Header], [$1],
   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Header),
               [Define to 1 if you have the <]AC_Header[> header file.])])])
 
@@ -380,7 +380,7 @@
 # AH_CHECK_HEADERS_DIRENT(HEADERS...)
 # -----------------------------------
 m4_define([AH_CHECK_HEADERS_DIRENT],
-[AC_FOREACH([AC_Header], [$1],
+[m4_foreach_w([AC_Header], [$1],
   [AH_TEMPLATE(AS_TR_CPP(HAVE_[]AC_Header),
               [Define to 1 if you have the <]AC_Header[> header file, and
                it defines `DIR'.])])])
Index: lib/autoconf/status.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autoconf/status.m4,v
retrieving revision 1.57
diff -u -r1.57 status.m4
--- lib/autoconf/status.m4      20 May 2005 08:13:16 -0000      1.57
+++ lib/autoconf/status.m4      24 May 2005 06:38:55 -0000
@@ -215,7 +215,7 @@
 # -------------------------------------------------------
 # Declare the DESTs depend upon their SOURCE1 etc.
 m4_define([_AC_CONFIG_DEPENDENCIES],
-[AC_FOREACH([AC_File], [$1],
+[m4_foreach_w([AC_File], [$1],
   [_AC_CONFIG_DEPENDENCY(m4_bpatsubst(AC_File, [:], [,]))])dnl
 ])
 
@@ -230,7 +230,7 @@
 # Note that this macro does not check if the list $[1] itself
 # contains doubles.
 m4_define([_AC_CONFIG_UNIQUE],
-[AC_FOREACH([AC_File], [$1],
+[m4_foreach_w([AC_File], [$1],
 [m4_pushdef([AC_Dest], m4_bpatsubst(AC_File, [:.*]))dnl
   AC_CONFIG_IF_MEMBER(AC_Dest, [AC_LIST_HEADERS],
      [AC_FATAL(`AC_Dest' [is already registered with AC_CONFIG_HEADERS.])])dnl
@@ -326,7 +326,7 @@
 # commands must be associated with a NAME, which should be thought
 # as the name of a file the COMMANDS create.
 AC_DEFUN([AC_CONFIG_COMMANDS],
-[AC_FOREACH([AC_Name], [$1], [_AC_CONFIG_COMMAND(m4_defn([AC_Name]), [$2])])dnl
+[m4_foreach_w([AC_Name], [$1], [_AC_CONFIG_COMMAND(m4_defn([AC_Name]), 
[$2])])dnl
 _AC_CONFIG_COMMANDS_INIT([$3])dnl
 ac_config_commands="$ac_config_commands $1"
 ])
@@ -456,7 +456,7 @@
 #        AC_LIST_HEADERS_COMMANDS
 #      esac
 AC_DEFUN([AC_CONFIG_HEADERS],
-[AC_FOREACH([AC_File], [$1], [_AC_CONFIG_HEADER(m4_defn([AC_File]), [$2])])dnl
+[m4_foreach_w([AC_File], [$1], [_AC_CONFIG_HEADER(m4_defn([AC_File]), 
[$2])])dnl
 _AC_CONFIG_COMMANDS_INIT([$3])dnl
 ac_config_headers="$ac_config_headers m4_normalize([$1])"
 ])
@@ -739,7 +739,7 @@
 # Reject DEST=., because it is makes it hard for ./config.status
 # to guess the links to establish (`./config.status .').
 AC_DEFUN([AC_CONFIG_LINKS],
-[AC_FOREACH([AC_File], [$1], [_AC_CONFIG_LINK(m4_defn([AC_File]), [$2])])dnl
+[m4_foreach_w([AC_File], [$1], [_AC_CONFIG_LINK(m4_defn([AC_File]), [$2])])dnl
 _AC_CONFIG_COMMANDS_INIT([$3])dnl
 ac_config_links="$ac_config_links m4_normalize([$1])"
 ])
@@ -870,7 +870,7 @@
 #        AC_LIST_FILES_COMMANDS
 #      esac
 AC_DEFUN([AC_CONFIG_FILES],
-[AC_FOREACH([AC_File], [$1], [_AC_CONFIG_FILE(m4_defn([AC_File]), [$2])])dnl
+[m4_foreach_w([AC_File], [$1], [_AC_CONFIG_FILE(m4_defn([AC_File]), [$2])])dnl
 _AC_CONFIG_COMMANDS_INIT([$3])dnl
 ac_config_files="$ac_config_files m4_normalize([$1])"
 ])
@@ -908,11 +908,11 @@
 dnl but quoted when config.status runs, so variables are expanded once.
 dnl Insert the sed substitutions of variables.
 m4_ifdef([_AC_SUBST_VARS],
-        [AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]),
+        [m4_foreach_w([AC_Var], m4_defn([_AC_SUBST_VARS]),
 [s,@AC_Var@,$AC_Var,;t t
 ])])dnl
 m4_ifdef([_AC_SUBST_FILES],
-        [AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_FILES]),
+        [m4_foreach_w([AC_Var], m4_defn([_AC_SUBST_FILES]),
 [/@AC_Var@/r $AC_Var
 s,@AC_Var@,,;t t
 ])])dnl
@@ -1526,19 +1526,19 @@
 do
   case "$ac_config_target" in
   # Handling of arguments.
-AC_FOREACH([AC_File], AC_LIST_FILES,
+m4_foreach_w([AC_File], AC_LIST_FILES,
 [  "m4_bpatsubst(AC_File, [:.*])" )dnl
  CONFIG_FILES="$CONFIG_FILES AC_File" ;;
 ])dnl
-AC_FOREACH([AC_File], AC_LIST_LINKS,
+m4_foreach_w([AC_File], AC_LIST_LINKS,
 [  "m4_bpatsubst(AC_File, [:.*])" )dnl
  CONFIG_LINKS="$CONFIG_LINKS AC_File" ;;
 ])dnl
-AC_FOREACH([AC_File], AC_LIST_COMMANDS,
+m4_foreach_w([AC_File], AC_LIST_COMMANDS,
 [  "m4_bpatsubst(AC_File, [:.*])" )dnl
  CONFIG_COMMANDS="$CONFIG_COMMANDS AC_File" ;;
 ])dnl
-AC_FOREACH([AC_File], AC_LIST_HEADERS,
+m4_foreach_w([AC_File], AC_LIST_HEADERS,
 [  "m4_bpatsubst(AC_File, [:.*])" )dnl
  CONFIG_HEADERS="$CONFIG_HEADERS AC_File" ;;
 ])dnl
Index: lib/m4sugar/m4sugar.m4
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/m4sugar/m4sugar.m4,v
retrieving revision 2.88
diff -u -r2.88 m4sugar.m4
--- lib/m4sugar/m4sugar.m4      17 May 2005 09:49:37 -0000      2.88
+++ lib/m4sugar/m4sugar.m4      24 May 2005 06:38:55 -0000
@@ -690,6 +690,21 @@
                                                   [$3])])])
 
 
+# m4_foreach_w(VARIABLE, LIST, EXPRESSION)
+# ----------------------------------------
+#
+# Like m4_foreach, but the list is whitespace separated.
+#
+# This macro is robust to active symbols:
+#    m4_foreach_w([Var], [ active
+#    b act\
+#    ive  ], [-Var-])end
+#    => -active--b--active-end
+#
+m4_define([m4_foreach_w],
+[m4_foreach([$1], m4_split(m4_normalize([$2])), [$3])])
+
+
 
 ## --------------------------- ##
 ## 8. More diversion support.  ##
@@ -1555,7 +1570,7 @@
 m4_if(m4_eval(m4_Cursor > m4_len(m4_Prefix)),
       1, [m4_define([m4_Cursor], m4_len(m4_Prefix))
 m4_Prefix])[]dnl
-m4_foreach([m4_Word], m4_split(m4_normalize([$1])),
+m4_foreach_w([m4_Word], [$1],
 [m4_define([m4_Cursor], m4_eval(m4_Cursor + m4_len(m4_defn([m4_Word])) + 1))dnl
 dnl New line if too long, else insert a space unless it is the first
 dnl of the words.

Reply via email to