#
# .M.i.r.o fixes invasion of slurs
# Usage: gawk -f StopSlurs.awk SlurInvasion.mscx > SlurInvasionContained.mscx
#
BEGIN {}
function getTag()
{
tag = gensub(/^ *<([a-zA-Z]+).*/,"\\1","g",$0)
t = $0
# ... may not be on the same line - read as many as needed
# also handle short versions
while ((index(t,"" tag ">") == 0) && (match(t,"<" tag "[^\n\r]*/> *$") == 0))
{
if (getline > 0)
t = t "\n" $0;
else
break;
}
return t
}
# -- PASS 1 - scan for valid slurs ----------------------------------------------------------------
# Create a list (array) of slurs which have been properly closed:
# Note that it scans the input file without changing the current position
(FNR == 1) {
while ((getline line < FILENAME) > 0)
if (match( line, /^ * 0) {
id = gensub( /^ *