[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
12-generate-awk.patch
From: |
Akim Demaille |
Subject: |
12-generate-awk.patch |
Date: |
Mon, 20 Aug 2001 17:42:54 +0200 |
Index: ChangeLog
from Akim Demaille <address@hidden>
* examples/include.m4: Typo.
* tests/generate.awk: Really add it.
* tests/Makefile.am: Adjust.
* tests/others.at (Discard comments): It sure fails without `-c'.
(include, undivert): Add -I examples/.
Index: examples/include.m4
--- examples/include.m4 Thu, 19 Nov 1998 14:02:11 +0100 demaille
+++ examples/include.m4 Sat, 18 Aug 2001 11:33:14 +0200 akim
@@ -1,6 +1,6 @@
Beginning.
include(`NOFILE')
-Intermidiate
+Intermediate
include(`incl-test.m4')
After
include(`NOFILE')
Index: tests/Makefile.am
--- tests/Makefile.am Sat, 18 Aug 2001 10:08:06 +0200 akim
+++ tests/Makefile.am Sat, 18 Aug 2001 10:15:34 +0200 akim
@@ -36,11 +36,9 @@ check-local: atconfig $(TESTSUITE)
$(SHELL) $(srcdir)/$(TESTSUITE)
$(srcdir)/generated.at: $(srcdir)/generate.awk $(top_srcdir)/doc/m4.texinfo
-# FIXME: Stupid Akim TM forgot to bring generate.awk...
-# rm -f $@
-# $(AWK) -f $(srcdir)/generate.awk $(top_srcdir)/doc/m4.texinfo
>address@hidden
-# mv address@hidden $@
- touch $@
+ rm -f $@ address@hidden
+ $(AWK) -f $(srcdir)/generate.awk $(top_srcdir)/doc/m4.texinfo
>address@hidden
+ mv address@hidden $@
# FIXME: Autom4te is not complete yet, and lacks a means to find
# the lib files.
Index: tests/others.at
--- tests/others.at Sat, 18 Aug 2001 10:08:06 +0200 akim
+++ tests/others.at Sat, 18 Aug 2001 16:09:46 +0200 akim
@@ -1,4 +1,4 @@
-# Hand crafted tests for GNU M4. -*- Autoconf -*-
+# Hand crafted tests for GNU M4. -*- Autotest -*-
# Copyright 2001 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
@@ -132,11 +132,11 @@ m4trace: -1- countdown(...) -> `0 ifelse
-## ---------------- ##
-## discard-comments ##
-## ---------------- ##
+## ------------------ ##
+## Discard comments. ##
+## ------------------ ##
-AT_SETUP([discard-comments])
+AT_SETUP([Discard comments])
AT_DATA([[in]],
[[This is not a comment # but this is.
@@ -148,7 +148,7 @@ m4trace: -1- countdown(...) -> `0 ifelse
--> ends.
]])
-AT_CHECK_M4([in], 0,
+AT_CHECK_M4([-c in], 0,
[[This is not a comment This should not disappear.
html ends.
@@ -471,7 +471,7 @@ rimfaxe:/home/rimfaxe /home/rimfaxe
AT_DATA([[expout]],
[[Beginning.
-Intermidiate
+Intermediate
include test file.
@@ -485,7 +485,7 @@ rimfaxe:/home/rimfaxe /home/rimfaxe
m4: ../examples/include.m4: 6: Cannot open NOFILE: No such file or directory
]])
-AT_CHECK_M4([examples/include.m4], 0, expout, experr)
+AT_CHECK_M4([-I $top_srcdir/examples examples/include.m4], 0, expout, experr)
AT_CLEANUP
@@ -1181,7 +1181,8 @@ m4trace: -1- move(auxilliary, destinatio
AT_SETUP([undivert])
-AT_CHECK_M4([examples/undivert.m4], 0,
+# undivert.m4 `include's a file from examples/.
+AT_CHECK_M4([-I $top_srcdir/examples examples/undivert.m4], 0,
[[
# undiverted file.
This is to be undiverted soon.
Index: tests/testsuite.at
--- tests/testsuite.at Sat, 18 Aug 2001 10:08:06 +0200 akim
+++ tests/testsuite.at Sat, 18 Aug 2001 16:10:07 +0200 akim
@@ -1,4 +1,4 @@
-# Process this file with autom4te to create testsuite. -*- Autoconf -*-
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU M4.
# Copyright 2001 Free Software Foundation, Inc.
Index: tests/generate.awk
--- 0.19/tests/generate.awk Sat, 18 Aug 2001 16:23:06 +0200 akim ()
+++ tests/generate.awk Sat, 18 Aug 2001 16:10:38 +0200 akim
@@ -0,0 +1,139 @@
+# Extract all examples from the manual source. -*- AWK -*-
+
+# This file is part of GNU M4
+# Copyright 1992, 2000, 2001 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+# 02111-1307 USA
+
+# This script is for use with any New AWK.
+
+BEGIN {
+ seq = -1;
+ status = 0;
+ print "# This file is part of the GNU m4 test suite. -*- Autotest -*-";
+ # I don't know how to get this file's name, so it's hard coded :(
+ print "# Do not edit by hand, it was generated by generate.awk.";
+ print "#";
+ print "# Copyright 1992, 2000, 2001 Free Software Foundation, Inc.";
+ print ;
+}
+
+/address@hidden / {
+ if (seq > 0)
+ print "AT_CLEANUP";
+
+ split ($0, tmp, ",");
+ node = substr(tmp[1], 7);
+ seq = 0;
+}
+
+/address@hidden ignore$/ {
+ getline;
+ next;
+}
+
+/address@hidden status: / {
+ status = $3;
+}
+
+/address@hidden/, /address@hidden example$/ {
+ if (seq < 0)
+ next;
+
+ if ($0 ~ /address@hidden/)
+ {
+ if (seq == 0)
+ new_group(node);
+ seq++;
+ printf ("# From example in %s line %d.\n\n", FILENAME, NR)
+ next;
+ }
+ else if ($0 ~ /address@hidden example$/)
+ {
+ new_test(input, status, output, error);
+ status = 0;
+ input = output = error = "";
+ next;
+ }
+ else if ($0 ~ /^\^D$/)
+ next;
+ else if ($0 ~ /address@hidden/)
+ output = output $0 "\n";
+ else if ($0 ~ /address@hidden/)
+ error = error $0 "\n";
+ else
+ input = input $0 "\n";
+}
+
+END {
+ if (seq > 0)
+ print "AT_CLEANUP";
+}
+
+# We have to handle CONTENTS line per line, since anchors in AWK are
+# referring to the whole string, not the lines.
+function normalize(contents, i, lines, n, line, res) {
+ # Remove the Texinfo tags.
+ n = split (contents, lines, "\n");
+ # We don't want the last field which empty: it's behind the last \n.
+ for (i = 1; i < n; ++i)
+ {
+ line = lines[i];
+ gsub (/address@hidden/, "", line);
+ gsub (/address@hidden/, "", line);
+ gsub ("@[{]", "{", line);
+ gsub ("@}", "}", line);
+ gsub ("@@", "@", line);
+ gsub ("@comment.*", "@\"\"@", line);
+
+ # Some of the examples have improperly balanced square brackets.
+ gsub ("[[]", "@<:@", line);
+ gsub ("[]]", "@:>@", line);
+
+ res = res line "\n";
+ }
+ return res;
+}
+
+function new_group(node) {
+ banner = node ". ";
+ gsub (/./, "-", banner);
+ printf ("\n\n");
+ printf ("## %s ##\n", banner);
+ printf ("## %s. ##\n", node);
+ printf ("## %s ##\n", banner);
+ printf ("\n");
+ printf ("AT_SETUP([[%s]])\n\n", node);
+}
+
+function new_test(input, status, output, error) {
+ input = normalize(input);
+ output = normalize(output);
+ error = normalize(error);
+
+ printf ("AT_DATA([[in]],\n[[%s]])\n\n", input);
+ # Some of these tests `include' files from tests/.
+ printf ("AT_CHECK_M4([[-I $srcdir in]], %s,", status);
+ if (output)
+ printf ("\n[[%s]]", output);
+ else
+ printf (" []");
+ if (error)
+ printf (",\n[[%s]])", error);
+ else
+ printf (")");
+ printf ("\n\n");
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- 12-generate-awk.patch,
Akim Demaille <=