Skip to content

Commit ef6e330

Browse files
committed
improve checkstyle.sh compatibility with non-GNU systems
git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@45916 379a1393-f5fb-40a0-bcee-ef074d9b53f7
1 parent b04806d commit ef6e330

File tree

1 file changed

+20
-11
lines changed

1 file changed

+20
-11
lines changed

vice/src/checkstyle.sh

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function checkcppcomments
88
{
99
echo "finding c++ style comments:"
1010
# first make a list of files, omitting those we dont want to check
11-
find -name '*.[chm]' | \
11+
find . -name '*.[chm]' | \
1212
grep -v "/arch/gtk3/novte/" | \
1313
grep -v "/lib/" | \
1414
grep -v '/resid/' | \
@@ -17,11 +17,11 @@ function checkcppcomments
1717
while IFS= read -r line
1818
do
1919
grep -Hn '//' "$line" | \
20-
sed -s 's/http:\/\//http:/g' | \
21-
sed -s 's/https:\/\//https:/g' | \
22-
sed -s 's/ip4:\/\//ip4:/g' | \
23-
sed -s 's/ip6:\/\//ip6:/g' | \
24-
sed -s 's/file:\/\//file:/g' | \
20+
${SED} -s 's/http:\/\//http:/g' | \
21+
${SED} -s 's/https:\/\//https:/g' | \
22+
${SED} -s 's/ip4:\/\//ip4:/g' | \
23+
${SED} -s 's/ip6:\/\//ip6:/g' | \
24+
${SED} -s 's/file:\/\//file:/g' | \
2525
grep --color '//'
2626
done < .checkcppcomments
2727
rm -f .checkcppcomments
@@ -32,13 +32,13 @@ function checktabs
3232
{
3333
echo "finding TABs:"
3434
# first make a list of files, omitting those we dont want to check
35-
find -name '*.[chm]' | \
35+
find . -name '*.[chm]' | \
3636
grep -v '/monitor/mon_parse.c' | \
3737
grep -v '/monitor/mon_lex.c' | \
3838
grep -v '/arch/mingw32-pcap/wpcap/' | \
3939
grep -v '/arch/gtk3/novte/box_drawing.h' | \
4040
grep -v "/lib/" > .checktabs
41-
find -name '*.cc' | \
41+
find . -name '*.cc' | \
4242
grep -v '/monitor/mon_parse.c' | \
4343
grep -v '/monitor/mon_lex.c' | \
4444
grep -v '/arch/mingw32-pcap/wpcap/' | \
@@ -61,13 +61,13 @@ function checkwhitespace
6161
{
6262
echo "finding trailing whitespace:"
6363
# first make a list of files, omitting those we dont want to check
64-
find -name '*.[chm]' | \
64+
find . -name '*.[chm]' | \
6565
grep -v '/monitor/mon_parse.c' | \
6666
grep -v '/monitor/mon_lex.c' | \
6767
grep -v '/arch/mingw32-pcap/wpcap/' | \
6868
grep -v '/arch/gtk3/novte/box_drawing.h' | \
6969
grep -v "/lib/" > .checkws
70-
find -name '*.cc' | \
70+
find . -name '*.cc' | \
7171
grep -v '/monitor/mon_parse.c' | \
7272
grep -v '/monitor/mon_lex.c' | \
7373
grep -v '/arch/mingw32-pcap/wpcap/' | \
@@ -76,7 +76,7 @@ function checkwhitespace
7676
# find trailing whitespace
7777
while IFS= read -r line
7878
do
79-
grep -Hn '[[:blank:]]\+$' "$line" | sed 's/\s\+$/~~~~/'
79+
grep -Hn '[[:blank:]]\+$' "$line" | ${SED} 's/\s\+$/~~~~/'
8080
done < .checkws
8181
rm -f .checkws
8282
}
@@ -95,6 +95,15 @@ function usage
9595
if [ "$#" -eq "0" ]; then
9696
usage
9797
else
98+
if sed --version >/dev/null 2>&1; then
99+
SED=sed
100+
elif gsed --version >/dev/null 2>&1; then
101+
SED=gsed
102+
else
103+
echo No GNU sed found
104+
exit 2
105+
fi
106+
98107
for thisarg in "$@"
99108
do
100109
case "$thisarg" in

0 commit comments

Comments
 (0)