~ubuntu-branches/ubuntu/natty/empathy/natty-updates

« back to all changes in this revision

Viewing changes to tools/check-c-style.sh

Tags: upstream-0.22.0
ImportĀ upstreamĀ versionĀ 0.22.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
fail=0
 
3
 
 
4
( . "${tools_dir}"/check-misc.sh ) || fail=$?
 
5
 
 
6
if grep -n '^ *GError *\*[[:alpha:]_][[:alnum:]_]* *;' "$@"
 
7
then
 
8
  echo "^^^ The above files contain uninitialized GError*s - they should be"
 
9
  echo "    initialized to NULL"
 
10
  fail=1
 
11
fi
 
12
 
 
13
# The first regex finds function calls like foo() (as opposed to foo ()).
 
14
#   It attempts to ignore string constants (may cause false negatives).
 
15
# The second and third ignore block comments (gtkdoc uses foo() as markup).
 
16
# The fourth ignores cpp so you can
 
17
#   #define foo(bar) (_real_foo (__FUNC__, bar)) (cpp insists on foo() style).
 
18
if grep -n '^[^"]*[[:lower:]](' "$@" \
 
19
  | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *\*' \
 
20
  | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: */\*' \
 
21
  | grep -v '^[-[:alnum:]_./]*:[[:digit:]]*: *#'
 
22
then
 
23
  echo "^^^ Our coding style is to use function calls like foo (), not foo()"
 
24
  fail=1
 
25
fi
 
26
 
 
27
if test -n "$CHECK_FOR_LONG_LINES"
 
28
then
 
29
  if egrep -n '.{80,}' "$@"
 
30
  then
 
31
    echo "^^^ The above files contain long lines"
 
32
    fail=1
 
33
  fi
 
34
fi
 
35
 
 
36
exit $fail