3 # This little script parse a list of C files, and extract the TRY blocks of it.
4 # Martin Quinson, 2006.
5 # Demerdierensiesich licence.
7 # It can reveal usefull when you have a segfault on exception throwing. This
8 # is often the symptom that something somewhere got out of a TRY block with
9 # return, goto, break or such. This is forbiden because some extra cleanups
10 # must be performed at the end of the block.
12 # So, if it happens to you, you may find this script usefull: let it extract
13 # all the TRY blocks of your project, and grep for the forbidden keywords
16 # You obviously have to adapt it to your case. The proper solution would be
17 # to accept the extra -I pathes from the command line.
20 for file in `find -name '*.c'` ; do
24 | cpp -I/home/mquinson/CVSIMPORT/gras/gras/include \
25 -I/home/mquinson/CVSIMPORT/gras/gras/src \
26 -I/home/mquinson/CVSIMPORT/gras/gras/src/include \
28 -D__XBT_EX_H__ -D_XBT_LOG_H_ \
29 | sed -n -e '/TRY/,/CATCH/p' \
30 | sed -e 's/^.*TRY.*$/----------------/' -e '/CATCH/d'"
32 err=`eval $cmd 2>&1 >/dev/null`
33 if [ -n "$err" ] ; then
34 echo "XXXXXXXXXX ERROR IN FILE $file"
38 if [ -n "`eval $cmd 2>/dev/null`" ] ; then
40 eval "$cmd" 2>/dev/null