4 ( .
"${tools_dir}"/check-misc.sh
) || fail
=$?
6 # The first regex finds function calls like foo() (as opposed to foo ()).
7 # It attempts to ignore string constants (may cause false negatives).
8 # The second and third ignore block comments (gtkdoc uses foo() as markup).
9 # The fourth ignores cpp so you can
10 # #define foo(bar) (_real_foo (__FUNC__, bar)) (cpp insists on foo() style).
11 if grep -n '^[^"]*[[:lower:]](' "$@" \
12 |
grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *\*' \
13 |
grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: */\*' \
14 |
grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *#'
16 echo "^^^ Our coding style is to use function calls like foo (), not foo()"
20 if grep -En '[(][[:alnum:]_]+ ?\*[)][(]?[[:alpha:]_]' "$@"; then
21 echo "^^^ Our coding style is to have a space between a cast and the "
22 echo " thing being cast"
26 # this only spots casts
27 if grep -En '[(][[:alnum:]_]+\*+[)]' "$@"; then
28 echo "^^^ Our coding style is to have a space before the * of pointer types"
32 # ... and this only spots variable declarations and function return types
33 if grep -En '^ *(static |const |)* *[[:alnum:]_]+\*+([[:alnum:]_]|;|$)' \
35 echo "^^^ Our coding style is to have a space before the * of pointer types"
40 if grep -n 'g_hash_table_destroy' "$@"; then
41 echo "^^^ Our coding style is to use g_hash_table_unref"
45 for p
in "" "ptr_" "byte_"; do
46 if grep -En "g_${p}array_free \(([^ ,]+), TRUE\)" "$@"; then
47 echo "^^^ Our coding style is to use g_${p}array_unref in the case "
48 echo " the underlying C array is not used"
53 if test -n "$CHECK_FOR_LONG_LINES"
55 if egrep -n '.{80,}' "$@"
57 echo "^^^ The above files contain long lines"