3 # Extract all examples from the manual source.
4 # Copyright (C) 1992, 2005-2014, 2016-2017, 2020-2021 Free Software
7 # This file is part of GNU M4.
9 # GNU M4 is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # GNU M4 is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <https://www.gnu.org/licenses/>.
22 # This script was designed under GNU awk, but hopefully portable to
23 # other implementations.
43 printf(" -- %d file%s", seq, seq == 1 ? "" : "s");
48 node = substr(tmp[1], 7);
49 if (length(node) > 10)
50 printf("Node: %s - truncated", node);
52 printf("Node: %s ", node);
54 node = tolower(substr(node, 1, 10));
67 /^@comment status: / {
71 /^@comment options: / {
73 gsub ("@comment options:", "", options);
78 gsub ("@comment xout: ", "", xout);
83 gsub ("@comment xerr: ", "", xerr);
86 /^@example$/, /^@end example$/ {
89 if ($0 ~ /^@example$/) {
94 file = sprintf("%03d.%s", count, node);
95 printf("dnl @ %s:%d: Origin of test\n"\
96 "dnl @ expected status: %d\n"\
97 "dnl @ extra options: %s\n"\
98 "dnl @ Copyright (C) 2006, 2007, 2008, 2009 Free Software\n"\
99 "dnl @ Foundation, Inc.\n"\
100 "dnl @ This file is free software; the Free Software Foundation\n"\
101 "dnl @ gives unlimited permission to copy and/or distribute it\n"\
102 "dnl @ with or without modifications, as long as this notice\n"\
103 "dnl @ is preserved.\n", FILENAME, NR, status, options) > file;
105 printf("dnl @ expected output: %s\n", xout) > file;
107 printf("dnl @ expected error: %s\n", xerr) > file;
114 if ($0 ~ /^@end example$/) {
121 if ($0 ~ /^@result\{\}/ || $0 ~ /^@error\{\}/)
126 gsub("@[{]", "{", $0);
128 gsub("@w[{] }", " ", $0);
129 gsub("@tabchar[{]}", "\t", $0);
130 printf("%s%s\n", prefix, $0) >> file;