git.fiddlerwoaroof.com
Browse code

improve formatter

Greg Wiley authored on 21/04/2017 05:37:04
Showing 2 changed files
... ...
@@ -55,6 +55,6 @@ endif
55 55
 
56 56
 .PHONY: format
57 57
 format:
58
-	@./format.sh
58
+	@./format.sh *.cc *.h
59 59
 
60 60
 
... ...
@@ -1,5 +1,24 @@
1 1
 #!/bin/bash
2 2
 
3
-for f in *.h *.cc; do echo "" >> $f; { rm $f;cat -s >$f; }<$f; done
4
-astyle -q --options=$(dirname $0)/astylerc *.h *.cc
3
+
4
+for f in "${@}"; do
5
+  astyle -q --options=$(dirname $0)/astylerc $f
6
+  echo "" >> $f
7
+  if ! grep -q 'Copyright.*CJ' $f; then
8
+      cat << EOF > $f.temp_
9
+/* Copyright (C) CJ Affiliate
10
+ *
11
+ * You may use, distribute and modify this code under  the
12
+ * terms of the GNU Public License.
13
+ *
14
+ * You should have received a copy of the license with this
15
+ * file. If not, you will find a copy in the "LICENSE" file
16
+ * at https://github.com/cjdev/dual-control.
17
+ */
18
+
19
+EOF
20
+  fi
21
+  cat -s $f >> $f.temp_
22
+  mv $f.temp_ $f
23
+done
5 24