summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2007-12-04 10:25:17 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2007-12-04 10:25:17 +0000
commitedb62c8475a47cb83ea8ee628f8280050f092e05 (patch)
tree70ba66b35cd4d1bc3af5e2450940392206dff075 /tools
parent1c7eb2faf81ea8c00062f80b0f055e8443308081 (diff)
darcs mv check-* tools/ ; adjust src/Makefile.am, tests/Makefile.am, tools/Makefile.am, Makefile.am accordingly
Diffstat (limited to 'tools')
-rw-r--r--tools/Makefile.am3
-rw-r--r--tools/check-c-style.sh36
-rw-r--r--tools/check-coding-style.mk15
-rw-r--r--tools/check-whitespace.sh17
4 files changed, 71 insertions, 0 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am
index c27fe04a5..6be0b72c4 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -1,6 +1,9 @@
EXTRA_DIST = \
c-constants-generator.xsl \
c-interfaces-generator.xsl \
+ check-coding-style.mk \
+ check-c-style.sh \
+ check-whitespace.sh \
doc-generator.xsl \
genginterface.py \
ls-interfaces.xsl \
diff --git a/tools/check-c-style.sh b/tools/check-c-style.sh
new file mode 100644
index 000000000..793d34b82
--- /dev/null
+++ b/tools/check-c-style.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+fail=0
+
+/bin/sh "${top_srcdir}"/check-whitespace.sh "$@" || fail=$?
+
+if grep -n '^ *GError *\*[[:alpha:]_][[:alnum:]_]* *;' "$@"
+then
+ echo "^^^ The above files contain uninitialized GError*s - they should be"
+ echo " initialized to NULL"
+ fail=1
+fi
+
+# The first regex finds function calls like foo() (as opposed to foo ()).
+# It attempts to ignore string constants (may cause false negatives).
+# The second and third ignore block comments (gtkdoc uses foo() as markup).
+# The fourth ignores cpp so you can
+# #define foo(bar) (_real_foo (__FUNC__, bar)) (cpp insists on foo() style).
+if grep -n '^[^"]*[[:lower:]](' "$@" \
+ | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *\*' \
+ | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: */\*' \
+ | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *#'
+then
+ echo "^^^ Our coding style is to use function calls like foo (), not foo()"
+ fail=1
+fi
+
+if test -n "$CHECK_FOR_LONG_LINES"
+then
+ if egrep -n '.{80,}' "$@"
+ then
+ echo "^^^ The above files contain long lines"
+ fail=1
+ fi
+fi
+
+exit $fail
diff --git a/tools/check-coding-style.mk b/tools/check-coding-style.mk
new file mode 100644
index 000000000..b69c63839
--- /dev/null
+++ b/tools/check-coding-style.mk
@@ -0,0 +1,15 @@
+check-local::
+ @fail=0; \
+ if test -n "$(check_misc_sources)"; then \
+ top_srcdir=$(top_srcdir) sh $(top_srcdir)/check-whitespace.sh \
+ $(check_misc_sources) || fail=1; \
+ fi; \
+ if test -n "$(check_c_sources)"; then \
+ top_srcdir=$(top_srcdir) sh $(top_srcdir)/check-c-style.sh \
+ $(check_c_sources) || fail=1; \
+ fi;\
+ if test yes = "$(ENABLE_CODING_STYLE_CHECKS)"; then \
+ exit "$$fail";\
+ else \
+ exit 0;\
+ fi
diff --git a/tools/check-whitespace.sh b/tools/check-whitespace.sh
new file mode 100644
index 000000000..534833126
--- /dev/null
+++ b/tools/check-whitespace.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+fail=0
+
+if grep -n ' $' "$@"
+then
+ echo "^^^ The above files contain unwanted trailing spaces"
+ fail=1
+fi
+
+if grep -n ' ' "$@"
+then
+ echo "^^^ The above files contain tabs"
+ fail=1
+fi
+
+exit $fail