annotate TOOLS/checktree.sh @ 22359:206b4600a956

also respond to --help, -h and -? command line options
author ivo
date Wed, 28 Feb 2007 11:50:23 +0000
parents 98d5ee376a61
children eec955510da7
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
22359
206b4600a956 also respond to --help, -h and -? command line options
ivo
parents: 22358
diff changeset
108 -help|--help|-h|-\?)
16240
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"
22357
131563493cc4 clarify -none command line option
ivo
parents: 20204
diff changeset
121 echo " (-noall can be specified as -none)"
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
122 echo
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
123 printoption "showcont " "show offending content of file(s)" \
19080
6ff62e005cba fix line >79 characters
ivo
parents: 19079
diff changeset
124 "$_showcont"
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
125 echo
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
126 printoption "color " "colored output" "$_color"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
127 printoption "head " "print heading for each test" "$_head"
22358
98d5ee376a61 fix printing of -(no)svn option
ivo
parents: 22357
diff changeset
128 printoption "svn " "use .svn/ to determine which files to check"\
98d5ee376a61 fix printing of -(no)svn option
ivo
parents: 22357
diff changeset
129 "$_svn"
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
130 echo -e "\nIf no files are specified, the whole tree is traversed."
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
131 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
132 exit
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
133 ;;
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
134 -stupid)
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
135 _stupid=yes
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
136 ;;
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
137 -nostupid)
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
138 _stupid=no
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
139 ;;
18087
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
140 -charset)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
141 _charset=yes
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
142 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
143 -nocharset)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
144 _charset=no
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
145 ;;
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
146 -oll)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
147 _oll=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
148 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
149 -nooll)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
150 _oll=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
151 ;;
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
152 -svn)
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
153 _svn=yes
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
154 ;;
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
155 -nosvn)
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
156 _svn=no
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
157 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
158 -head)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
159 _head=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
160 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
161 -nohead)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
162 _head=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
163 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
164 -color)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
165 _color=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
166 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
167 -nocolor)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
168 _color=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
169 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
170 -spaces)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
171 _spaces=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
172 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
173 -nospaces)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
174 _spaces=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
175 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
176 -extensions)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
177 _extensions=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
178 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
179 -noextensions)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
180 _extensions=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
181 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
182 -crlf)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
183 _crlf=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
184 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
185 -nocrlf)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
186 _crlf=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
187 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
188 -trailws)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
189 _trailws=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
190 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
191 -notrailws)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
192 _trailws=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
193 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
194 -rcsid)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
195 _rcsid=yes
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
196 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
197 -norcsid)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
198 _rcsid=no
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
199 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
200 -all)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
201 enable_all_tests
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
202 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
203 -noall)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
204 disable_all_tests
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
205 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
206 -none)
16405
ivo
parents: 16240
diff changeset
207 disable_all_tests
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
208 ;;
17131
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
209 -showcont)
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
210 _showcont=yes
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
211 ;;
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
212 -noshowcont)
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
213 _showcont=no
80d3fdcf58a8 option to show the lines containing anomalies, patch by Ivo van Poorten
wanderer
parents: 16405
diff changeset
214 ;;
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
215 -*)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
216 echo "unknown option: $i" >&2
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
217 exit 0
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 *)
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
220 _files="$_files $i"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
221 ;;
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
222 esac
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
223 done
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
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
227 # Set heading color
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
228
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
229 if [ "$_color" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
230 COLB="\e[36m"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
231 COLE="\e[m"
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
232 else
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
233 COLB=""
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
234 COLE=""
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
235 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
236
19077
e3f7f221f75e CVS --> Subversion
ivo
parents: 18087
diff changeset
237 # 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
238
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
239 filelist=`all_filenames`
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
240
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
241 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
242 _diffopts="-u"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
243 _grepopts="-n -I"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
244 else
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
245 _diffopts="-q"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
246 _grepopts="-l -I"
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
247 fi
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
248
16240
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
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
251 # DO CHECKS
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 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
254
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
255 if [ "$_spaces" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
256 printhead "checking for spaces in filenames ..."
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
257 find . | grep " "
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
258 fi
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 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
261
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
262 if [ "$_extensions" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
263 printhead "checking for uppercase extensions ..."
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
264 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
265 fi
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 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
268
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
269 if [ "$_crlf" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
270 printhead "checking for MSDOS line endings ..."
19079
0ba020beb2e4 fix matching of MSDOS line endings
ivo
parents: 19078
diff changeset
271 CR=`echo " " | tr ' ' '\015'`
0ba020beb2e4 fix matching of MSDOS line endings
ivo
parents: 19078
diff changeset
272 grep $_grepopts "$CR" $filelist
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
273 fi
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 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
276
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
277 if [ "$_trailws" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
278 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
279 grep $_grepopts "[[:space:]]\+$" $filelist
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
280 fi
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 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
283
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
284 if [ "$_rcsid" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
285 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
286 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
287 fi
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 # -----------------------------------------------------------------------------
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
290
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
291 if [ "$_oll" = "yes" ]; then
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
292 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
293 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
294 fi
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 # -----------------------------------------------------------------------------
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
297
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
298 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
299 printhead "checking bad charsets ..."
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
300 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
301 case "$I" in
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
302 ./help/help_mp-*.h)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
303 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
304 ./DOCS/*)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
305 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
306 *.c|*.h)
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
307 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
308 ;;
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
309 esac
edffd6f8a022 add check for non-ascii charsets used in code and simplify showcont switch handling
reimar
parents: 17131
diff changeset
310 done
16240
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
311 fi
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
312
d4cf25d45b13 Script to check (CVS) source-tree for anomalies, like MSDOS line endings etc..
ivo
parents:
diff changeset
313 # -----------------------------------------------------------------------------
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
314
20204
97fbe96274c3 Use = instead of == for extra portability.
diego
parents: 19085
diff changeset
315 if [ "$_stupid" = "yes" ]; then
19085
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
316 printhead "checking for stupid code ..."
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
317
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
318 # 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
319 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
320
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
321 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
322 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
323 printhead "--> casting of void* $i()"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
324 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
325 done
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
326
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
327 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
328 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
329 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
330 done
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
331
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
332 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
333 printhead "--> usage of sizeof($i)"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
334 grep $_grepopts "sizeof[ ]*([ ]*$i[ ]*)" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
335 done
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
336
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
337 printhead "--> usage of &&1"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
338 grep $_grepopts "&&[ ]*1" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
339
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
340 printhead "--> usage of ||0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
341 grep $_grepopts "||[ ]*0" $chfilelist
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
342
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
343 # 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
344 printhead "--> usage of *0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
345 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
346
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
347 printhead "--> usage of *1"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
348 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
349
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
350 printhead "--> usage of +0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
351 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
352
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
353 printhead "--> usage of -0"
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
354 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
355 fi
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
356
e5ec659ec1c6 added checks for stupid code like casting return value of malloc and friends,
ivo
parents: 19083
diff changeset
357 # -----------------------------------------------------------------------------