* ChangeLog: Add copyright.
[m4/ericb.git] / checks / get-them
blob5521b34dda5e7fbf7dccf81a64d0a0163f0a2828
1 #!/bin/sh
2 # Extract all examples from the manual source.
3 # Copyright (C) 1992, 2005, 2006 Free Software Foundation, Inc.
5 # This script is for use with GNU awk.
7 FILE=${1-/dev/null}
9 $AWK '
11 BEGIN {
12 node = "";
13 seq = -1;
14 count = 0;
15 file = "NONE";
18 /^@node / {
19 if (seq > 0)
20 printf(" -- %d file%s", seq, seq == 1 ? "" : "s");
21 if (seq >= 0)
22 printf("\n");
24 split($0, tmp, ",");
25 node = substr(tmp[1], 7);
26 if (length(node) > 10)
27 printf("Node: %s - truncated", node);
28 else
29 printf("Node: %s ", node);
30 gsub(" ", "_", node);
31 node = tolower(substr(node, 1, 10));
32 seq = 0;
35 /^@comment ignore$/ {
36 getline;
37 next;
40 /^@example$/, /^@end example$/ {
41 if (seq < 0)
42 next;
43 if ($0 ~ /^@example$/) {
44 if (count > 0)
45 close (file);
46 seq++;
47 count++;
48 file = sprintf("%03d.%s", count, node);
49 printf("dnl @ %s:%d: Origin of test\n"\
50 "dnl @ Copyright (C) 2006 Free Software Foundation\n"\
51 "dnl @ This file is free software; the Free Software Foundation\n"\
52 "dnl @ gives unlimited permission to copy and/or distribute it\n"\
53 "dnl @ with or without modifications, as long as this notice\n"\
54 "dnl @ is preserved.\n", FILENAME, NR) > file;
55 next;
57 if ($0 ~ /^@end example$/) {
58 next;
60 if ($0 ~ /^\^D$/)
61 next;
62 if ($0 ~ /^@result\{\}/ || $0 ~ /^@error\{\}/)
63 prefix = "dnl ";
64 else
65 prefix = "";
66 gsub("@@", "@", $0);
67 gsub("@comment.*", "", $0);
68 gsub("@tabchar{}", "\t", $0);
69 printf("%s%s\n", prefix, $0) >> file;
72 END {
73 printf("\n");
75 ' $FILE