Annotation of src/usr.bin/ctags/ctags.1, Revision 1.11
1.11 ! mpech 1: .\" $OpenBSD: ctags.1,v 1.10 2000/11/10 05:10:23 aaron Exp $
1.1 deraadt 2: .\" $NetBSD: ctags.1,v 1.4 1995/03/26 20:14:04 glass Exp $
3: .\"
4: .\" Copyright (c) 1987, 1990, 1993
5: .\" The Regents of the University of California. All rights reserved.
6: .\"
7: .\" Redistribution and use in source and binary forms, with or without
8: .\" modification, are permitted provided that the following conditions
9: .\" are met:
10: .\" 1. Redistributions of source code must retain the above copyright
11: .\" notice, this list of conditions and the following disclaimer.
12: .\" 2. Redistributions in binary form must reproduce the above copyright
13: .\" notice, this list of conditions and the following disclaimer in the
14: .\" documentation and/or other materials provided with the distribution.
15: .\" 3. All advertising materials mentioning features or use of this software
16: .\" must display the following acknowledgement:
17: .\" This product includes software developed by the University of
18: .\" California, Berkeley and its contributors.
19: .\" 4. Neither the name of the University nor the names of its contributors
20: .\" may be used to endorse or promote products derived from this software
21: .\" without specific prior written permission.
22: .\"
23: .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24: .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25: .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26: .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27: .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28: .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29: .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30: .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31: .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32: .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33: .\" SUCH DAMAGE.
34: .\"
35: .\" @(#)ctags.1 8.1 (Berkeley) 6/6/93
36: .\"
37: .Dd June 6, 1993
38: .Dt CTAGS 1
1.5 aaron 39: .Os
1.1 deraadt 40: .Sh NAME
41: .Nm ctags
42: .Nd create a tags file
43: .Sh SYNOPSIS
44: .Nm ctags
45: .Op Fl BFadtuwvx
46: .Op Fl f Ar tagsfile
47: .Ar name ...
48: .Sh DESCRIPTION
1.6 aaron 49: .Nm
1.1 deraadt 50: makes a tags file for
51: .Xr ex 1
52: from the specified C,
53: Pascal, Fortran,
54: .Tn YACC ,
55: lex, and lisp sources.
56: A tags file gives the locations of specified objects in a group of files.
57: Each line of the tags file contains the object name, the file in which it
58: is defined, and a search pattern for the object definition, separated by
1.8 aaron 59: whitespace.
1.9 aaron 60: .Pp
1.1 deraadt 61: Using the
62: .Ar tags
63: file,
64: .Xr ex 1
65: can quickly locate these object definitions.
66: Depending upon the options provided to
67: .Nm ctags ,
68: objects will consist of subroutines, typedefs, defines, structs,
1.3 aaron 69: enums, and unions.
1.9 aaron 70: .Pp
71: The options are as follows:
1.1 deraadt 72: .Bl -tag -width Ds
73: .It Fl B
1.3 aaron 74: Use backward searching patterns
1.1 deraadt 75: .Pq Li ?...? .
76: .It Fl F
1.3 aaron 77: Use forward searching patterns
1.1 deraadt 78: .Pq Li /.../
79: (the default).
80: .It Fl a
1.3 aaron 81: Append to
1.1 deraadt 82: .Ar tags
83: file.
84: .It Fl d
1.3 aaron 85: Create tags for
1.1 deraadt 86: .Li #defines
87: that don't take arguments;
88: .Li #defines
89: that take arguments are tagged automatically.
1.7 deraadt 90: .It Fl f Ar tagsfile
1.1 deraadt 91: Places the tag descriptions in a file called
92: .Ar tagsfile .
93: The default behaviour is to place them in a file called
94: .Ar tags .
95: .It Fl t
1.3 aaron 96: Create tags for typedefs, structs, unions, and enums.
1.1 deraadt 97: .It Fl u
1.3 aaron 98: Update the specified files in the
1.1 deraadt 99: .Ar tags
100: file, that is, all
101: references to them are deleted, and the new values are appended to the
1.9 aaron 102: file.
103: (Beware: this option is implemented in a way which is rather
1.1 deraadt 104: slow; it is usually faster to simply rebuild the
105: .Ar tags
106: file.)
107: .It Fl v
108: An index of the form expected by
109: .Xr vgrind 1
1.9 aaron 110: is produced on the standard output.
111: This listing contains the object name, file name, and page number (assuming
112: 64 line pages).
113: Since the output will be sorted into lexicographic order,
1.1 deraadt 114: it may be desired to run the output through
115: .Xr sort 1 .
116: Sample use:
117: .Bd -literal -offset indent
1.11 ! mpech 118: $ ctags \-v files \&| sort \-f > index
! 119: $ vgrind \-x index
1.1 deraadt 120: .Ed
121: .It Fl w
1.3 aaron 122: Suppress warning diagnostics.
1.1 deraadt 123: .It Fl x
1.6 aaron 124: .Nm
1.1 deraadt 125: produces a list of object
126: names, the line number and file name on which each is defined, as well
1.9 aaron 127: as the text of that line and prints this on the standard output.
128: This is a simple index which can be printed out as an off-line readable
1.1 deraadt 129: function index.
130: .El
131: .Pp
132: Files whose names end in
1.9 aaron 133: .Dq \&.c
1.1 deraadt 134: or
1.9 aaron 135: .Dq \&.h
1.1 deraadt 136: are assumed to be C
137: source files and are searched for C style routine and macro definitions.
138: Files whose names end in
1.9 aaron 139: .Dq \&.y
1.1 deraadt 140: are assumed to be
141: .Tn YACC
142: source files.
143: Files whose names end in
1.9 aaron 144: .Dq \&.l
1.1 deraadt 145: are assumed to be lisp files if their
1.9 aaron 146: first non-blank character is
147: .Ql \&; ,
148: .Ql ( ,
149: or
150: .Ql [ ,
1.1 deraadt 151: otherwise, they are
1.9 aaron 152: treated as lex files.
153: Other files are first examined to see if they
1.1 deraadt 154: contain any Pascal or Fortran routine definitions, and, if not, are
155: searched for C style definitions.
156: .Pp
157: The tag
158: .Li main
1.9 aaron 159: is treated specially in C programs.
160: The tag formed is created by prepending
161: .Sq M
1.1 deraadt 162: to the name of the file, with the
163: trailing
1.9 aaron 164: .Dq \&.c
165: and any leading pathname components removed.
166: This makes use of
1.6 aaron 167: .Nm
1.9 aaron 168: practical in directories with more than one program.
1.1 deraadt 169: .Pp
170: Yacc and lex files each have a special tag.
171: .Ar Yyparse
172: is the start
173: of the second section of the yacc file, and
174: .Ar yylex
175: is the start of
176: the second section of the lex file.
1.10 aaron 177: .Sh DIAGNOSTICS
178: .Nm
179: exits with a value of 1 if an error occurred, 0 otherwise.
180: Duplicate objects are not considered errors.
1.1 deraadt 181: .Sh FILES
182: .Bl -tag -width tags -compact
183: .It Pa tags
184: default output tags file
185: .El
186: .Sh SEE ALSO
187: .Xr ex 1 ,
188: .Xr vi 1
1.10 aaron 189: .Sh HISTORY
190: The
191: .Nm
192: command appeared in
193: .Bx 3.0 .
1.1 deraadt 194: .Sh BUGS
195: Recognition of
1.6 aaron 196: .Nm functions ,
1.10 aaron 197: .Nm subroutines ,
1.1 deraadt 198: and
199: .Nm procedures
200: for
201: .Tn FORTRAN
1.9 aaron 202: and Pascal is done in a very simple-minded way.
203: No attempt
1.1 deraadt 204: is made to deal with block structure; if you have two Pascal procedures
205: in different blocks with the same name you lose.
1.6 aaron 206: .Nm
1.1 deraadt 207: doesn't
208: understand about Pascal types.
209: .Pp
210: The method of deciding whether to look for C, Pascal or
211: .Tn FORTRAN
212: functions is a hack.
213: .Pp
1.6 aaron 214: .Nm
1.1 deraadt 215: relies on the input being well formed, and any syntactical
1.9 aaron 216: errors will completely confuse it.
217: It also finds some legal syntax confusing; for example,
218: since it doesn't understand
1.1 deraadt 219: .Li #ifdef Ns 's
220: (incidentally, that's a feature, not a bug), any code with unbalanced
221: braces inside
222: .Li #ifdef Ns 's
223: will cause it to become somewhat disoriented.
224: In a similar fashion, multiple line changes within a definition will
225: cause it to enter the last line of the object, rather than the first, as
1.9 aaron 226: the searching pattern.
227: The last line of multiple line
1.1 deraadt 228: .Li typedef Ns 's
229: will similarly be noted.