add test for json_mhd.c logic
[oweals/gnunet.git] / pre-commit
index da86ca59cc4c971e85cf1f40becabc6c699dd096..c67fcaf0c65393ccdb385e786147fe28a240a1ed 100755 (executable)
@@ -1,8 +1,22 @@
 #!/bin/sh
-find src/ -name "*.c" -exec indent {} \;
-find src/ -name "*.h" -exec indent {} \;
-if test -x "`which 'dos2unix'`"
+# Run this script to indent the GNUnet code.  When run without arguments,
+# it indents the ENTIRE src/ tree.  Run with 'src/XXX' to indent the
+# src/XXX directory.
+#
+# This script is in the public domain.
+if test $# = 0
 then
-  find src/ -name "*.c" -exec dos2unix {} \;
-  find src/ -name "*.h" -exec dos2unix {} \;
+ PATHS=src/
+else
+ PATHS="$@"
+fi
+find $PATHS -name "*.c" -exec indent {} \;
+find $PATHS -name "*.h" -exec indent {} \;
+find $PATHS -name "*.c" -exec indent {} \;
+find $PATHS -name "*.h" -exec indent {} \;
+find $PATHS -name "*.c" -exec contrib/scripts/removetrailingwhitespace.py {} \;
+find $PATHS -name "*.h" -exec contrib/scripts/removetrailingwhitespace.py {} \;
+if test -n "`dos2unix -V | head -n1 | awk '{print $1 $2}'`"; then
+  find $PATHS -name "*.c" -exec dos2unix {} \;
+  find $PATHS -name "*.h" -exec dos2unix {} \;
 fi