summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/grep/tests/formatere.awk
blob: ba60439a18946ff0c9a9c4c8f34eaca768bef15d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#
# Extended Regular Expression

# skip comments
$0 ~ /^#/ { next; }

# skip specifics to regcomp/regexec
$2 ~ /[msnr$#p^]/ { next; }

# jump empty lines
$0 ~ /^$/ { next; }

# subreg skip
NF >= 5 { next; }

# debug
#{ printf ("<%s> <%s> <%s> <%s>\n", $1, $2, $3, $4); }

# errors
NF == 3 {
# nuke any remaining '@'
#	gsub (/@/, ",");
# it means empty lines
	gsub (/\"\"/, "");
# escapes
	gsub (/\\\'/, "\\\'\'");
# error in regex 
	if (index ($2, "C") != 0)
	{
		if (index ($2, "b") == 0)
			printf ("2@%s@%s\n", $1, $3);
	}
# error not matching 
	else
	{
		if (index ($2, "b") == 0)
			printf ("1@%s@%s\n", $1, $3);
	}
	next;
}

# ok
NF == 4 {
# skip those magic cookies can't rely on echo to gnerate them
	if (match($3, /[NSTZ]/))
		next;

# nuke any remaining '@'
#	gsub (/@/, ",");
# it means empty lines
	gsub (/\"\"/, "");
# escape escapes
	gsub (/\\\'/, "\\\'\'");

	if (index ($2, "b") == 0)
	{
		printf ("0@%s@%s\n", $1, $3);
	}
	next;
}
OpenPOWER on IntegriCloud