3 # This script scans the whole source code for symbols of the form
5 # xxx is either TRACE, WARN, ERR or WARN
6 # yyy is a C identifier
7 # It outputs on the standard output a sorted list of the
8 # yyy identifiers found in the .c files.
9 # Each identifier is reported once. Header files are not scanned.
11 # The script can be given an argument that specify the files to be
12 # searched according to the following scheme:
13 # - if the argument does not contain a slash (/), the script
14 # will search the tree rooted in the current directory for
15 # files that match that description. You can also pass
16 # wildcard arguments, but remember to quote them to prevent
17 # expansion by the shell
18 # - if the argument does contain a slash, only that file is
20 # - if no argument is given, the argument defaults to "*.c"
21 # that is, all C files are searched.
22 # - if more than a argument is given, only the listed files are
23 # searched. Note that in this case, the script will not
24 # attempt to find them in some subdirectories, but rather
25 # it will try to open them in the current directory.
26 # Thus, if you want to disable the automatic searching when the file
27 # name does not contain a /, either prefix the filename with ./
28 # or add /dev/null as another argument.
30 # Dimitrie O. Paun <dimi@cs.toronto.edu>
34 0 | 1) files=${1:-'*.c'}
35 if [ ${files#*/} = "$files" ]; then
36 files=$(find . -name "$files" -print)
42 grep -h "TRACE *(" $files /dev/null | \
43 sed 's/.*TRACE *( *\([A-Za-z0-9_]*\).*/\1/g'
44 grep -h "ERR *(" $files /dev/null | \
45 sed 's/.*ERR *( *\([A-Za-z0-9_]*\).*/\1/g'
46 grep -h "FIXME *(" $files /dev/null | \
47 sed 's/.*FIXME *( *\([A-Za-z0-9_]*\).*/\1/g'
48 grep -h "WARN *(" $files /dev/null | \
49 sed 's/.*WARN *( *\([A-Za-z0-9_]*\).*/\1/g'