forked from nuttx/nuttx-update
tools/indent.sh: Add a command line option to suppress reformatting of comments. This is useful when comments are already correct and/or contain formatted data such as tables or lists.
This commit is contained in:
parent
946b13559b
commit
759ed2d5c0
2 changed files with 33 additions and 16 deletions
|
@ -732,8 +732,8 @@ indent.sh
|
|||
(see below and the comments at the top of the indent.sh file).
|
||||
|
||||
USAGE:
|
||||
tools/indent.sh [-d] -o <out-file> <in-file>
|
||||
tools/indent.sh [-d] <in-file-list>
|
||||
tools/indent.sh [-d] [-p] -o <out-file> <in-file>
|
||||
tools/indent.sh [-d] [-p] <in-file-list>
|
||||
tools/indent.sh [-d] -h
|
||||
|
||||
Where:
|
||||
|
@ -746,22 +746,29 @@ indent.sh
|
|||
will not be modified.
|
||||
-d
|
||||
Enable script debug
|
||||
-p
|
||||
Comments are pre-formatted. Do not reformat.
|
||||
-h
|
||||
Show this help message and exit
|
||||
|
||||
The conversions make by the indent.sh script differs from the NuttX coding
|
||||
style in that:
|
||||
|
||||
1. I normally put the trailing */ of a multi-line comment on a separate
|
||||
line. If your C file already has properly formatted comments then
|
||||
using -nfca instead of -fca eliminates that bad behavior
|
||||
2. I usually align things vertically (like '=' in assignments),
|
||||
3. indent.sh puts a bogus blank line at the top of the file,
|
||||
4. I don't like the way it handles nested conditional compilation
|
||||
1. The coding standard requires that the trailing */ of a multi-line
|
||||
comment be on a separate line. By default, indent.sh will put the
|
||||
final */ on the same line as the last comment text. If your C file
|
||||
already has properly formatted comments then using the -p option will
|
||||
eliminate that bad behavior
|
||||
2. If your source file has highly formatted comments containing things
|
||||
such as tables or lists, then use the -p option to preserve those
|
||||
pre-formatted comments.
|
||||
3. I usually align things vertically (like '=' in assignments),
|
||||
4. indent.sh puts a bogus blank line at the top of the file,
|
||||
5. I don't like the way it handles nested conditional compilation
|
||||
intermixed with code. I prefer the preprocessor conditional tests
|
||||
be all right justified in that case.
|
||||
5. I also indent brackets differently on structures than does this script.
|
||||
6. I normally use no spaces in casts. indent.sh adds spaces in casts like
|
||||
6. I also indent brackets differently on structures than does this script.
|
||||
7. I normally use no spaces in casts. indent.sh adds spaces in casts like
|
||||
"(FAR void *)&foo" becomes "(FAR void *) & foo".
|
||||
7. When used with header files, the initial idempotence conditional test
|
||||
causes all preprocessor directives to be indented in the file. So for
|
||||
|
@ -769,7 +776,9 @@ indent.sh
|
|||
converted header file.
|
||||
|
||||
You will manually need to check for the issues listed above after
|
||||
performing the conversions.
|
||||
performing the conversions. nxstyle.c provides a good test that will
|
||||
catch most of the indent.sh screw-ups. Together, they do a pretty good
|
||||
job of formatting.
|
||||
|
||||
See also nxstyle.c and uncrustify.cfg
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
############################################################################
|
||||
# tools/indent.sh
|
||||
#
|
||||
# Copyright (C) 2008, 2010, 2016 Gregory Nutt. All rights reserved.
|
||||
# Copyright (C) 2008, 2010, 2016, 2019 Gregory Nutt. All rights reserved.
|
||||
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
|
@ -59,8 +59,6 @@
|
|||
|
||||
# Constants
|
||||
|
||||
options="-nbad -bap -bbb -nbbo -nbc -bl -bl2 -bls -nbs -cbi2 -ncdw -nce -ci2 -cli0 -cp40 -ncs -nbfda -nbfde -di1 -nfc1 -fca -i2 -l80 -lp -ppi2 -lps -npcs -pmt -nprs -npsl -saf -sai -sbi2 -saw -sc -sob -nss -nut"
|
||||
|
||||
advice="Try '$0 -h' for more information"
|
||||
|
||||
# Parse inputs
|
||||
|
@ -69,12 +67,16 @@ unset filelist
|
|||
unset outfile
|
||||
files=none
|
||||
mode=inplace
|
||||
fca=-fca
|
||||
|
||||
while [ ! -z "${1}" ]; do
|
||||
case ${1} in
|
||||
-d )
|
||||
set -x
|
||||
;;
|
||||
-p )
|
||||
fca=-nfca
|
||||
;;
|
||||
-o )
|
||||
shift
|
||||
outfile=${1}
|
||||
|
@ -84,8 +86,8 @@ while [ ! -z "${1}" ]; do
|
|||
echo "$0 is a tool for generation of proper version files for the NuttX build"
|
||||
echo ""
|
||||
echo "USAGE:"
|
||||
echo " $0 [-d] -o <out-file> <in-file>"
|
||||
echo " $0 [-d] <in-file-list>"
|
||||
echo " $0 [-d] [-p] -o <out-file> <in-file>"
|
||||
echo " $0 [-d] [-p] <in-file-list>"
|
||||
echo " $0 [-d] -h"
|
||||
echo ""
|
||||
echo "Where:"
|
||||
|
@ -98,6 +100,8 @@ while [ ! -z "${1}" ]; do
|
|||
echo " will not be modified."
|
||||
echo " -d"
|
||||
echo " Enable script debug"
|
||||
echo " -p"
|
||||
echo " Comments are pre-formatted. Do not reformat."
|
||||
echo " -h"
|
||||
echo " Show this help message and exit"
|
||||
exit 0
|
||||
|
@ -128,6 +132,10 @@ if [ "X${files}" == "Xnone" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Options
|
||||
|
||||
options="-nbad -bap -bbb -nbbo -nbc -bl -bl2 -bls -nbs -cbi2 -ncdw -nce -ci2 -cli0 -cp40 -ncs -nbfda -nbfde -di1 -nfc1 ${fca} -i2 -l80 -lp -ppi2 -lps -npcs -pmt -nprs -npsl -saf -sai -sbi2 -saw -sc -sob -nss -nut"
|
||||
|
||||
# Perform the indentation
|
||||
|
||||
if [ "X${mode}" == "Xcopy" ]; then
|
||||
|
|
Loading…
Reference in a new issue