]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - gnu/usr.bin/grep/tests/formatere.awk
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / gnu / usr.bin / grep / tests / formatere.awk
1 #
2 # Extended Regular Expression
3
4 # skip comments
5 $0 ~ /^#/ { next; }
6
7 # skip specifics to regcomp/regexec
8 $2 ~ /[msnr$#p^]/ { next; }
9
10 # jump empty lines
11 $0 ~ /^$/ { next; }
12
13 # subreg skip
14 NF >= 5 { next; }
15
16 # debug
17 #{ printf ("<%s> <%s> <%s> <%s>\n", $1, $2, $3, $4); }
18
19 # errors
20 NF == 3 {
21 # nuke any remaining '@'
22 #       gsub (/@/, ",");
23 # it means empty lines
24         gsub (/\"\"/, "");
25 # escapes
26         gsub (/\\\'/, "\\\'\'");
27 # error in regex 
28         if (index ($2, "C") != 0)
29         {
30                 if (index ($2, "b") == 0)
31                         printf ("2@%s@%s\n", $1, $3);
32         }
33 # error not matching 
34         else
35         {
36                 if (index ($2, "b") == 0)
37                         printf ("1@%s@%s\n", $1, $3);
38         }
39         next;
40 }
41
42 # ok
43 NF == 4 {
44 # skip those magic cookies can't rely on echo to gnerate them
45         if (match($3, /[NSTZ]/))
46                 next;
47
48 # nuke any remaining '@'
49 #       gsub (/@/, ",");
50 # it means empty lines
51         gsub (/\"\"/, "");
52 # escape escapes
53         gsub (/\\\'/, "\\\'\'");
54
55         if (index ($2, "b") == 0)
56         {
57                 printf ("0@%s@%s\n", $1, $3);
58         }
59         next;
60 }