home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Share Gallery 1
/
share_gal_1.zip
/
share_gal_1
/
LA
/
LA013.ZIP
/
RETROMAC.COM
/
RETRO.KML
< prev
next >
Wrap
Text File
|
1989-10-01
|
37KB
|
990 lines
*
* ----------------------------------------------
* PC-TAGS(tm) RETRO Program for the KEDIT Editor
* ----------------------------------------------
*
* KEDIT Macros to Search a PC-TAGS-Generated Tagfile and Retrieve a
* Function Definition
*
* Copyright (C) 1989 by Moderne Software. All rights reserved.
* Moderne Software, P.O. Box 3638, Santa Clara, CA 95055-3638
*
* Limited permission is given to registered PC-TAGS users to modify this
* file for their own personal use only. This file may not be used for any
* purpose other than in conjunction with the PC-TAGS software package.
*
* Entry Points
* ------------
* pctags_auto -- uses word under cursor for search
* pctags_prompt -- prompts for a word to use in search
*
* Support Macros
* --------------
* _init -- initialize global variables
* _delimiter -- determine if a character is a word delimiter
* _convert_slashes -- convert all slash characters in string to backslashes
* _dos_shell -- execute RETROEXEC environment value thru DOS
* _find_first -- get first matching file spec
* _find_next -- get next matching file spec
* _get_tagfile -- retrieve the name of the next tagfile to search
* _parse_file_spec -- break multiple tagfile specs into single parts
* _file_loaded -- determine if a file is already loaded
* _save_dir_file -- temporarily rename any existing DIR.DIR file
* _restore_dir -- restore renamed directory file back to DIR.DIR
* _init_file -- initialize editor settings for loaded file
* _pctags_main -- search and retrieval workhorse code
*
* History
* -------
* 1 Oct 89 -- Version 1.00
*
****************************************
:_init
* Macro : _init
* Syntax: 'macro _init'
* Entry : None.
* Exit : Global variables used by the RETRO operation are initialized.
* Note : This macro must be called every time pctags_auto or pctags_prompt
* are invoked.
* You can change the pctags_tagname_case variable's value from
* CASE_SENSITIVE to CASE_INSENSITIVE if you want the search for
* a matching tagname to ignore case
'editv set pctags_tagname_case CASE_SENSITIVE'
* The following variable values should not be changed
'editv set pctags_first_call 1'
'editv set pctags_env_tagfiles '
'editv set pctags_return_arg '
'editv set pctags_file_spec '
* _init
****************************************
:alt-t
* Macro : pctags_auto
* Syntax: Press the <Alt-T> key
* Entry : None. Callable from outside this module.
* Exit : '0' if entire retrieval operation was successfully completed
* '1' if operation was not successful.
* Description:
* Complete RETRO operation is performed.
* Tagname is extracted from the current cursor position
* The cursor should be in the file area when this macro is invoked. If
* the cursor is on the command line, the operation will abort.
* Note : This macro is assigned by default to the <Alt-T> keystroke. You may
* reset this to any key you wish.
* Make sure cursor is in file area and not on command line
if command() then do
* Cursor cannot be on command line
'emsg Cursor must be in file area'
exit 1
end
* Make sure cursor is under a valid word
'macro _delimiter' field.2()
if rc = 1 then do
'emsg Cursor is not under a valid word'
exit 1
end
* Initialize global variables
'macro _init'
* Save current cursor position
'sos save'
* Backtrack to the start of the word (first delimiter or beginning
* of line)
do forever
* If at beginning of line, stop backtracking
if first() then
leave
* Backtrack one character
'cursor screen left'
* Check if character is a delimiter
'macro _delimiter' field.2()
if rc = 1 then do
* Advance forward to first character in word and exit loop
saved_rc = rc
'cursor screen right'
end
* If a delimiter was found, stop backtracking
if saved_rc = '1' then
leave
end
* Grab characters until end of word
tagname = ''
do forever
* Check if character is a delimiter
'macro _delimiter' field.2()
if rc = 1 then
* Reached end of word, stop grabbing characters
leave
* Append character to tagname
tagname = tagname || field.2()
* Advance to next character
'cursor screen right'
end
* Restore original cursor position
'sos restore'
* Append a blank to the tagname
tagname = tagname || ' '
* Perform retrieval operation
'macro _pctags_main' tagname
* Return appropriate value
'editv get pctags_return_arg'
if pctags_return_arg = 'SUCCESSFUL' then
* Successful retrieval operation
exit 0
else
* Failed operation
* Put cursor into file area
if command() then
'cursor home'
exit 1
* pctags_auto
****************************************
:alt-p
* Macro : pctags_prompt
* Syntax: Press the <Alt-P> key
* Entry : None. Callable from outside this module.
* Exit : Returns '0' if operation is successful, else '1'.
* Description:
* Complete RETRO operation is performed.
* Tagname is prompted for on the message line and input on the
* command line.
* Note : This macro is assigned by default to the <Alt-P> keystroke. You may
* reset this to any key you wish.
* Initialize global variables
'macro _init'
* Make sure the message line is active
'preserve'
'msgmode on'
* Prompt the user for a tagname
'msg Enter tagname on command line'
'readv cmdline'
* Restore original message mode
'restore'
* If empty string was entered, abort
if readv.1 = '' then exit 1
* Append a blank to the tagname
tagname = readv.1 || ' '
* Perform retrieval operation
'macro _pctags_main' tagname
* Return appropriate value
'editv get pctags_return_arg'
if pctags_return_arg = 'SUCCESSFUL' then
* Successful retrieval operation
exit 0
else
* Failed operation
* Put cursor into file area
if command() then
'cursor home'
exit 1
* pctags_prompt
****************************************
:_delimiter
* Macro : _delimiter
* Syntax: 'macro _delimiter' ch
* Entry : ch is a single-character string
* Exit : If ch is a word delimiter (i.e. NOT an alphanumeric, underscore or
* period character) then return '1', else return '0'.
* Get argument
ch = arg( 1 )
* Check if delimiter
if ( ( datatype( ch, 'a' ) = '1' ) | ( ch = '_' ) | ( ch = '.' ) ) then do
* No, it is not a delimiter
exit 0
end
* Yes, it is a delimiter
exit 1
* _delimiter
****************************************
:_convert_slashes
* Macro : _convert_slashes
* Syntax: 'macro _convert_slashes' str
* Entry : str is a complete file specification which may use slashes as path
* separators.
* Exit : All slash characters are converted to backslashes. Converted string
* is returned in the global variable pctags_return_arg.
* Get argument
str = arg( 1 )
* Convert all slashes to backslashes
do forever
* Look for a slash
i = pos( '/', str )
* Convert slash to backslash
if i <> 0 then
str = substr( str, 1, i - 1 ) || '\' || substr( str, i + 1 )
else
leave
end
* Return converted string
'editv set pctags_return_arg' str
* _convert_slashes
****************************************
:_dos_shell
* Macro : _dos_shell
* Syntax: 'macro _dos_shell' file_spec
* Entry : file_spec is the name of the file the RETROEXEC environment variable
* command is supposed to make available
* Global variable pctags_env_retroexec contains the command line to
* execute. It may contain special parameters documented below.
* Case of the special parameters is significant. It may also contain
* the DOS standard output redirection characters > or >>, but the
* command must then be bracketed with double quotes. The quotes will
* be removed before sending the command line to DOS.
* Exit : The command will have been executed. No return value is sent back.
* Special command line parameters:
* %s - entire file specification of desired file (file_spec parm)
* %d - drive of desired file
* %p - path (no drive) of desired file (no terminating backslash)
* %f - filename of desired file
* %c - current directory (in drive:path format suitable for CD'ing)
* %u - user-defined substitution string
* %% - single %
* Get arguments
cmd_line = arg( 1 )
'editv get pctags_file_spec'
* If command line is bracketed by double quotes, remove them
if (substr( cmd_line, 1, 1 ) = '"') & (substr( cmd_line, length( cmd_line ), 1 ) = '"') then
cmd_line = substr( cmd_line, 2, length( cmd_line ) - 2 )
* Create special parameter strings
* Get drive:path
path_separator = pos( '\', pctags_file_spec )
do forever
* If no more path separators found, exit do-loop
if path_separator = '0' then leave
* Save position of found path separator
last_path_separator = path_separator
* Look for another separator
path_separator = pos( '\', pctags_file_spec, path_separator + 1 )
end
* Save start of file name
fname_start = last_path_separator + 1
* If not in root, don't count last backslash
if last_path_separator <> '3' then
last_path_separator = last_path_separator - 1
* Break drive:path into separate strings (%d and %p special parms)
drive = substr( pctags_file_spec, 1, 2 )
path = substr( pctags_file_spec, 3, last_path_separator - 2 )
* Get filename only (%f special parm)
fname = substr( pctags_file_spec, fname_start )
* Get current directory
curr_dir = directory.1()
* Parse command line, replacing special parameters
sub = pos( '%', cmd_line )
do forever
* Was a special parameter found?
if sub = '0' then leave
* Get the character after '%'
parm = substr( cmd_line, sub + 1, 1 )
* Interpret substitution character
sub_str = ''
if parm = 's' then
* Entire file specification of desired file
sub_str = pctags_file_spec
if parm = 'd' then
* Drive of desired file
sub_str = drive
if parm = 'p' then
* Path (no drive) of desired file
sub_str = path
if parm = 'f' then
* Filename of desired file
sub_str = fname
if parm = 'c' then
* Current directory
sub_str = curr_dir
if parm = 'u' then do
* User-defined substitution string
'msg Enter substitution string on command line'
'readv cmdline'
sub_str = readv.1
end
if parm = '%' then
* Single percent sign
sub_str = '%'
* Replace special parameter with substitution string
cmd_line = substr( cmd_line, 1, sub - 1 ) || sub_str || substr( cmd_line, sub + 2 )
* Look for any more special parameters
sub = pos( '%', cmd_line, sub + 1 )
end
* Send command line to secondary command processor for execution
* Note: If you prefer, you may change this to a 'dosnowait' call
'dosquiet' cmd_line
* Remove any output displayed onscreen during execution
'refresh'
* _dos_shell
****************************************
:_find_first
* Macro : _find_first
* Syntax: 'macro _find_first' file_spec
* Entry : file_spec is a file specification of the tagfile(s) which to search.
* It may contain wildcard characters.
* Exit : Global variable pctags_return_arg is set to the complete file
* specification of the first existing tagfile which to search. If
* the returned string is empty then there are no existing files
* that match the input file_spec.
* Note : This macro creates a DIR.DIR file. This file still exists when the
* macro exits and must be closed either by subsequent calls to this
* macro or by _pctags_main when a matching tagname is found.
* All the necessary checking to verify that the file can be created
* (i.e. the maximum number of files are not already open) is
* performed. If the DIR.DIR file cannot be created because there is
* no room for it in the ring, the global variable pctags_return_arg
* is set to a value of NO_ROOM_IN_RING. The calling macro must handle
* this appropriately.
* If a DIR.DIR file was not created because there were no matching file,
* an empty, dummy DIR.DIR is created. This macro will always exit
* with a DIR.DIR file existing unless there is no room in the ring to
* hold it.
* If a DIR.DIR file already exists when this macro is called, it will be
* erased.
* Get argument
file_spec = arg( 1 )
* Try to create DIR.DIR file
'nomsg dir' file_spec
* See if any matches exist
if rc <> 0 then do
* No matches, see if DIR.DIR was created
if rc = 95 | rc = 100 then do
* Ran out of file space, DIR.DIR not created
* Return NO_ROOM_IN_RING
'editv set pctags_return_arg NO_ROOM_IN_RING'
exit
end
* DIR.DIR not created because no matches exist, create dummy
* file and move to the end of it
'nomsg kedit dir.dir (new noprofile'
'locate 1'
* Return empty string
'editv set pctags_return_arg '
exit
end
* DIR.DIR created, move from the top line to the first file line
'locate 1'
* Return the complete fileid on this line
'editv set pctags_return_arg' dirfileid.1()
* _find_first
****************************************
:_find_next
* Macro : _find_next
* Syntax: 'macro _find_next'
* Entry : None.
* Exit : Global variable pctags_return_arg is set to the complete file
* specification of the next file matching the file_spec passed to
* the _find_first macro. If there are no more matching files then
* an empty string is returned.
* This macro depends upon the DIR.DIR file being set by a previous call
* to _find_first.
* The DIR.DIR file will still exist upon exit from this macro, even if
* the end of the matching-file list was reached.
* Make sure we're not already at the bottom of the list
if eof() then do
* Return empty string
* Note: This code should never be executed because the end-of-
* the-list condition will have been found on a previous call.
'editv set pctags_return_arg '
exit
end
* Move down to next line in matching-file list
'locate 1'
* Return the complete fileid on this line
* Note: If we've reached to end-of-file line then the fileid should
* be empty
'editv set pctags_return_arg' dirfileid.1()
* _find_next
****************************************
:_get_tagfile
* Macro : _get_tagfile
* Syntax: 'macro _get_tagfile'
* Entry : None.
* Exit : Global variable pctags_return_arg is set to the complete file
* specification of the next tagfile to search. The tagfile is
* guaranteed to exist. If the returned string is empty then there
* are no more tagfiles to search.
* If this is the first call to this macro in this RETRO invocation,
* get the RETRO environment variable setting, if any
'editv get pctags_first_call'
if pctags_first_call = '0' then do
* Get next matching file spec, if any
'macro _find_next'
'editv get pctags_return_arg'
file_spec = pctags_return_arg
end; else do
* Go thru this code once per RETRO invocation
'editv set pctags_first_call 0'
* Get RETRO environment variable
file_spec = dosenv( 'RETRO' )
if file_spec = '' then do
* No such variable, use the default
file_spec = '*.tag'
end
* Convert any slash path separators to backslashes
'macro _convert_slashes' file_spec
'editv get pctags_return_arg'
file_spec = pctags_return_arg
* Parse any multiple file specs into single spec, may contain
* wildcard characters
'macro _parse_file_spec' file_spec
'editv get pctags_return_arg'
file_spec = pctags_return_arg
* Find the first matching file
'macro _find_first' file_spec
'editv get pctags_return_arg'
file_spec = pctags_return_arg
end
* Check if we have a tagfile name to search
do forever
if file_spec <> '' then
* We have a file spec, use it
leave
* Are there more file specs in pctags_env_tagfiles?
'editv get pctags_env_tagfiles'
if pctags_env_tagfiles = '' then
* No more tagfiles to search, return empty string
leave
* Get the next tagfile spec, may contain wildcards
'macro _parse_file_spec' pctags_env_tagfiles
'editv get pctags_return_arg'
file_spec = pctags_return_arg
* Find the first matching file
'macro _find_first' file_spec
'editv get pctags_return_arg'
file_spec = pctags_return_arg
end
* Verify that the _find_first macro was able to do its job
if file_spec = 'NO_ROOM_IN_RING' then do
* Maximum number of files is already open
'emsg Cannot open any more files'
'editv set pctags_return_arg UNSUCCESSFUL'
exit
end
* Set return string
'editv set pctags_return_arg' file_spec
* _get_tagfile
****************************************
:_parse_file_spec
* Macro : _parse_file_spec
* Syntax: 'macro _parse_file_spec' file_spec
* Entry : file_spec is a file specification to parse. May contain wildcards.
* May also contain multiple specs, each separated by a semicolon.
* Exit : The first file spec is returned in the pctags_return_arg global
* variable. All subsequent file specs, if any, are stored in the
* global variable pctags_env_tagfiles.
* Get argument
file_spec = arg( 1 )
* Does file_spec contain multiple specs?
semicolon = pos( ';', file_spec )
if semicolon = 0 then
* No, file_spec contains one drive:path\filename
* Clear pctags_env_tagfiles
'editv set pctags_env_tagfiles' ''
else do
* Yes, store subsequent specs in pctags_env_tagfiles
'editv set pctags_env_tagfiles' substr( file_spec, semicolon + 1 )
* Truncate subsequent specs from file_spec
file_spec = substr( file_spec, 1, semicolon - 1 )
end
* Return single file spec
'editv set pctags_return_arg' file_spec
* _parse_file_spec
****************************************
:_file_loaded
* Macro : _file_loaded
* Syntax: 'macro _file_loaded' file_spec
* Entry : file_spec is a complete file specification
* Exit : Global variable RC is set to '1' if file_spec is already loaded
* into a KEDIT buffer. Otherwise it is set to '0'.
* If file is found to be loaded, it is made the current file.
* Get argument
file_spec = arg( 1 )
* Save the current fileid in case we have to return to it
org_fileid = fileid.1()
* Try to make file_spec the current file
'nomsg kedit' file_spec '(new noprofile'
* Did file exist in the ring?
if size.1() = '0' then do
* No, delete empty file
'quit'
* Return to original file
'nomsg kedit' org_fileid '(new noprofile'
* Return 'not-loaded' value
exit 0
end
* File DID exist in ring, leave it as the current file
* Return 'already-loaded' value
exit 1
* _file_loaded
****************************************
:_save_dir_file
* Macro : _save_dir_file
* Syntax: 'macro _save_dir_file'
* Entry : None.
* Exit : If a DIR.DIR file exists in the ring, it is renamed to RETRO@@@.DIR.
* The current fileid upon entry to this macro remains unchanged upon
* exit.
* Note : Renaming the DIR.DIR file is necessary in order to preserve it through
* the RETRO macro. RETRO creates several of its own DIR.DIR files
* which would overwrite any previously existing one. It is necessary
* to rename the RETRO@@@.DIR file back to DIR.DIR before completing
* the RETRO operation.
* Cycle thru ring of open files, searching for a DIR.DIR fileid
* Note: Always complete cycle, even after a DIR.DIR is found, so that
* we will return to the original file upon exit
do i = 1 to nbfile.1()
* Compare this fileid to DIR.DIR
if upper( fname.1() ) = 'DIR' & upper( fext.1() ) = 'DIR' then do
* Rename file name to RETRO@@@.DIR
'set fname RETRO@@@'
end
* Advance to next file in ring
'nomsg kedit'
end
* _save_dir_file
****************************************
:_restore_dir
* Macro : _restore_dir
* Syntax: 'macro _restore_dir'
* Entry : None.
* Exit : If a file called RETRO@@@.DIR exists in the ring of open files, it
* is renamed to DIR.DIR.
* Note : It is assumed that the RETRO@@@.DIR file was created by the macro
* _save_dir_file and did not exist when the RETRO operation began.
* Cycle thru the ring of open files, searching for a RETRO@@@.DIR fileid
* Note: Always complete the cycle, even after RETRO@@@.DIR is found, so
* that we will return to the original file upon exit
do i = 1 to nbfile.1()
* Compare this fileid to RETRO@@@.DIR
if upper( fname.1() ) = 'RETRO@@@' & upper( fext.1() ) = 'DIR' then do
* Rename file name to DIR.DIR
'set fname DIR'
end
* Advance to next file in ring
'nomsg kedit'
end
* _restore_dir
****************************************
:_init_file
* Macro : _init_file
* Syntax: 'macro _init_file'
* Entry : None.
* Exit : Editor settings for the current file which would affect the outcome
* of our search are set so the search may succeed.
* Set our own editor settings
'arbchar off'
'hex off'
'scope all'
'stay on'
'varblank off'
'wordwrap off'
'wrap on'
'zone 1 *'
* _init_file
****************************************
* Note: This descriptive section cannot be placed after the _pctags_main
* header because it would cause the macro to exceed the maximum macro
* length of 250 lines.
*
* Detailed Description:
* The main RETRO operation is performed. This entails the following
* operations:
* -- Cycle through all required tagfiles. Default = *.tag or all
* tagfiles specified in RETRO environment variable which may
* contain multiple file specs, each with wildcards, separated
* by semicolons. For example,
* SET RETRO=c:\kedit\tagfiles\*.tag;c:\prog\*.tag
* -- Search each tagfile for the function_name string.
* -- If not found in any tagfile, display message and quit.
* -- If found, get name of file and definition file from tagfile.
* -- Close tagfile.
* -- Load file for editing.
* -- If file cannot be found, tag info contains EXEC command and
* environment variable RETROEXEC is defined, execute the
* command-line value assigned to it. Try to load the file
* again.
* -- If file still cannot be found, display message and quit.
* -- Search file for definition line.
* -- If any of these operations fail, display appropriate error
* message and quit.
:_pctags_main
* Macro : _pctags_main
* Syntax: 'macro _pctags_main' function_name
* Entry : function_name is the tagname we are searching for. A single blank
* character should be appended to its end.
* Exit : Global variable pctags_return_arg is set to SUCCESSFUL if the
* retrieval operation succeeds. Otherwise, it is set to UNSUCCESSFUL.
* Description:
* Main RETRO operation is performed.
* Get argument
function_name = arg( 1 )
* Create search-string (surround with @ characters)
search_tag = '@' || function_name || '@'
* If a DIR.DIR file already exists, temporarily rename it
'macro _save_dir_file'
* Cycle through all RETRO (or default) tagfiles until done or match found
do forever
* Get a tagfile
'macro _get_tagfile'
'editv get pctags_return_arg'
tagfile_name = pctags_return_arg
* If the maximum number of files are already open, quit
* Note: Error handling was done in _get_tagfile
if tagfile_name = 'UNSUCCESSFUL' then do
'macro _restore_dir'
exit
end
* If no more tagfiles to get, quit
if tagfile_name = '' then do
* Tagname not found in tagfiles
* Dump DIR.DIR file and terminate operation
'quit'
'emsg 'function_name'not found.'
'macro _restore_dir'
'editv set pctags_return_arg UNSUCCESSFUL'
exit
end
* Tagfile is guaranteed to exist so just try to load it
'nomsg kedit' tagfile_name '(noprofile nodefext'
* Verify that there was room in the ring for the tagfile
if rc <> 0 then do
* See if we ran out of file space
if rc = 95 | rc = 100 then
* Yes, max number of files already open
'emsg Cannot open any more files'
else
* Could not load tagfile for some other reason
'emsg Could not load tagfile' tagfile_name
* Dump DIR.DIR file and terminate operation
'quit'
'macro _restore_dir'
'editv set pctags_return_arg UNSUCCESSFUL'
exit
end
* Initialize tagfile
'macro _init_file'
'top'
* Set appropriate case-sensitivity for tagname search
'editv get pctags_tagname_case'
if pctags_tagname_case = 'CASE_SENSITIVE' then
'case' case.1() 'respect'
else
'case' case.1() 'ignore'
* Search tagfile for function_name
'nomsg tfind' search_tag
if rc <> 0 then do
* Tag not found, quit tagfile, try another
'quit'
iterate
end
* Found a good match!
* Leave tagfile-loop
leave
end
* Found a tagfile match
* Read tagfile line
line = curline.3()
* Done with tagfile, close it
'quit'
* Dump DIR.DIR file used for finding matching tagfile specs
'quit'
* Format of line:
* Column 1: Function name searching for (variable length)
* Single space terminator
* Optional RETRO commands (! and #)
* Complete file specification of file containing definition
* of function (variable length)
* Single space terminator
* Caret(^) character signifying the start of the definition line
* Line from file that defines the function or the line number in
* the file
* As an example:
* "function c:\dir\file.c ^int function( arg1, arg2 )"
* Determine starting indices of file spec and definition line
file_start = pos( ' ', line ) + 1
decl_start = pos( ' ', line, file_start ) + 2
* Extract file spec and definition line
file_spec = substr( line, file_start, decl_start - file_start - 2 )
decl_line = substr( line, decl_start )
* Check file spec for leading command characters
exec_env = '0'
line_number = '0'
special_chars = '1'
do forever
* Get a potential command char
ch = substr( file_spec, special_chars, 1 )
if ch = '!' then do
* If file_spec not found, execute RETROEXEC
* environment variable command line.
exec_env = '1'
* Increment index
special_chars = special_chars + 1
end;
if ch = '#' then do
* Line number of definition is stored in tagfile
* instead of line contents (99)
line_number = '1'
special_chars = special_chars + 1
end
if (ch <> '!') & (ch <> '#') then
* Exit loop
leave
end
* Remove all leading command chars from file spec
file_spec = substr( file_spec, special_chars )
* Save current fileid in case we have to return to it
original_fileid = fileid.1()
* See if file is already loaded, make it current if it is
'macro _file_loaded' file_spec
file_already_loaded = rc
* If file is not already loaded, verify that it exists
if file_already_loaded = '0' then do
* See if file exists
'nomsg dir' file_spec
if rc = 0 then
* File exists, dump DIR.DIR file
'quit'
else do
* File not found, should we run RETROEXEC?
if exec_env = '1' then do
* Yes, is RETROEXEC defined?
retroexec_env = dosenv( 'RETROEXEC' )
if retroexec_env <> '' then do
* Execute the variable's value
'editv set pctags_file_spec' file_spec
'macro _dos_shell' retroexec_env
end
end
* Does file exist now?
'nomsg dir' file_spec
if rc = 0 then
* Yes, dump DIR.DIR
'quit'
else do
* No, file is still not available
'emsg' file_spec 'does not exist. Update tagfile.'
* Nothing more we can do, return FAILURE code
'macro _restore_dir'
'editv set pctags_return_arg UNSUCCESSFUL'
exit
end
end
* Load source file (should never fail)
'nomsg kedit' file_spec '(nodefext'
end
* Turn on msgline (assumes PROFILE.KEX does not set msgmode off) and
* initialize file so our search will succeed, preserving original
* settings
'msgmode on'
'preserve'
'macro _init_file'
* Restore any original DIR.DIR file
'macro _restore_dir'
* Searching for line contents or line number?
if line_number = '1' then do
* Goto specified line number in source file
':' || decl_line
end; else do
* Search for definition line
* Do not ignore case in search
'case' case.1() 'respect'
* Surround definition string with @ characters
decl_line = '@' || decl_line || '@'
* Do search operation
'nomsg tfind' decl_line
if rc <> 0 then do
* Definition line not found in source file
'restore'
* If file was loaded from disk, delete it
if file_already_loaded = '0' then
'quit'
else
* File was already loaded, go back to original fileid
'nomsg kedit' original_fileid '(new noprofile'
* Tell user what's going on
'emsg Update' tagfile_name 'with' file_spec
'editv set pctags_return_arg UNSUCCESSFUL'
exit
end
end
* Found function definition!
* Set SUCCESS return value
'restore'
'sos current'
'sos firstcol'
'editv set pctags_return_arg SUCCESSFUL'
exit
* _pctags_main
****************************************