#! /usr/bin/gawk -f # Last edited on 2022-07-24 11:38:33 by stolfi BEGIN { debug = 0; # Should it print debugging state? if (do_filter == "") { do_filter = 1; } else { do_filter += 0; } # 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; } } # Headers of sections entirely of garbage lines: /^Persistence of Vision[(]tm[)]/ { state = 1; next; } /^This is an unofficial version compiled by/ { state = 1; next; } /^Primary POV-Ray/ { state = 1; next; } /^With Assistance From:/ { state = 1; next; } /^Past Contributors:/ { state = 1; next; } /^Support libraries used/ { state = 1; next; } /^Render Options/ { state = 1; next } /^Render Time:/ { state = 1; next } /^Parser Options/ { state = 1; next; } /^Output Options/ { state = 1; next; } /^Image Output Options/ { state = 1; next; } /^Information Output Options/ { state = 1; next; } /^Total Scene Processing Times/ { state = 1; next; } /^ *Ray->Shape Intersection/ { state = 1; next } /^Parser Statistics/ { state = 1; next } /^Parser Time/ { state = 1; next } /^Render Options/ { state = 1; next } /^Render Statistics/ { state = 1; next } /^Render Time:/ { 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; } # Separator and blank lines do not affect state: /^[-][-][-]-*$/ { next; } /^[ \011]*$/ { next; } # Single garbage lines that end garbage sections: /^POV-Ray is based on/ { state = 0; next; } /^Copyright [-0-9]+/ { state = 0; next; } /^Other contributors are/ { state = 0; next; } /^ *Rendered/ { state = 0; next } # Garbage lines that may be followed by important info or error messages: /^[ =]*\[Parsing...\][ =]*$/ { state = 0; next } /^[ =]*\[Rendering...\][ =]*$/ { state = 0; next } # Delete known garbage lines: # /^Finite Objects:/ { state = 0; next } # /^Infinite Objects:/ { state = 0; next } # /^Light Sources:/ { state = 0; next } # /^Total:/ { state = 0; next } # /^Parser Time/ { state = 0; next } # /^ *Parse Time:/ { state = 0; next } # /^ *using [0-9]+ thread/ { state = 0; next } # /^ *Bounding Time:/ { state = 0; next } # /^ *Quality:/ { state = 0; next } # /^ *Bounding boxes/ { state = 0; next } # /^ *Antialiasing/ { state = 0; next } # /^ *Gamma/ { state = 0; next } # /^ *Render Statistics/ { state = 0; next } # /^ *Image Resolution/ { state = 0; next } # /^ *Pixels:/ { state = 0; next } # /^ *Rays:/ { state = 0; next } # /^ *Shadow Ray Tests:/ { state = 0; next } # /^ *Shadow Cache Hits:/ { state = 0; 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; }