summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorXavier Claessens <xclaesse@gmail.com>2011-11-16 15:58:50 +0100
committerXavier Claessens <xclaesse@gmail.com>2011-11-16 15:58:50 +0100
commit3785f4686c084558b0b693c7d625088efe432d73 (patch)
treed8047cd2ce1e8a81d230e2a89cca8e5cc9b1a585 /tools
parent267db8394c7b8be25daa72674eb088b845c15ead (diff)
Add coding style check for g_hash_table_destroy and g_array_free usage
Diffstat (limited to 'tools')
-rw-r--r--tools/check-c-style.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/tools/check-c-style.sh b/tools/check-c-style.sh
index 357fdb3..4330b14 100644
--- a/tools/check-c-style.sh
+++ b/tools/check-c-style.sh
@@ -24,6 +24,39 @@ then
fail=1
fi
+if grep -En '[(][[:alnum:]_]+ ?\*[)][(]?[[:alpha:]_]' "$@"; then
+ echo "^^^ Our coding style is to have a space between a cast and the "
+ echo " thing being cast"
+ fail=1
+fi
+
+# this only spots casts
+if grep -En '[(][[:alnum:]_]+\*+[)]' "$@"; then
+ echo "^^^ Our coding style is to have a space before the * of pointer types"
+ echo " (regex 1)"
+ fail=1
+fi
+# ... and this only spots variable declarations and function return types
+if grep -En '^ *(static |const |)* *[[:alnum:]_]+\*+([[:alnum:]_]|;|$)' \
+ "$@"; then
+ echo "^^^ Our coding style is to have a space before the * of pointer types"
+ echo " (regex 2)"
+ fail=1
+fi
+
+if grep -n 'g_hash_table_destroy' "$@"; then
+ echo "^^^ Our coding style is to use g_hash_table_unref"
+ fail=1
+fi
+
+for p in "" "ptr_" "byte_"; do
+ if grep -En "g_${p}array_free \(([^ ,]+), TRUE\)" "$@"; then
+ echo "^^^ Our coding style is to use g_${p}array_unref in the case "
+ echo " the underlying C array is not used"
+ fail=1
+ fi
+done
+
if test -n "$CHECK_FOR_LONG_LINES"
then
if egrep -n '.{80,}' "$@"