annotate TOOLS/checktree.sh @ 20206:670f7aaf481f

Sync mail-lists.xml removal.
author diego
date Sat, 14 Oct 2006 16:22:51 +0000
parents 97fbe96274c3
children 131563493cc4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
1 #!/bin/sh
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
2
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
3 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
4
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
5 # Check source-tree for anomalies
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
6 #
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
7 # (C)opyright 2005 by Ivo van Poorten
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
8 # Licensed under GNU General Public License version 2
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
9 #
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
10 # Thanks to Melchior Franz of the FlightGear project for the original idea
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
11 # of a source-tree checker and Torinthiel for the feedback along the way.
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
12
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
13 # $Id$
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
14
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
15 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
16
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
17 # Default settings
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
18
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
19 _spaces=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
20 _extensions=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
21 _crlf=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
22 _trailws=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
23 _rcsid=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
24 _oll=no
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
25 _charset=no
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
26 _stupid=no
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
27 _showcont=no
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
28
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
29 _color=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
30 _head=yes
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
31 _svn=yes
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
32 _files=
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
33
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
34 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
35
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
36 # Avoid locale problems
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
37
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
38 export LC_ALL=C
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
39
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
40 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
41
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
42 # Helper functions
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
43
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
44 enable_all_tests() {
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
45 _spaces=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
46 _extensions=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
47 _crlf=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
48 _trailws=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
49 _rcsid=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
50 _oll=yes
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
51 _charset=yes
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
52 _stupid=yes
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
53 }
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
54
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
55 disable_all_tests() {
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
56 _spaces=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
57 _extensions=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
58 _crlf=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
59 _trailws=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
60 _rcsid=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
61 _oll=no
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
62 _charset=no
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
63 _stupid=no
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
64 }
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
65
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
66 printoption() {
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
67 echo " -(no)$1 $2 [default: $3]"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
68 }
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
69
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
70 printhead() {
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
71 test "$_head" = "yes" && echo -e "$COLB$1$COLE"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
72 }
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
73
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
74 all_filenames() {
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
75 test "$_files" != "" && echo "$_files" && return
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
76
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
77 if [ "$_svn" = "no" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
78 find . -type f \
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
79 | grep -v "\.\#\|\~$\|\.depend\|\/\.svn\/\|config.mak\|^\./config\.h" \
19078
4361813f6cae also omit configure.log and the generated help_mp.h from files to check
ivo
parents: 19077
diff changeset
80 | grep -v "^\./version\.h\|\.o$\|\.a$\|configure.log\|^\./help_mp.h"
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
81 else
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
82 list_svn .
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
83 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
84 }
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
85
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
86 list_svn() {
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
87 tmpfiles=`sed '/name/ba; /kind/ba; d; b;
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
88 :a; s/^ *....=\"\(.*\)\".*$/\1/;' $1/.svn/entries | \
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
89 sed '/$/N; s/\n/ /; / dir$/d; s/ file$//;'`
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
90 tmpdirs=`sed ' /name/ba; /kind/ba; d; b;
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
91 :a; s/^ *....=\"\(.*\)\".*$/\1/;' $1/.svn/entries | \
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
92 sed ' /$/N; s/\n/ /; / file$/d; /^ dir$/d; s/ dir$//;'`
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
93
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
94 for i in $tmpfiles; do
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
95 echo $1/$i
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
96 done
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
97 for j in $tmpdirs; do
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
98 list_svn $1/$j
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
99 done
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
100 }
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
101
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
102 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
103
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
104 # Parse command line
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
105
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
106 for i in "$@"; do
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
107 case "$i" in
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
108 -help)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
109 echo -e "\n$0 [options] [files]\n"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
110 echo -e "options:\n"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
111 printoption "spaces " "test for spaces in filenames" "$_spaces"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
112 printoption "extensions" "test for uppercase extensions" "$_extensions"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
113 printoption "crlf " "test for MSDOS line endings" "$_crlf"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
114 printoption "trailws " "test for trailing whitespace" "$_trailws"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
115 printoption "rcsid " "test for missing RCS Id's" "$_rcsid"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
116 printoption "oll " "test for overly long lines" "$_oll"
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
117 printoption "charset " "test for wrong charset" "$_charset"
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
118 printoption "stupid " "test for stupid code" "$_stupid"
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
119 echo
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
120 printoption "all " "enable all tests" "no"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
121 echo
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
122 printoption "showcont " "show offending content of file(s)" \
19080
6ff62e005cba fix line >79 characters
ivo
parents: 19079
diff changeset
123 "$_showcont"
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
124 echo
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
125 printoption "color " "colored output" "$_color"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
126 printoption "head " "print heading for each test" "$_head"
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
127 printoption "svn " "use .svn/ to determine which files to " \
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
128 "check" "$_svn"
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
129 echo -e "\nIf no files are specified, the whole tree is traversed."
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
130 echo -e "If there are, -(no)svn has no effect.\n"
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
131 exit
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
132 ;;
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
133 -stupid)
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
134 _stupid=yes
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
135 ;;
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
136 -nostupid)
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
137 _stupid=no
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
138 ;;
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
139 -charset)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
140 _charset=yes
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
141 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
142 -nocharset)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
143 _charset=no
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
144 ;;
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
145 -oll)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
146 _oll=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
147 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
148 -nooll)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
149 _oll=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
150 ;;
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
151 -svn)
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
152 _svn=yes
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
153 ;;
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
154 -nosvn)
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
155 _svn=no
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
156 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
157 -head)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
158 _head=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
159 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
160 -nohead)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
161 _head=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
162 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
163 -color)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
164 _color=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
165 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
166 -nocolor)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
167 _color=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
168 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
169 -spaces)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
170 _spaces=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
171 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
172 -nospaces)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
173 _spaces=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
174 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
175 -extensions)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
176 _extensions=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
177 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
178 -noextensions)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
179 _extensions=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
180 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
181 -crlf)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
182 _crlf=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
183 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
184 -nocrlf)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
185 _crlf=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
186 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
187 -trailws)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
188 _trailws=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
189 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
190 -notrailws)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
191 _trailws=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
192 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
193 -rcsid)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
194 _rcsid=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
195 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
196 -norcsid)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
197 _rcsid=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
198 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
199 -all)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
200 enable_all_tests
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
201 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
202 -noall)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
203 disable_all_tests
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
204 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
205 -none)
16405
ivo
parents: 16240
diff changeset
206 disable_all_tests
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
207 ;;
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
208 -showcont)
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
209 _showcont=yes
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
210 ;;
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
211 -noshowcont)
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
212 _showcont=no
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
213 ;;
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
214 -*)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
215 echo "unknown option: $i" >&2
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
216 exit 0
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
217 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
218 *)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
219 _files="$_files $i"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
220 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
221 esac
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
222 done
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
223
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
224 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
225
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
226 # Set heading color
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
227
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
228 if [ "$_color" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
229 COLB="\e[36m"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
230 COLE="\e[m"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
231 else
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
232 COLB=""
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
233 COLE=""
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
234 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
235
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
236 # Generate filelist once so -svn isn't _that_ much slower than -nosvn anymore
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
237
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
238 filelist=`all_filenames`
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
239
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
240 if [ "$_showcont" = "yes" ]; then
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
241 _diffopts="-u"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
242 _grepopts="-n -I"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
243 else
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
244 _diffopts="-q"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
245 _grepopts="-l -I"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
246 fi
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
247
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
248 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
249
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
250 # DO CHECKS
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
251
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
252 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
253
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
254 if [ "$_spaces" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
255 printhead "checking for spaces in filenames ..."
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
256 find . | grep " "
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
257 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
258
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
259 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
260
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
261 if [ "$_extensions" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
262 printhead "checking for uppercase extensions ..."
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
263 echo $filelist | grep "\.[[:upper:]]\+$" | grep -v "\.S$"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
264 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
265
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
266 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
267
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
268 if [ "$_crlf" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
269 printhead "checking for MSDOS line endings ..."
19079
0ba020beb2e4 fix matching of MSDOS line endings
ivo
parents: 19078
diff changeset
270 CR=`echo " " | tr ' ' '\015'`
0ba020beb2e4 fix matching of MSDOS line endings
ivo
parents: 19078
diff changeset
271 grep $_grepopts "$CR" $filelist
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
272 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
273
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
274 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
275
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
276 if [ "$_trailws" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
277 printhead "checking for trailing whitespace ..."
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
278 grep $_grepopts "[[:space:]]\+$" $filelist
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
279 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
280
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
281 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
282
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
283 if [ "$_rcsid" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
284 printhead "checking for missing RCS \$Id\$ or \$Revision\$ tags ..."
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
285 grep -L -I "\$\(Id\|Revision\)[[:print:]]\+\$" $filelist
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
286 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
287
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
288 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
289
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
290 if [ "$_oll" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
291 printhead "checking for overly long lines (over 79 characters) ..."
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
292 grep $_grepopts "^[[:print:]]\{80,\}$" $filelist
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
293 fi
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
294
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
295 # -----------------------------------------------------------------------------
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
296
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
297 if [ "$_charset" = "yes" ]; then
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
298 printhead "checking bad charsets ..."
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
299 for I in $filelist ; do
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
300 case "$I" in
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
301 ./help/help_mp-*.h)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
302 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
303 ./DOCS/*)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
304 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
305 *.c|*.h)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
306 iconv -c -f ascii -t ascii "$I" | diff $_diffopts "$I" -
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
307 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
308 esac
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
309 done
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
310 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
311
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
312 # -----------------------------------------------------------------------------
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
313
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
314 if [ "$_stupid" = "yes" ]; then
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
315 printhead "checking for stupid code ..."
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
316
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
317 # avoid false-positives in xpm files, docs, etc, only check .c and .h files
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
318 chfilelist=`echo $filelist | tr ' ' '\n' | grep "[\.][ch]$"`
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
319
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
320 for i in calloc malloc realloc memalign av_malloc av_mallocz faad_malloc \
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
321 lzo_malloc safe_malloc mpeg2_malloc _ogg_malloc; do
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
322 printhead "--> casting of void* $i()"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
323 grep $_grepopts "([ ]*[a-zA-Z_]\+[ ]*\*.*)[ ]*$i" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
324 done
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
325
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
326 for i in "" signed unsigned; do
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
327 printhead "--> usage of sizeof($i char)"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
328 grep $_grepopts "sizeof[ ]*([ ]*$i[ ]*char[ ]*)" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
329 done
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
330
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
331 for i in int8_t uint8_t; do
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
332 printhead "--> usage of sizeof($i)"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
333 grep $_grepopts "sizeof[ ]*([ ]*$i[ ]*)" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
334 done
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
335
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
336 printhead "--> usage of &&1"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
337 grep $_grepopts "&&[ ]*1" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
338
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
339 printhead "--> usage of ||0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
340 grep $_grepopts "||[ ]*0" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
341
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
342 # added a-fA-F_ to eliminate some false positives
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
343 printhead "--> usage of *0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
344 grep $_grepopts "[a-zA-Z0-9)]\+[ ]*\*[ ]*0[^.0-9xa-fA-F_]" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
345
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
346 printhead "--> usage of *1"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
347 grep $_grepopts "[a-zA-Z0-9)]\+[ ]*\*[ ]*1[^.0-9ea-fA-F_]" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
348
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
349 printhead "--> usage of +0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
350 grep $_grepopts "[a-zA-Z0-9)]\+[ ]*+[ ]*0[^.0-9xa-fA-F_]" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
351
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
352 printhead "--> usage of -0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
353 grep $_grepopts "[a-zA-Z0-9)]\+[ ]*-[ ]*0[^.0-9xa-fA-F_]" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
354 fi
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
355
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
356 # -----------------------------------------------------------------------------