[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: for (i in arr) in AWK
From: |
Akim Demaille |
Subject: |
FYI: for (i in arr) in AWK |
Date: |
06 Dec 2000 16:08:47 +0100 |
User-agent: |
Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Channel Islands) |
Index: ChangeLog
from Akim Demaille <address@hidden>
* doc/autoconf.texi (Limitations of Usual Tools) <awk>: `for' on
arrays is nondeterministic across AWK implementations.
* tests/tools.at (autoconf: forbidden tokens): Sort the error
message to guarantee its uniqueness.
Index: doc/autoconf.texi
===================================================================
RCS file: /cvs/autoconf/doc/autoconf.texi,v
retrieving revision 1.402
diff -u -u -r1.402 autoconf.texi
--- doc/autoconf.texi 2000/11/30 17:48:50 1.402
+++ doc/autoconf.texi 2000/12/06 15:00:15
@@ -5920,6 +5920,25 @@
Aaaaarg!
@end example
+If you want your program to be deterministic, don't depend on @code{for}
+on arrays:
+
address@hidden
+$ cat for.awk
+END @{
+ arr["foo"] = 1
+ arr["bar"] = 1
+ for (i in arr)
+ print i
address@hidden
+$ gawk -f for.awk </dev/null
+foo
+bar
+$ nawk -f for.awk </dev/null
+bar
+foo
address@hidden example
+
@item @command{cat}
@c ----------------
Index: tests/tools.at
===================================================================
RCS file: /cvs/autoconf/tests/tools.at,v
retrieving revision 1.15
diff -u -u -r1.15 tools.at
--- tests/tools.at 2000/12/06 10:53:59 1.15
+++ tests/tools.at 2000/12/06 15:00:16
@@ -186,16 +186,18 @@
-## ------------------ ##
-## Forbidden tokens. ##
-## ------------------ ##
+## ---------------------------- ##
+## autoconf: forbidden tokens. ##
+## ---------------------------- ##
-AT_SETUP([Forbidden tokens])
+AT_SETUP([autoconf: forbidden tokens])
AT_DATA([configure.in],
[[AC_PLAIN_SCRIPT()dnl
# 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_pattern_allow([^AC_ALLOWED$])
NOT_AC_ALLOWED AC_ALLOWED AC_ALLOWED_NOT
@@ -212,17 +214,20 @@
It would be very bad if Autoconf forgot to expand [AC_]OUTPUT!
]])
-AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir], 1, [],
-[[configure.in:5: error: undefined macro: NOT_AC_ALLOWED
-configure.in:5: error: undefined macro: AC_ALLOWED_NOT
-configure.in:8: error: undefined macro: FORBIDDEN
-configure.in:12: error: undefined macro: AC_THIS_IS_INVALID
+AT_CHECK([autoconf --autoconf-dir .. -l $at_srcdir 2>err], 1)
+# The output of autoconf is not deterministic here because it
+# uses `for (ind in array)'. So be sure to have a unique representation.
+AT_CHECK([sort <err], 0,
+[[configure.in:12: error: undefined macro: AC_THIS_IS_INVALID
configure.in:12: error: undefined macro: AZ_THIS_IS_INVALID_TOO
configure.in:13: error: undefined macro: ALTHOUGH_AC_THIS_IS
+configure.in:5: error: undefined macro: AC_ALLOWED_NOT
+configure.in:5: error: undefined macro: NOT_AC_ALLOWED
+configure.in:8: error: undefined macro: FORBIDDEN
configure:16: error: undefined macro: AC_OUTPUT
]])
-AT_CLEANUP(configure)
+AT_CLEANUP(configure err)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: for (i in arr) in AWK,
Akim Demaille <=