Skip to content

Commit

Permalink
#419 added checks and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cpantel committed Jun 27, 2016
1 parent 0c534df commit 32da77b
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 14 deletions.
26 changes: 26 additions & 0 deletions modules/tools/scripts/check_crlf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# remove this line when the generator gets stable
#
# exclude-dir="out" \
#
# keep synchronized with fixer

CRLF=$( egrep --recursive --files-with-matches "^" \
--include="*.c" \
--include="*.C" \
--include="*.h" \
--include="*.H" \
--include="*.php" \
--include="Makefile*" \
--include="*.sh" \
--exclude-dir="externals" \
--exclude-dir="out" \
--exclude-dir="\.git" \
* )

if [ "$CRLF" ] ; then
echo "FAIL, there are files with DOS EOL (CRLF)"
echo "$CRLF"
else
echo "EOL OK"
fi

Expand Down
44 changes: 44 additions & 0 deletions modules/tools/scripts/check_indentation.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# remove this line when the generator gets stable
#
# exclude-dir="out" \
#
INDENT=$( egrep --with-filename --line-number --recursive \
-ve "^( {3})+" \
-ve "^$" \
-ve "^[a-zA-Z0-9]+" \
-ve "^[_-#}{?<\$\.]+" \
-ve "^ *\*" \
-ve "^ */" \
--include="*.c" \
--include="*.C" \
--include="*.h" \
--include="*.H" \
--include="*.php" \
--include="*.sh" \
--exclude-dir="externals" \
--exclude-dir="out" \
--exclude-dir="\.git" \
* )


INDENT=${INDENT}$( egrep --with-filename --line-number --recursive \
-e "^ + " \
-e "^ " \
--include="*.c" \
--include="*.C" \
--include="*.h" \
--include="*.H" \
--include="*.php" \
--include="*.sh" \
--exclude-dir="externals" \
--exclude-dir="out" \
--exclude-dir="\.git" \
* )

if [ "$INDENT" ] ; then
echo "There is bad indentation"
echo "$INDENT"
exit 1
else
echo "Indentation OK"
fi
28 changes: 14 additions & 14 deletions modules/tools/scripts/check_trailing_spaces.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# remove this line when the generator gets stable
#
# -and -not -wholename "./out/*" \
# exclude-dir="out" \
#
# keep synchronized with fixer

TRAILING=$(find . -type f \
-and -not -wholename "./out/*" \
-and -not -wholename "./.git*" \
-and -not -wholename "./externals*" \
-and -not -name "*.png" \
-and -not -name "*~" \
-and -not -name "*.zargo" \
-and -not -name "*.axf" \
-and -not -name "*.o" \
-and -not -name "*.exe" \
-and -not -name "*.a" \
-and -not -name "*.swp" \
-exec egrep -n -H " +$" {} \;)
TRAILING=$( egrep --with-filename --line-number --recursive " +$" \
--include="*.c" \
--include="*.C" \
--include="*.h" \
--include="*.H" \
--include="*.php" \
--include="Makefile*" \
--include="*.sh" \
--exclude-dir="externals" \
--exclude-dir="out" \
--exclude-dir="\.git" \
* )

if [ "$TRAILING" ] ; then
echo "FAIL, there are trailing spaces"
Expand Down
28 changes: 28 additions & 0 deletions modules/tools/scripts/fix_crlf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# remove this line when the generator gets stable
#
# exclude-dir="out" \
#
# keep synchronized with checker

CRLF=$( egrep --recursive --files-with-matches "^" \
--include="*.c" \
--include="*.C" \
--include="*.h" \
--include="*.H" \
--include="*.php" \
--include="Makefile*" \
--include="*.sh" \
--exclude-dir="externals" \
--exclude-dir="out" \
--exclude-dir="\.git" \
* )

if [ "$CRLF" ] ; then
for FILE in $CRLF; do
echo "Fixing DOS EOL (CRLF): $FILE"
dos2unix "$FILE"
done
else
echo "EOL OK"
fi

Expand Down
27 changes: 27 additions & 0 deletions modules/tools/scripts/fix_trailing_spaces.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# remove this line when the generator gets stable
#
# exclude-dir="out" \
#
# keep synchronized with checker

TRAILING=$( egrep --files-with-matches --recursive " +$" \
--include="*.c" \
--include="*.C" \
--include="*.h" \
--include="*.H" \
--include="*.php" \
--include="Makefile*" \
--include="*.sh" \
--exclude-dir="externals" \
--exclude-dir="out" \
--exclude-dir="\.git" \
* )

if [ "$TRAILING" ] ; then
for FILE in $TRAILING; do
echo "Fixing trailing spaces: $FILE"
sed -i -e 's/ *$//' "$FILE"
done
else
echo "Trailing spaces OK"
fi

0 comments on commit 32da77b

Please sign in to comment.