# Get rid of comments, including nested ones. Pretty it ain't. { if ($0 ~ /\(\*|\*\)/) { ct = 1; while (ct <= length) { start = index(substr($0,ct), "(*") if (start == 0) start = 10000 stop = index(substr($0,ct), "*)") if (stop == 0) stop = 10000 if (start < stop) { # start comment if (depth == 0) { print substr($0, ct, start-1) } ct += start+1; depth++ } else if (stop < start) { # end comment if (depth == 0) { print "BAD COMMENT", $0; exit } ct += stop+1; depth-- } else { # no comments left on line if (depth == 0) { print substr($0, ct) } next } } } else { if (depth == 0) print } }