Reindented.
[platform/upstream/binutils.git] / gdb / gdb_indent.sh
1 #!/bin/sh
2
3 # Try to find a GNU indent.  There could be a BSD indent in front of a
4 # GNU gindent so when indent is found, keep looking.
5
6 gindent=
7 indent=
8 paths=`echo $PATH | sed \
9         -e 's/::/:.:/g' \
10         -e 's/^:/.:/' \
11         -e 's/:$/:./' \
12         -e 's/:/ /g'`
13 for path in $paths
14 do
15     if test ! -n "${gindent}" -a -x ${path}/gindent
16     then
17         gindent=${path}/gindent
18         break
19     elif test ! -n "${indent}" -a -x ${path}/indent
20     then
21         indent=${path}/indent
22     fi
23 done
24
25 if test -n "${gindent}"
26 then
27     indent=${gindent}
28 elif test -n "${indent}"
29 then
30     :
31 else
32     echo "Indent not found" 1>&2
33 fi
34
35
36 # Check that the indent found is both GNU and a reasonable version.
37 # Different indent versions give different indentation.
38
39 case `${indent} --version 2>/dev/null < /dev/null` in
40     GNU*2.2* ) ;;
41     *GNU* ) echo "Incorrect version of GNU indent" 1>&2 ;;
42     * ) echo "Indent is not GNU" 1>&2 ;;
43 esac
44
45
46 # Check that we're in the GDB source directory
47
48 case `pwd` in
49     */gdb ) ;;
50     */sim/* ) ;;
51     * ) echo "Not in GDB directory" 1>&2 ; exit 1 ;;
52 esac
53
54
55 # Run indent per GDB specs
56
57 types="\
58 -T FILE \
59 -T prgregset_t -T fpregset_t -T gregset_t \
60 `cat *.h | sed -n \
61     -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_ftype\).*$/-T \1/p' \
62     -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_func\).*$/-T \1/p' \
63     -e 's/^typedef.*[^a-zA-Z0-9_]\([a-zA-Z0-9_]*[a-zA-Z0-9_]\);$/-T \1/p' \
64     | sort -u`"
65
66 ${indent} ${types} "$@"