3 # Extract all examples from the manual source.
4 # Copyright (C) 1992, 2005-2013 Free Software Foundation, Inc.
6 # This file is part of GNU M4.
8 # GNU M4 is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # GNU M4 is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 # This script was designed under GNU awk, but hopefully portable to
22 # other implementations.
42 printf(" -- %d file%s", seq, seq == 1 ? "" : "s");
47 node = substr(tmp[1], 7);
48 if (length(node) > 10)
49 printf("Node: %s - truncated", node);
51 printf("Node: %s ", node);
53 node = tolower(substr(node, 1, 10));
66 /^@comment status: / {
70 /^@comment options: / {
72 gsub ("@comment options:", "", options);
77 gsub ("@comment xout: ", "", xout);
82 gsub ("@comment xerr: ", "", xerr);
85 /^@example$/, /^@end example$/ {
88 if ($0 ~ /^@example$/) {
93 file = sprintf("%03d.%s", count, node);
94 printf("dnl @ %s:%d: Origin of test\n"\
95 "dnl @ expected status: %d\n"\
96 "dnl @ extra options: %s\n"\
97 "dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software\n"\
98 "dnl @ Foundation, Inc.\n"\
99 "dnl @ This file is free software; the Free Software Foundation\n"\
100 "dnl @ gives unlimited permission to copy and/or distribute it\n"\
101 "dnl @ with or without modifications, as long as this notice\n"\
102 "dnl @ is preserved.\n", FILENAME, NR, status, options) > file;
104 printf("dnl @ expected output: %s\n", xout) > file;
106 printf("dnl @ expected error: %s\n", xerr) > file;
113 if ($0 ~ /^@end example$/) {
120 if ($0 ~ /^@result\{\}/ || $0 ~ /^@error\{\}/)
125 gsub("@[{]", "{", $0);
127 gsub("@w[{] }", " ", $0);
128 gsub("@tabchar[{]}", "\t", $0);
129 printf("%s%s\n", prefix, $0) >> file;