aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Cagney <cagney@redhat.com>2001-11-09 04:00:00 +0000
committerAndrew Cagney <cagney@redhat.com>2001-11-09 04:00:00 +0000
commitf6a9480ec1bae59eeacb9c52f5fcf11032ff3594 (patch)
tree7688163cf5972a8148bf6912c6675e57173829e8
parent922b248500147ff26d37f987ec8c7ac9057edee6 (diff)
downloadgdb-f6a9480ec1bae59eeacb9c52f5fcf11032ff3594.zip
gdb-f6a9480ec1bae59eeacb9c52f5fcf11032ff3594.tar.gz
gdb-f6a9480ec1bae59eeacb9c52f5fcf11032ff3594.tar.bz2
A simple script to indent GDB source code.
-rw-r--r--gdb/ChangeLog4
-rwxr-xr-xgdb/gdb_indent.sh62
2 files changed, 66 insertions, 0 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7a54716..b714e78 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@
+2001-11-08 Andrew Cagney <ac131313@redhat.com>
+
+ * gdb_indent.sh: New file.
+
2001-11-08 Jim Blandy <jimb@redhat.com>
* s390-tdep.c (s390_get_frame_info): Initialize got_load_addr and
diff --git a/gdb/gdb_indent.sh b/gdb/gdb_indent.sh
new file mode 100755
index 0000000..e54e08e
--- /dev/null
+++ b/gdb/gdb_indent.sh
@@ -0,0 +1,62 @@
+#!/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.
+
+case `${indent} --version 2>/dev/null < /dev/null` in
+ GNU*2.2.6 ) ;;
+ *GNU* ) echo "Incorrect version of GNU indent" 1>&2 ;;
+ * ) echo "Indent is not GNU" 1>&2 ;;
+esac
+
+
+# Check that we're in the GDB source directory
+
+case `pwd` in
+ */gdb ) ;;
+ * ) echo "Not in GDB directory" 1>&2 ; exit 1 ;;
+esac
+
+
+# Run indent per GDB specs
+
+types="-T FILE `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} "$@"