2001-11-09 05:00:00 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Try to find a GNU indent. There could be a BSD indent in front of a
|
|
|
|
# GNU gindent so when indent is found, keep looking.
|
|
|
|
|
|
|
|
gindent=
|
|
|
|
indent=
|
|
|
|
paths=`echo $PATH | sed \
|
|
|
|
-e 's/::/:.:/g' \
|
|
|
|
-e 's/^:/.:/' \
|
|
|
|
-e 's/:$/:./' \
|
|
|
|
-e 's/:/ /g'`
|
|
|
|
for path in $paths
|
|
|
|
do
|
|
|
|
if test ! -n "${gindent}" -a -x ${path}/gindent
|
|
|
|
then
|
|
|
|
gindent=${path}/gindent
|
|
|
|
break
|
|
|
|
elif test ! -n "${indent}" -a -x ${path}/indent
|
|
|
|
then
|
|
|
|
indent=${path}/indent
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if test -n "${gindent}"
|
|
|
|
then
|
|
|
|
indent=${gindent}
|
|
|
|
elif test -n "${indent}"
|
|
|
|
then
|
|
|
|
:
|
|
|
|
else
|
|
|
|
echo "Indent not found" 1>&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Check that the indent found is both GNU and a reasonable version.
|
|
|
|
# Different indent versions give different indentation.
|
|
|
|
|
2003-01-14 00:07:07 +01:00
|
|
|
m1=2
|
|
|
|
m2=2
|
|
|
|
m3=9
|
|
|
|
|
|
|
|
version=`${indent} --version 2>/dev/null < /dev/null`
|
|
|
|
case "${version}" in
|
|
|
|
*GNU* ) ;;
|
|
|
|
* ) echo "error: GNU indent $m1.$m2.$m3 expected" 1>&2 ; exit 1;;
|
2001-11-09 05:00:00 +01:00
|
|
|
esac
|
2003-01-14 00:07:07 +01:00
|
|
|
v1=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\1/'`
|
|
|
|
v2=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\2/'`
|
|
|
|
v3=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\3/'`
|
|
|
|
|
|
|
|
if test $m1 -ne $v1 -o $m2 -ne $v2 -o $m3 -gt $v3
|
|
|
|
then
|
|
|
|
echo "error: Must be GNU indent version $m1.$m2.$m3 or later" 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
2001-11-09 05:00:00 +01:00
|
|
|
|
2003-01-14 00:07:07 +01:00
|
|
|
if test $m3 -ne $v3
|
|
|
|
then
|
|
|
|
echo "warning: GNU indent version $m1.$m2.$m3 recommended" 1>&2
|
|
|
|
fi
|
2001-11-09 05:00:00 +01:00
|
|
|
|
|
|
|
# Check that we're in the GDB source directory
|
|
|
|
|
|
|
|
case `pwd` in
|
|
|
|
*/gdb ) ;;
|
2002-05-18 21:50:20 +02:00
|
|
|
*/sim/* ) ;;
|
2001-11-09 05:00:00 +01:00
|
|
|
* ) echo "Not in GDB directory" 1>&2 ; exit 1 ;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
# Run indent per GDB specs
|
|
|
|
|
2002-06-17 21:56:15 +02:00
|
|
|
types="\
|
|
|
|
-T FILE \
|
2003-04-11 22:56:40 +02:00
|
|
|
-T bfd -T asection -T pid_t \
|
|
|
|
-T prgregset_t -T fpregset_t -T gregset_t -T sigset_t \
|
2003-04-17 19:18:49 +02:00
|
|
|
-T td_thrhandle_t -T td_event_msg_t -T td_thr_events_t \
|
|
|
|
-T td_notify_t -T td_thr_iter_f -T td_thrinfo_t \
|
2002-06-17 21:56:15 +02:00
|
|
|
`cat *.h | sed -n \
|
2001-11-09 05:00:00 +01:00
|
|
|
-e 's/^.*[^a-z0-9_]\([a-z0-9_]*_ftype\).*$/-T \1/p' \
|
|
|
|
-e 's/^.*[^a-z0-9_]\([a-z0-9_]*_func\).*$/-T \1/p' \
|
|
|
|
-e 's/^typedef.*[^a-zA-Z0-9_]\([a-zA-Z0-9_]*[a-zA-Z0-9_]\);$/-T \1/p' \
|
|
|
|
| sort -u`"
|
|
|
|
|
|
|
|
${indent} ${types} "$@"
|