Copyright record updated.
[platform/core/security/suspicious-activity-monitor.git] / style_check.sh
1 #!/bin/bash
2
3 SCRIPT_PATH=$(readlink -m $0)
4 SCRIPT_DIR=${SCRIPT_PATH%/*}
5 export ARTISTIC_STYLE_OPTIONS=${SCRIPT_DIR}/.astylerc
6
7 declare -a IGNORED=(
8     "build"
9     "build-gbs"
10 )
11
12 function is_ignored
13 {
14     for ((i = 0; i < ${#IGNORED[@]}; i++)) ; do
15         if [ "$1" = ${IGNORED[$i]} ] ; then
16             return 0
17         fi
18     done
19     return 1
20 }
21
22 function visit
23 {
24     for entry in ${1}/* ; do
25         if [ -d $entry ] ; then
26             base_n=$(basename $entry)
27             is_ignored $base_n && echo "$base_n ignored" || visit $entry
28         elif [ -f $entry ] ; then
29             if [[ $entry =~ ^.+\.(cpp|h)$ ]] ; then
30                 astyle $entry
31             fi
32         fi
33
34     done
35 }
36
37 visit $SCRIPT_DIR