Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ ctags(1) — Duplix 4.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

ex(1)

vi(1)

CTAGS(1)  —  Unix Programmer’s Manual

NAME

ctags − create a tags file

SYNOPSIS

ctags [ options ] [ −f tagsfile ] name ... 

DESCRIPTION

Ctags generates a tags file for ex(1) from the specified C, Pascal, Fortran, YACC, lex, and lisp sources.  A tags file lists the locations of specified objects (in this case functions and typedefs) in a group of files.  Each line of the tags file contains an object name, the name of the file in which the object is defined, and an address specification for the object definition.  Functions are searched with a pattern, typedefs with a line number.  Specifiers are given in separate fields on the line, separated by blanks or tabs.  Using the tags file, ex can quickly find these objects definitions. 

Normally ctags places the tag descriptions in a file called tags.  You can use the -f option to specify a different filename if you wish.  See the description of ctag options below. 

ctags reads the names and contents of files to determine in which programming language their text is written.  Files whose names end in .c or .h are assumed to be C source files.  ctags searches them for C routine and macro definitions.  Files whose names end in .y are assumed to be YACC source files.  Files whose names end in .l and whose first non-blank character is ‘;’, ‘(’, or ‘[’ are assumed to be lisp files.  Other files whose names end in .l are assumed to be lex files.  If a filename does not end in one of these suffixes, ctags searches the file for Pascal and Fortran routine definitions.  If it finds neither, it searchs the file for C routine definitions. 

The tag main is treated specially in C programs.  The tag formed is created by prepending M to the name of the file, with a trailing .c removed, if any, and leading pathname components also removed.  This makes use of ctags practical in directories with more than one program. 

OPTIONS

−a Appends to tags file. 

−B Uses backward searching patterns (?...?). 

−f filename
Instructs ctags to place the tag descriptions in the named file rather than in the default file, tags. 

−F Uses forward searching patterns (/.../) (default). 

−t Creates tags for typedefs. 

−u Causes the specified files to be updated in tags—that is, ctags deletes old references to the files and appends new values to the tags file.  (Beware: this option is implemented in a way which is slow.  It is usually faster to simply rebuild the tags file.) 

−v Produces an index of the form expected by vgrind(1) on the standard output.  This listing contains function name, filename, and page number (assuming 64 line pages).  Since the output will be sorted into lexicographic order, it may be desired to run the output through sort −f.  Sample use:

ctags −v files | sort −f > index
vgrind −x index

−w Suppresses warning diagnostics. 

−x Prints on the standard output an index listing object names, the line numbers of lines on which objects are defined, the files in which objects are defined, and the text of the lines defining objects.  This index can be printed out as a readable, off-line function index. 

FILES

tagsoutput tags file

SEE ALSO

ex(1), vi(1)

AUTHOR

Ken Arnold; FORTRAN added by Jim Kleckner; Bill Joy added Pascal and −x, replacing cxref; C typedefs added by Ed Pelegri-Llopart. 

BUGS

Recognition of functions, subroutines and procedures for FORTRAN and Pascal is done is a very simpleminded way.  No attempt is made to deal with block structure; if you have two Pascal procedures in different blocks with the same name you lose. 

The method of deciding whether to look for C or Pascal and FORTRAN functions is a hack. 

Does not know about #ifdefs. 

Should know about Pascal types. 

Relies on the input being well formed to detect typedefs. 

Use of −tx shows only the last line of typedefs. 
 

4th Berkeley Distribution  —  April 11, 1988

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026