diff --git a/genheader.sh b/utils/genheader.sh similarity index 93% rename from genheader.sh rename to utils/genheader.sh index 7be2999..26ee24b 100755 --- a/genheader.sh +++ b/utils/genheader.sh @@ -7,7 +7,7 @@ echo "* Institution: BFH Bern University of Applied Sciences" echo "* File: $1" echo "*" echo "* Version History:" -echo "* Date Autor Email SHA Changes" +echo "* Date Autor Email SHA Changes" git log --pretty=format:"* %ad%x09%ae%x09%h%x09%s" --date=short --date-order --no-merges --reverse $1 | grep -v -i "fileheader" diff --git a/utils/style.astylerc b/utils/style.astylerc new file mode 100644 index 0000000..8fdbb87 --- /dev/null +++ b/utils/style.astylerc @@ -0,0 +1,16 @@ + +# general style +--style=1tbs +--indent=spaces=4 # default +--lineend=linux #only \r as line ending + +# alignment +--align-pointer=type #put asterisks to the type. eg. char* a +--align-reference=type #put references to the type. eg. int& a + +# padding +--break-blocks # insert empty lines between header blocks +--unpad-paren # remove extra padding around parens +--pad-oper # spaces around operators +--pad-header # insert space between header blocks and the following paren +--add-brackets # add brackets to one line conditionals diff --git a/updateheaders.sh b/utils/updateheaders.sh similarity index 71% rename from updateheaders.sh rename to utils/updateheaders.sh index 84068bb..55d8b74 100755 --- a/updateheaders.sh +++ b/utils/updateheaders.sh @@ -3,14 +3,15 @@ FILES=`find common/ emulator/ discovery/ -name "*.c" -or -name "*.h" -or -name "*.cpp" | grep -v libs | grep -v /pixy/` + for FILE in $FILES; do echo "Adding Header to $FILE" - #remove old header - CONTENT=$(perl -0777 -pe 's%^/\*.*?discoverpixy.*?\*/%%igs' $FILE) + #remove old header, and format file with astyle + CONTENT=$(perl -0777 -pe 's%^/\*.*?discoverpixy.*?\*/%%igs' $FILE | astyle --options=./utils/style.astylerc) #add new header - ./genheader.sh $FILE > $FILE + ./utils/genheader.sh $FILE > $FILE #append file content echo "$CONTENT" >> $FILE