#!/bin/gawk -f

BEGIN {
		skipnext = 0
}

skipnext == 1 { skipnext = 0; next; }

/^[ \t]*alias[ \t]+sound/ {
		sounddevice = $3
		skipnext = 1
		next
}

/^[ \t]*alias[ \t]+midi/ {
		mididevice = $3
		next
}

/^[ \t]*pre-install/ || /^[ \t]*post-install/ || /^[ \t]*install/ {
		if ($2 != sounddevice && $2 != mididevice)
			print $0
		next
}

/^[ \t]*pre-remove/ || /^[ \t]*remove/ || /^[ \t]*post-remove/ {
		if ($2 != sounddevice && $2 != mididevice)
			print $0
		next
}

/^[ \t]*options/ {
		if ($2 != sounddevice && $2 != mididevice) 
			print $0
		next
}

{  
		# default pattern
		print $0
}

END {
}
