This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[rfc] gdb_indent.sh ....


Hello,

To recap some history:

1999-07-07  Stan Shebs  <shebs@andros.cygnus.com>

         * All C files except *-stub.c and *-share/*: Indent to GNU
         standard, using indent 1.9.1.
         * defs.h: Make indent ignore this file, macros confuse it.

         * gnu-regex.c, gnu-regex.h: Don't let indent mess with these.

Back in '99 it was decided that the GDB's code's indentation had got to 
the point where it was so bad that we should just re-indent everything. 
  From that point on GDB's indentation style could be defined by 
indent's output.

As usual, there were teething problems :-)

	o	indent 1.9.1 indented structs and enums
		as:

			struct foo
			  {
			    int a;
			  };

		while Emacs and GNU indent 2.2.6 use:

			struct foo
			{
			  int a;
			};

		The GNU coding standard (once I've got around
		to submitting the approved in principal patch)
		allows both styles however suggests the second
		since that is consistent with current indent
		and Emacs.

	o	Everyone forgot about typedefs.  As consequence
		indent would output:

			foo (FILE * f);

		instead of:

			foo (FILE *f);

and as a consequence the rule was loosened to ``based on the output of 
GNU indent''.  The original decision, however, was definitly a good move 
- the code style really was that bad!

Since then it has been suggested the above problems can be addressed by 
wrapping indent in a script.  See attached.  GDB's indentation style 
would be based on the output of gdb_indent.sh.

As for re-indenting everything again, er probably not.  However don't be 
suprised if people do run gdb_indent.sh over a file and check in the 
result before making mechanical changes to code cf value_ptr patch I'm 
about to post.

thoughts, objections, howls of pain,
Andrew
2001-10-31  Andrew Cagney  <ac131313@redhat.com>

	* gdb_indent.sh: New file.

Index: gdb_indent.sh
===================================================================
RCS file: gdb_indent.sh
diff -N gdb_indent.sh
*** /dev/null	Tue May  5 13:32:27 1998
--- gdb_indent.sh	Wed Oct 31 17:35:15 2001
***************
*** 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} "$@"

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]