* gdb_indent.sh: Allow the script to be run in the sim directory.
[deliverable/binutils-gdb.git] / gdb / gdb_indent.sh
CommitLineData
f6a9480e
AC
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
6gindent=
7indent=
8paths=`echo $PATH | sed \
9 -e 's/::/:.:/g' \
10 -e 's/^:/.:/' \
11 -e 's/:$/:./' \
12 -e 's/:/ /g'`
13for path in $paths
14do
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
23done
24
25if test -n "${gindent}"
26then
27 indent=${gindent}
28elif test -n "${indent}"
29then
30 :
31else
32 echo "Indent not found" 1>&2
33fi
34
35
36# Check that the indent found is both GNU and a reasonable version.
37# Different indent versions give different indentation.
38
39case `${indent} --version 2>/dev/null < /dev/null` in
40 GNU*2.2.6 ) ;;
41 *GNU* ) echo "Incorrect version of GNU indent" 1>&2 ;;
42 * ) echo "Indent is not GNU" 1>&2 ;;
43esac
44
45
46# Check that we're in the GDB source directory
47
48case `pwd` in
49 */gdb ) ;;
8efe637d 50 */sim/* ) ;;
f6a9480e
AC
51 * ) echo "Not in GDB directory" 1>&2 ; exit 1 ;;
52esac
53
54
55# Run indent per GDB specs
56
57types="-T FILE `cat *.h | sed -n \
58 -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_ftype\).*$/-T \1/p' \
59 -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_func\).*$/-T \1/p' \
60 -e 's/^typedef.*[^a-zA-Z0-9_]\([a-zA-Z0-9_]*[a-zA-Z0-9_]\);$/-T \1/p' \
61 | sort -u`"
62
63${indent} ${types} "$@"
This page took 0.067556 seconds and 4 git commands to generate.