File: gdb_indent.sh

package info (click to toggle)
gdb 7.12-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 216,152 kB
  • ctags: 304,881
  • sloc: ansic: 2,141,328; asm: 331,662; exp: 133,348; makefile: 57,698; sh: 23,586; yacc: 14,054; cpp: 12,262; perl: 5,300; python: 4,685; ada: 4,343; xml: 3,670; pascal: 3,120; lisp: 1,516; cs: 879; lex: 624; f90: 457; sed: 228; awk: 142; objc: 134; java: 73; fortran: 43
file content (92 lines) | stat: -rwxr-xr-x 2,156 bytes parent folder | download | duplicates (31)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/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.

# Make certain that the script is not running in an internationalized
# environment.
LANG=c ; export LANG
LC_ALL=c ; export LC_ALL

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.

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;;
esac
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

if test $m3 -ne $v3
then
    echo "warning: GNU indent version $m1.$m2.$m3 recommended" 1>&2
fi

# Check that we're in the GDB source directory

case `pwd` in
    */gdb ) ;;
    */sim/* ) ;;
    * ) echo "Not in GDB directory" 1>&2 ; exit 1 ;;
esac


# Run indent per GDB specs

types="\
-T FILE \
-T bfd -T asection -T pid_t \
-T prgregset_t -T fpregset_t -T gregset_t -T sigset_t \
-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 \
-T caddr_t \
`cat *.h | sed -n \
    -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} "$@"