1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179
|
#!/bin/sh
#
# Copyright (C) 2014 Masatake YAMATO
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
CTAGS=./ctags
line()
{
local i
for i in $(seq 72); do
echo -n -e -
done
echo
}
header()
{
echo
echo "$1"
line
}
check_include_general_h_first()
{
local f
local l
local i=0
header "Check whether general.h is included first: $1"
# Added -maxdepth 1 to skip parsers/cxx
for f in $(find $1 -maxdepth 1 -name '*.c'); do
if grep -a -q -e '^#[[:space:]]*include' $f; then
l=$()
if ! ( grep -a -e '^#[[:space:]]*include' $f | head -1 | grep -q "general.h" ); then
i=$(expr $i + 1)
echo "$f: general.h should be included FIRST" 2>&1
fi
fi
done
return $i
}
check_name_cpp_macro()
{
local dir=$1
local r=0
local n
header "Check whether '_' is not used as ctags own macro name"
for f in $(find $dir -name '*.[ch]' | grep -v portable-dirent_p.h); do
if ${CTAGS} --language-force=C -x --_xformat='%F:%N' --kinds-C=d -o - $f | grep -q '.*:_.*H'; then
for n in $(${CTAGS} --language-force=C -x --_xformat='%N' --kinds-C=d -o - $f | grep '^_.*H'); do
echo "#" $n
echo sed -i \""s|$n|CTAGS_$(echo $dir | tr a-z A-Z)_${n#_}|g\"" $f
done
r=1
fi
done
return $r
}
check_vStringCatS_usage()
{
local i=0
header "Check wrong vStringCatS usage(use vStringPut instead): $1"
for f in $(find $1 -name '*.c'); do
if grep -H -a -e 'vStringCatS[[:space:]]*(.*,[[:space:]]*"."[[:space:]]*)' $f; then
i=$(expr $i + 1)
elif grep -H -a -e 'vStringCatS[[:space:]]*(.*,[[:space:]]*"\\."[[:space:]]*)' $f; then
i=$(expr $i + 1)
fi
done
return $i
}
check_eof_chars_in_vcxproj()
{
local r=2
local f
# *.vcxproj* should not have the last CRLF.
for f in win32/ctags_vs2013.vcxproj win32/ctags_vs2013.vcxproj.filters; do
header "Check the EOF characters of $f"
local s=$(od -t c -j $(expr $(stat -c %s $f) - 1) $f)
if echo "$s" | grep -q '>$'; then
r=$(expr $r - 1)
else
echo "unexpected chars: $s"
fi
done
return $r
}
main()
{
local i=0
if ! [ -d ./main ]; then
echo "cannot find ./main"
return 2
fi
if ! [ -d ./parsers ]; then
echo "cannot find ./parsers"
return 2
fi
if ! check_include_general_h_first main; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
if ! check_include_general_h_first parsers; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
if ! check_name_cpp_macro main; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
if ! check_name_cpp_macro parsers; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
if ! check_vStringCatS_usage main; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
if ! check_vStringCatS_usage parsers; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
if ! check_eof_chars_in_vcxproj; then
i=$(expr $i + 1)
echo "failed"
else
echo "ok"
fi
return $i
}
main "$@"
exit $?
|