From d0098efa958ca82dc9c65c93b5830d727422faef Mon Sep 17 00:00:00 2001 From: Aseda Gyeke Aboagye Date: Wed, 14 Aug 2013 19:03:28 -0700 Subject: core,nTox,toxic - Fix for Issue #453. Refactoring w/astyle. This commit introduces a few things. Basically I didn't like the fact that although we had a coding style document, no one was following it. See https://github.com/irungentoo/ProjectTox-Core/issues/453 for more info regarding that. This commit just marks the first of my efforts to refactor the code base according to the posted coding style document by introducing an astylerc and a optional git pre-commit hook. I propose that users can add this functionality as a pre-commit hook. More info is in the README file. However, this has only been tested on Linux and I imagine should work on OSX as well. I don't think pre-commit hooks work on Windows, but I may be mistaken. The future commits I plan are refactoring the source files for other offending items such as using typedefs. See http://wiki.tox.im/index.php/Coding_Style. --- .gitignore | 3 +++ tools/README | 9 +++++++++ tools/astylerc | 11 +++++++++++ tools/pre-commit | 17 +++++++++++++++++ 4 files changed, 40 insertions(+) create mode 100644 tools/README create mode 100644 tools/astylerc create mode 100644 tools/pre-commit diff --git a/.gitignore b/.gitignore index 07480699..49ac783a 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,6 @@ tags #netbeans nbproject + +#astyle +*.orig diff --git a/tools/README b/tools/README new file mode 100644 index 00000000..4d8538c3 --- /dev/null +++ b/tools/README @@ -0,0 +1,9 @@ +This directory can house various tools and utilities. + +astylerc + - This file can be used in the precommit hook to try its best at making the code conform to the coding style document. + +pre-commit (*NIX only at the moment) + - Lints your file in adherence to the coding style doucment as best as possible in terms of spacing, indenting, etc. + - Requires you to have astyle installed. + - To use, copy this file to ProjectTox-Core/.git/hooks diff --git a/tools/astylerc b/tools/astylerc new file mode 100644 index 00000000..a2f05160 --- /dev/null +++ b/tools/astylerc @@ -0,0 +1,11 @@ +--style=kr +--pad-header +--max-code-length=120 +--convert-tabs +--indent-switches +--pad-oper +--align-pointer=name +--align-reference=name +--preserve-date +--lineend=linux +--break-blocks \ No newline at end of file diff --git a/tools/pre-commit b/tools/pre-commit new file mode 100644 index 00000000..8f91779d --- /dev/null +++ b/tools/pre-commit @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +# +# An example hook script to verify what is about to be committed. +# Called by "git commit" with no arguments. The hook should +# exit with non-zero status after issuing an appropriate message if +# it wants to stop the commit. +# +# To enable this hook, rename this file to "pre-commit". + +for file in `git diff-index --diff-filter=ACMR --name-only HEAD`; do + if [[ $file == *.c || $file == *.h ]] + then + echo $file + `which astyle` $file --options=tools/astylerc + git add $file + fi +done \ No newline at end of file -- cgit v1.2.3