home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
c
/
getf.arc
/
GETF.DOC
< prev
next >
Wrap
Text File
|
1988-11-11
|
5KB
|
144 lines
NAME: getf - locate the source file containing a C function
and present it in a specified editor.
USAGE: getf [list_file_name] function_name
DESCRIPTION:
getf looks for the file funcs.txt, which is presumed to be a
listing of C source file names together with a list of the C
functions defined in these source files, and the line numbers of
the definitions. The expected format is
source_file_1.c:
function_1 lineno_1
function_2 lineno_2
...
function_n lineno_n;
source_file_2.c:
...
(This file can be conveniently built using the companion program
bldfuncs.c.)
The editor to be used is specified in the DOS environment variable
GETFEDIT, which is presumed to have the form:
editor_file_name control_string
where control_string is an sprintf control string which must have
an occurrence of the pattern "%s". This pattern will be replaced by
the name of the source file in which the requested function
resides.
If a pattern "%d" exists, it will be replaced by the line number on
which the requested function is defined. Otherwise, if a second
"%s" pattern exists, it will be replaced by the name of the
function. The latter two formats allow the use of an
editor-specific command to position the source file to the
requested function automatically. After replacing the %s and %d
patterns as above, the GETFEDIT string is executed via a DOS exec
call, thus overlaying the current program getf.
Unix style regular expressions are allowed in the function name
argument for getf, and are interpreted as follows:
* Matches any string including the null string.
? Matches any single character.
[...] Matches any one of the characters enclosed.
[~...] Matches any character NOT enclosed.
- May be used inside brackets to specify range
(i.e. x[1-58] matches x1, x2, ... x5, x8)
\\ Escapes special characters.
Other characters match themselves.
EXAMPLES:
An example of funcs.txt is
bldfuncs.c:
main 48
get_names_one_file 97
get_fn_name 187
filter_data 221
filter_parens 242
filter_curly_braces 274
filter_ppdir 306
get_ppdir_line 343
filter_quotes 367
filter_cmt 396;
getf.c:
main 49
patn_match 193
ask_for_file 226
edit 259
help 299;
Assume the editor is BRIEF. Possible GETFEDIT strings might be:
b.exe %s
This will simply bring up the desired source file
in BRIEF without any attempt at positioning the
cursor to the requested function.
b.exe -m"search_fwd %s" %s
This will bring up the desired source file and
position the cursor to the first occurrence of the
requested function.
b.exe -m"funcsrch %s" %s
(see DDJ article for a description of this
customized BRIEF macro.) This will bring up the
desired source file, seek to the end of the file,
then seek backwards for the LAST occurrence of the
requested function. In practice, this is the
approach most likely to position the cursor to the
actual definition of the function.
For the SEE editor supplied with the DeSmet C compiler, a suitable
GETFEDIT control string is:
\see.exe %s -l%d
This will bring up the desired source file and
position the cursor near the function definition.
Of course, if much text is added or deleted the
line numbers in funcs.txt will be out of date, so
bldfuncs will need to be run again.
To illustrate wildcards:
getf func*
matches func, func1, func_2, etc.
getf t*n
matches ten, tension, transportation, but not tens.
getf [bdf-h]ad
matches bad, dad, fad, gad, had
*alloc
matches alloc, malloc, calloc, realloc
[~c]alloc
matches malloc, but not alloc, calloc
NOTE:
Remember that to set GETFEDIT in your autoexec.bat file (or in any
other batch file) you must use TWO percent signs instead of one:
set GETFEDIT=c:\bin\b.exe -m"funcsrch %%s" %%s
This is necessary to avoid interpretation of the percent signs by
command.com.
AUTHOR:
Marvin Hymowech, "Find That Function", Dr. Dobb's Journal of Software
Tools, #142 (August 1988).
transcribed and modestly enhanced by James R. Van Zandt,
jrv@mitre-bedford.arpa.