git='no';
ext='\.[ch]$';
FILES='.';
+tflag='no';
+t_enum='no';
+t_func='no';
+t_macro='no';
+t_type='no';
grepc_usage()
grepc_parse_cmd()
{
- while getopts "ghx:" opt; do
+ while getopts "ght:x:" opt; do
case "$opt" in
g)
git='yes';
grepc_usage;
exit 0;
;;
+ t)
+ case "$OPTARG" in
+ e)
+ t_enum='yes';
+ ;;
+ f)
+ t_func='yes';
+ ;;
+ m)
+ t_macro='yes';
+ ;;
+ t)
+ t_type='yes';
+ ;;
+ *)
+ grepc_usage;
+ exit 1;
+ ;;
+ esac;
+ tflag='yes';
+ ;;
x)
ext="$OPTARG";
;;
}
-grepc_grepc()
+grepc_search_default()
{
grepc_enum_constant "$1";
grepc_func "$1";
}
+grepc_search()
+{
+ if [ "$tflag" = 'no' ]; then
+ grepc_search_default "$1";
+
+ else
+ if [ "$t_enum" = 'yes' ]; then
+ grepc_enum_constant "$1";
+ fi;
+ if [ "$t_func" = 'yes' ]; then
+ grepc_func "$1";
+ fi;
+ if [ "$t_macro" = 'yes' ]; then
+ grepc_macro "$1";
+ fi;
+ if [ "$t_type" = 'yes' ]; then
+ grepc_type "$1";
+ fi;
+ fi;
+}
+
+
main()
{
grepc_parse_cmd $@;
grepc_find_files "$identifier";
- grepc_grepc "$identifier" \
+ grepc_search "$identifier" \
| tail -n+3;
}
.I file
is given,
the working directory is searched.
+.SS Types of code
+This program can search for several types of code.
+The following arguments can be passed to the
+.B \-t
+option
+to select the types of code that will be searched.
+.TP
+.B e
+enum constant definitions.
+.TP
+.B f
+Function declarations and definitions.
+.TP
+.B m
+Macro definitions.
+.TP
+.B t
+Type definitions.
.SH OPTIONS
.TP
.B \-g
.B \-h
Output a help message and exit.
.TP
+.BI \-t " type"
+Restrict the search to a specific
+.I type
+of code (see Types of code under DESCRIPTION).
+This option can be passed multiple times
+to search for various types of code.
+Default:
+.BR "e f m t" .
+.TP
.BI \-x " extension"
Restrict the search to files ending with
.IR extension .