shithub: riscv

ref: f88a55e79b5bf656e7f9578d1318a955b9a4963a
dir: /sys/src/cmd/dtracy/lint.rc/

View raw version
#!/bin/rc
# check for full switch statements

nl='
'
nodetypes=`''{sed -n '/OINVAL/,/}/ s/,//p' dat.h | sed 's/[ 	]*//g; /^$/d' | sort | grep -v '^OINVAL$'}
switches=`$nl{grep -n '/\*nodetype\*/' *.[ch]}
for(l in $switches){
	f=`:{echo $l}
	a=`$nl{sed -n $f(2)^'s/[^ 	].*//p' $f(1)}
	comm -23 <{echo $nodetypes} <{sed -n $f(2)^',/^'^$a^'}/ s/^'^$a^'case ([^:]*):.*/\1/p' $f(1) | sort} | sed -n 's/.+/'^$f(1)^':'^$f(2)^' missing &/p'
}

oper=`''{sed -n '/OPINVAL/,/}/ s/,//p' dat.h | sed 's/[ 	]*//g; /^$/d' | sort | grep -v '^OPINVAL$'}
switches=`$nl{grep -n '/\*oper\*/' *.[ch]}
for(l in $switches){
	f=`:{echo $l}
	a=`$nl{sed -n $f(2)^'s/[^ 	].*//p' $f(1)}
	comm -23 <{echo $oper} <{sed -n $f(2)^',/^'^$a^'}/ s/^'^$a^'case ([^:]*):.*/\1/p' $f(1) | sort} | sed -n 's/.+/'^$f(1)^':'^$f(2)^' missing &/p'
}