use btree instead of hashing, don't have to resort later
[unix-history] / usr / src / usr.bin / ctags / ctags.1
CommitLineData
b5dc1377 1.\" Copyright (c) 1987, 1990 The Regents of the University of California.
083e16be 2.\" All rights reserved.
cab8f024 3.\"
a7edb52c 4.\" %sccs.include.redist.roff%
083e16be 5.\"
5237c2bf 6.\" @(#)ctags.1 6.8 (Berkeley) %G%
cab8f024 7.\"
b5dc1377
CL
8.Dd
9.Dt CTAGS 1
10.Os BSD 4
11.Sh NAME
12.Nm ctags
13.Nd create a tags file
14.Sh SYNOPSIS
15.Nm ctags
16.Op Fl BFadtuwvx
17.Op Fl f Ar tagsfile
18.Ar name ...
19.Sh DESCRIPTION
20.Nm Ctags
21makes a tags file for
22.Xr ex 1
23from the specified C,
a7edb52c
CL
24Pascal, Fortran,
25.Tn YACC ,
26lex, and lisp sources. A tags file gives the
8c5e71ad
KB
27locations of specified objects in a group of files. Each line of the
28tags file contains the object name, the file in which it is defined,
29and a search pattern for the object definition, separated by white-space.
b5dc1377
CL
30Using the
31.Ar tags
32file,
33.Xr ex 1
34can quickly locate these object
5325ced3
CL
35definitions. Depending on the options provided to
36.Nm ctags ,
8c5e71ad
KB
37objects will consist of subroutines, typedefs, defines, structs,
38enums and unions.
a7edb52c
CL
39.Bl -tag -width Ds
40.It Fl B
41use backward searching patterns
42.Pq Li ?...? .
43.It Fl F
44use forward searching patterns
45.Pq Li /.../
46(the default).
47.It Fl a
b5dc1377
CL
48append to
49.Ar tags
50file.
a7edb52c 51.It Fl d
b5dc1377 52create tags for
5325ced3 53.Li #defines
b5dc1377 54that don't take arguments;
5325ced3 55.Li #defines
8c5e71ad 56that take arguments are tagged automatically.
a7edb52c
CL
57.It Fl f
58Places the tag descriptions in a file called
59.Ar tagsfile .
60The default behaviour is to place them in a file
61.Ar tags .
62.It Fl t
8c5e71ad 63create tags for typedefs, structs, unions, and enums.
a7edb52c 64.It Fl u
b5dc1377
CL
65update the specified files in the
66.Ar tags
67file, that is, all
8c5e71ad
KB
68references to them are deleted, and the new values are appended to the
69file. (Beware: this option is implemented in a way which is rather
b5dc1377
CL
70slow; it is usually faster to simply rebuild the
71.Ar tags
72file.)
a7edb52c
CL
73.It Fl v
74An index of the form expected by
75.Xr vgrind 1
76is produced on the standard output. This listing
77contains the object name, file name, and page number (assuming 64
78line pages). Since the output will be sorted into lexicographic order,
79it may be desired to run the output through
80.Xr sort 1 .
81Sample use:
82.Bd -literal -offset indent
83ctags \-v files \&| sort \-f > index
84vgrind \-x index
85.Ed
86.It Fl w
87suppress warning diagnostics.
88.It Fl x
89.Nm ctags
90produces a list of object
91names, the line number and file name on which each is defined, as well
92as the text of that line and prints this on the standard output. This
93is a simple index which can be printed out as an off-line readable
94function index.
95.El
b5dc1377
CL
96.Pp
97Files whose names end in
98.Nm \&.c
99or
100.Nm \&.h
101are assumed to be C
102source files and are searched for C style routine and macro definitions.
103Files whose names end in
104.Nm \&.y
a7edb52c
CL
105are assumed to be
106.Tn YACC
107source files.
b5dc1377
CL
108Files whose names end in
109.Nm \&.l
110are assumed to be lisp files if their
111first non-blank character is `;', `(', or `[',
112otherwise, they are
113treated as lex files. Other files are first examined to see if they
114contain any Pascal or Fortran routine definitions, and, if not, are
115searched for C style definitions.
116.Pp
117The tag
5325ced3 118.Li main
b5dc1377
CL
119is treated specially in C programs. The tag formed
120is created by prepending
121.Ar M
122to the name of the file, with the
123trailing
124.Nm \&.c
125and any leading pathname components removed. This
126makes use of
127.Nm ctags
128practical in directories with more than one
8c5e71ad 129program.
b5dc1377
CL
130.Pp
131Yacc and lex files each have a special tag.
132.Ar Yyparse
133is the start
134of the second section of the yacc file, and
135.Ar yylex
136is the start of
137the second section of the lex file.
138.Sh FILES
a7edb52c
CL
139.Bl -tag -width tags -compact
140.It Pa tags
b5dc1377 141default output tags file
a7edb52c 142.El
b5dc1377
CL
143.Sh DIAGNOSTICS
144.Nm Ctags
145exits with a value of 1 if an error occurred, where
28048a77 146duplicate objects are not considered errors, 0 otherwise.
b5dc1377
CL
147.Sh SEE ALSO
148.Xr ex 1 ,
149.Xr vi 1
b5dc1377
CL
150.Sh BUGS
151Recognition of
152.Nm functions ,
153.Nm subroutines
154and
155.Nm procedures
a7edb52c
CL
156for
157.Tn FORTRAN
158and Pascal is done is a very simpleminded way. No attempt
8c5e71ad 159is made to deal with block structure; if you have two Pascal procedures
b5dc1377
CL
160in different blocks with the same name you lose.
161.Nm Ctags
162doesn't
8c5e71ad 163understand about Pascal types.
b5dc1377 164.Pp
a7edb52c
CL
165The method of deciding whether to look for C, Pascal or
166.Tn FORTRAN
cab8f024 167functions is a hack.
b5dc1377
CL
168.Pp
169.Nm Ctags
170relies on the input being well formed, and any syntactical
8c5e71ad 171errors will completely confuse it. It also finds some legal syntax
b5dc1377 172confusing; for example, as it doesn't understand
a7edb52c 173.Li #ifdef Ns 's ,
8c5e71ad 174(incidentally, that's a feature, not a bug) any code with unbalanced
b5dc1377 175braces inside
a7edb52c 176.Li #ifdef Ns 's
b5dc1377 177will cause it to become somewhat disoriented.
8c5e71ad
KB
178In a similar fashion, multiple line changes within a definition will
179cause it to enter the last line of the object, rather than the first, as
b5dc1377 180the searching pattern. The last line of multiple line
a7edb52c 181.Li typedef Ns 's
8c5e71ad 182will similarly be noted.
a7edb52c
CL
183.Sh HISTORY
184The
185.Nm
186command appeared in
187.Bx 3.0 .