42 lines
1.6 KiB
Plaintext
42 lines
1.6 KiB
Plaintext
|
#!/bin/bash
|
||
|
#
|
||
|
# This script scans the whole source code for symbols of the form
|
||
|
# 'dprintf_xxx(yyy' where yyy is a C identifier and outputs, on the
|
||
|
# standard output a sorted list of the identifiers found in the .c
|
||
|
# files. Each identifier is reported once. Header files are not
|
||
|
# scanned.
|
||
|
#
|
||
|
# The script can be given an argument that specify the files to be
|
||
|
# searched according to the following scheme:
|
||
|
# - if the argument does not contain a slash (/), the script
|
||
|
# will search the tree rooted in the current directory for
|
||
|
# files that match that description. You can also pass
|
||
|
# wildcard arguments, but remember to quote them to prevent
|
||
|
# expansion by the shell
|
||
|
# - if the argument does contain a slash, only that file is
|
||
|
# searched
|
||
|
# - if no argument is given, the argument defaults to "*.c"
|
||
|
# that is, all C files are searched.
|
||
|
# - if more than a argument is given, only the listed files are
|
||
|
# searched. Note that in this case, the script will not
|
||
|
# attempt to find them in some subdirectories, but rather
|
||
|
# it will try to open them in the current directory.
|
||
|
# Thus, if you want to disable the automatic searching when the file
|
||
|
# name does not contain a /, either prefix the filename with ./
|
||
|
# or add /dev/null as another argument.
|
||
|
#
|
||
|
# Dimitrie O. Paun <dimi@cs.toronto.edu>
|
||
|
#
|
||
|
|
||
|
case "$#" in
|
||
|
0 | 1) files=${1:-'*.c'}
|
||
|
if [ ${files#*/} = "$files" ]; then
|
||
|
files=$(find . -name "$files" -print)
|
||
|
fi;;
|
||
|
* ) files="$@";;
|
||
|
esac
|
||
|
|
||
|
grep -h dprintf_ $files /dev/null | \
|
||
|
sed 's/.*dprintf_[A-Za-z0-9_]\+ *( *\([A-Za-z0-9_]*\).*/\1/g' | \
|
||
|
sort | uniq
|