modified: src1/input.c
[GalaxyCodeBases.git] / c_cpp / etc / calc / check.awk
blobf637efa6ba7434c8f079fbe43052c912ece01e74
1 #!/usr/bin/awk
3 # check - check the regression output for problems
5 # Copyright (C) 1999-2006 Landon Curt Noll
7 # Calc is open software; you can redistribute it and/or modify it under
8 # the terms of the version 2.1 of the GNU Lesser General Public License
9 # as published by the Free Software Foundation.
11 # Calc is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
14 # Public License for more details.
16 # A copy of version 2.1 of the GNU Lesser General Public License is
17 # distributed with calc under the filename COPYING-LGPL. You should have
18 # received a copy with calc; if not, write to Free Software Foundation, Inc.
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 # @(#) $Revision: 30.2 $
22 # @(#) $Id: check.awk,v 30.2 2013/08/11 01:08:32 chongo Exp $
23 # @(#) $Source: /usr/local/src/cmd/calc/RCS/check.awk,v $
25 # Under source code control: 1996/05/25 22:07:58
26 # File existed as early as: 1996
28 # chongo <was here> /\oo/\ http://www.isthe.com/chongo/
29 # Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
31 # This awk script will print 3 lines before and after any non-blank line that
32 # does not begin with a number. This allows the 'make debug' rule to remove
33 # all non-interest lines the 'make check' regression output while providing
34 # 3 lines of context around unexpected output.
36 BEGIN {
37 havebuf0=0;
38 buf0=0;
39 havebuf1=0;
40 buf1=0;
41 havebuf2=0;
42 buf2=0;
43 error = 0;
44 end_seen = 0;
47 NF == 0 {
48 if (error > 0) {
49 if (havebuf2) {
50 print buf2;
52 --error;
54 buf2 = buf1;
55 havebuf2 = havebuf1;
56 buf1 = buf0;
57 havebuf1 = havebuf0;
58 buf0 = $0;
59 havebuf0 = 1;
60 next;
63 /: Ending regression tests$/ {
64 end_seen = 1;
67 $1 ~ /^[0-9]+:/ || $1 ~ /^[0-9]+-[0-9]*:/ || $1 ~ /^"\)\)$/ {
68 if (error > 0) {
69 if (havebuf2) {
70 print buf2;
72 --error;
74 buf2 = buf1;
75 havebuf2 = havebuf1;
76 buf1 = buf0;
77 havebuf1 = havebuf0;
78 buf0 = $0;
79 havebuf0 = 1;
80 next;
84 error = 6;
85 if (havebuf2) {
86 print buf2;
88 buf2 = buf1;
89 havebuf2 = havebuf1;
90 buf1 = buf0;
91 havebuf1 = havebuf0;
92 buf0 = $0;
93 havebuf0 = 1;
94 next;
97 END {
98 if (error > 0 && havebuf2) {
99 print buf2;
100 --error;
102 if (error > 0 && havebuf1) {
103 print buf1;
104 --error;
106 if (error > 0 && havebuf0) {
107 print buf0;
109 if (error > 0 || !end_seen) {
110 exit(1);
111 } else {
112 exit(0);