Fix texinfo grammar.
[m4/ericb.git] / checks / get-them
blobe034962ceedd0498a8b1d311942bf73cc77de932
1 #!/bin/sh
2 # -*- AWK -*-
3 # Extract all examples from the manual source.
4 # Copyright (C) 1992, 2005, 2006, 2007 Free Software Foundation, Inc.
6 # This script is for use with GNU awk.
8 FILE=${1-/dev/null}
10 $AWK '
12 BEGIN {
13 node = "";
14 seq = -1;
15 count = 0;
16 file = "NONE";
17 status = 0;
18 options = "";
19 xout = "";
20 xerr = "";
23 /^@node / {
24 if (seq > 0)
25 printf(" -- %d file%s", seq, seq == 1 ? "" : "s");
26 if (seq >= 0)
27 printf("\n");
29 split($0, tmp, ",");
30 node = substr(tmp[1], 7);
31 if (length(node) > 10)
32 printf("Node: %s - truncated", node);
33 else
34 printf("Node: %s ", node);
35 gsub(" ", "_", node);
36 node = tolower(substr(node, 1, 10));
37 seq = 0;
40 /^@comment ignore$/ {
41 getline;
42 status = 0;
43 options = "";
44 xout = "";
45 xout = "";
46 next;
49 /^@comment status: / {
50 status = $3;
53 /^@comment options: / {
54 options = $0;
55 gsub ("@comment options:", "", options);
58 /^@comment xout: / {
59 xout = $0;
60 gsub ("@comment xout: ", "", xout);
63 /^@comment xerr: / {
64 xerr = $0;
65 gsub ("@comment xerr: ", "", xerr);
68 /^@example$/, /^@end example$/ {
69 if (seq < 0)
70 next;
71 if ($0 ~ /^@example$/) {
72 if (count > 0)
73 close (file);
74 seq++;
75 count++;
76 file = sprintf("%03d.%s", count, node);
77 printf("dnl @ %s:%d: Origin of test\n"\
78 "dnl @ expected status: %d\n"\
79 "dnl @ extra options: %s\n"\
80 "dnl @ Copyright (C) 2006, 2007 Free Software Foundation\n"\
81 "dnl @ This file is free software; the Free Software Foundation\n"\
82 "dnl @ gives unlimited permission to copy and/or distribute it\n"\
83 "dnl @ with or without modifications, as long as this notice\n"\
84 "dnl @ is preserved.\n", FILENAME, NR, status, options) > file;
85 if (xout)
86 printf("dnl @ expected output: %s\n", xout) > file;
87 if (xerr)
88 printf("dnl @ expected error: %s\n", xerr) > file;
89 status = 0;
90 options = "";
91 xout = "";
92 xerr = "";
93 next;
95 if ($0 ~ /^@end example$/) {
96 next;
98 if ($0 ~ /^\^D$/)
99 next;
100 if ($0 ~ /^\$ @kbd/)
101 next;
102 if ($0 ~ /^@result\{\}/ || $0 ~ /^@error\{\}/)
103 prefix = "dnl ";
104 else
105 prefix = "";
106 gsub("@@", "@", $0);
107 gsub("@{", "{", $0);
108 gsub("@}", "}", $0);
109 gsub("@w{ }", " ", $0);
110 gsub("@tabchar{}", "\t", $0);
111 printf("%s%s\n", prefix, $0) >> file;
114 END {
115 printf("\n");
117 ' $FILE