summaryrefslogtreecommitdiff
path: root/nuttx/tools
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-03-26 08:50:48 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-03-26 08:50:48 -0600
commite94c449aa58daaf3109e4b54f2d542c1cf2191e7 (patch)
tree735a0b35db6449a4c47d8cb9c6e604b2f521ad00 /nuttx/tools
parent3c38cd7d842a1b9e7ef8f4f409f162bad86d1acb (diff)
downloadpx4-nuttx-e94c449aa58daaf3109e4b54f2d542c1cf2191e7.tar.gz
px4-nuttx-e94c449aa58daaf3109e4b54f2d542c1cf2191e7.tar.bz2
px4-nuttx-e94c449aa58daaf3109e4b54f2d542c1cf2191e7.zip
tools/astyle.sh: Formatting tool based on logic from Lorenz Meier
Diffstat (limited to 'nuttx/tools')
-rw-r--r--nuttx/tools/README.txt8
-rwxr-xr-xnuttx/tools/astyle.sh43
-rwxr-xr-xnuttx/tools/indent.sh2
3 files changed, 52 insertions, 1 deletions
diff --git a/nuttx/tools/README.txt b/nuttx/tools/README.txt
index a1bf40b60..f0feff661 100644
--- a/nuttx/tools/README.txt
+++ b/nuttx/tools/README.txt
@@ -12,6 +12,12 @@ README.txt
This file!
+astyle.sh
+---------
+
+ A C formatting tool from Lorenz Meier. This is based on astyle and gets
+ very close to the NuttX coding style.
+
Config.mk
---------
@@ -528,6 +534,8 @@ indent.sh
to my coding NuttX coding style. It doesn't do a really good job,
however (see the comments at the top of the indent.sh file).
+ See astyle.sh above. I suspect that it will do a better job.
+
zipme.sh
--------
diff --git a/nuttx/tools/astyle.sh b/nuttx/tools/astyle.sh
new file mode 100755
index 000000000..9b5cc0c0f
--- /dev/null
+++ b/nuttx/tools/astyle.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+############################################################################
+# tools/astyle.sh
+#
+# Copyright (C) 2014 Gregory Nutt. All rights reserved.
+# Author: Lorenz Meier
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in
+# the documentation and/or other materials provided with the
+# distribution.
+# 3. Neither the name NuttX nor the names of its contributors may be
+# used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+# POSSIBILITY OF SUCH DAMAGE.
+#
+############################################################################
+
+astyle \
+ --style=gnu \
+ --indent=spaces=2 \
+ --indent-cases \
+ --indent-switches \
+ $*
+
diff --git a/nuttx/tools/indent.sh b/nuttx/tools/indent.sh
index 4ebae9652..866430e7e 100755
--- a/nuttx/tools/indent.sh
+++ b/nuttx/tools/indent.sh
@@ -41,7 +41,7 @@
# - I usually align things vertically (like '=' in assignments),
# - indent puts a bogus blank line at the top of the file,
# - I don't like the way it handles nested conditional compilation intermixed with code.
-# - I also indent brackets differently on structures than does not script.
+# - I also indent brackets differently on structures than does this script.
#
# Constants