-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpovray-output-filter.gawk
executable file
·79 lines (66 loc) · 1.71 KB
/
povray-output-filter.gawk
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#! /usr/bin/gawk -f
# Last edited on 2017-07-10 19:33:57 by stolfilocal
BEGIN {
debug = 0; # Should it print debugging state?
do_filter = 1; # Should it apply the filter?
state = 0;
# If 0, just copying stream.
# If 1, deleting irrelevant output.
# If 2, collecting continuation lines of error message text {emess}.
if (debug != 0) { printf "@@ state = %d --starting--\n", state > "/dev/stderr"; }
}
(do_filter == 0){
# Pass everything through:
print;
next;
}
(debug != 0){
printf "@@ state = %d %s\n", state, $0 > "/dev/stderr";
}
/^[!][!]/ {
# Debug message line:
print;
next;
}
/^[ ]/ {
# Possible continuation line:
if (state == 2) { emess = (emess $0); next; }
}
// {
# Not a continuation line. If gathering error message, dump it:
if (state == 2) {
if ($0 ~ /^[ ]/) { prog_error(("boh?")); }
printf "%s:%s: ** %s\n", efile, eline, emess > "/dev/stderr";
state = 0;
}
}
/^Persistence of Vision[(]tm[)]/ { state = 1; next; }
/^Output Options/ { state = 0; }
/^Total Scene Processing Times/ { state = 1; next; }
/^File[ ]+[']*[^' ]+['][ ]+line */ {
# Preamble of context lines and error message:
efile=$2; gsub(/[']/, "", efile);
eline=$4; gsub(/[:]/, "", eline);
if (! match($0, /[:]/)) { prog_error(("no colon")); }
emess = substr($0, RSTART+1); gsub(/^[ ]+/, "", emess);
state = 2;
next;
}
(state == 0) {
# Generic random line:
print > "/dev/stderr";
next;
}
(state == 1) {
# Undesired noise line:
next;
}
(state == 2) {
# Should have been handled before:
prog_error(("boh?"));
}
function prog_error(msg){
printf "!! povray-output-filter: bug at output line %d - %s\n", FNR, msg > "/dev/stderr";
print > "/dev/stderr";
next;
}