1CTAGS(P) POSIX Programmer's Manual CTAGS(P)
2
3
4
6 ctags - create a tags file (DEVELOPMENT, FORTRAN)
7
9 ctags [-a][-f tagsfile] pathname ...
10
11 ctags -x pathname ...
12
13
15 The ctags utility shall be provided on systems that support the User
16 Portability Utilities option, the Software Development Utilities
17 option, and either or both of the C-Language Development Utilities
18 option and FORTRAN Development Utilities option. On other systems, it
19 is optional.
20
21 The ctags utility shall write a tagsfile or an index of objects from C-
22 language or FORTRAN source files specified by the pathname operands.
23 The tagsfile shall list the locators of language-specific objects
24 within the source files. A locator consists of a name, pathname, and
25 either a search pattern or a line number that can be used in searching
26 for the object definition. The objects that shall be recognized are
27 specified in the EXTENDED DESCRIPTION section.
28
30 The ctags utility shall conform to the Base Definitions volume of
31 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
32
33 The following options shall be supported:
34
35 -a Append to tagsfile.
36
37 -f tagsfile
38 Write the object locator lists into tagsfile instead of the
39 default file named tags in the current directory.
40
41 -x Produce a list of object names, the line number, and filename in
42 which each is defined, as well as the text of that line, and
43 write this to the standard output. A tagsfile shall not be cre‐
44 ated when -x is specified.
45
46
48 The following pathname operands are supported:
49
50 file.c Files with basenames ending with the .c suffix shall be treated
51 as C-language source code. Such files that are not valid input
52 to c99 produce unspecified results.
53
54 file.h Files with basenames ending with the .h suffix shall be treated
55 as C-language source code. Such files that are not valid input
56 to c99 produce unspecified results.
57
58 file.f Files with basenames ending with the .f suffix shall be treated
59 as FORTRAN-language source code. Such files that are not valid
60 input to fort77 produce unspecified results.
61
62
63 The handling of other files is implementation-defined.
64
66 See the INPUT FILES section.
67
69 The input files shall be text files containing source code in the lan‐
70 guage indicated by the operand filename suffixes.
71
73 The following environment variables shall affect the execution of
74 ctags:
75
76 LANG Provide a default value for the internationalization variables
77 that are unset or null. (See the Base Definitions volume of
78 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
79 ables for the precedence of internationalization variables used
80 to determine the values of locale categories.)
81
82 LC_ALL If set to a non-empty string value, override the values of all
83 the other internationalization variables.
84
85 LC_COLLATE
86
87 Determine the order in which output is sorted for the -x option.
88 The POSIX locale determines the order in which the tagsfile is
89 written.
90
91 LC_CTYPE
92 Determine the locale for the interpretation of sequences of
93 bytes of text data as characters (for example, single-byte as
94 opposed to multi-byte characters in arguments and input files).
95 When processing C-language source code, if the locale is not
96 compatible with the C locale described by the ISO C standard,
97 the results are unspecified.
98
99 LC_MESSAGES
100 Determine the locale that should be used to affect the format
101 and contents of diagnostic messages written to standard error.
102
103 NLSPATH
104 Determine the location of message catalogs for the processing of
105 LC_MESSAGES .
106
107
109 Default.
110
112 The list of object name information produced by the -x option shall be
113 written to standard output in the following format:
114
115
116 "%s %d %s %s", <object-name>, <line-number>, <filename>, <text>
117
118 where <text> is the text of line <line-number> of file <filename>.
119
121 The standard error shall be used only for diagnostic messages.
122
124 When the -x option is not specified, the format of the output file
125 shall be:
126
127
128 "%s\t%s\t/%s/\n", <identifier>, <filename>, <pattern>
129
130 where <pattern> is a search pattern that could be used by an editor to
131 find the defining instance of <identifier> in <filename> (where defin‐
132 ing instance is indicated by the declarations listed in the EXTENDED
133 DESCRIPTION).
134
135 An optional circumflex ( '^' ) can be added as a prefix to <pattern>,
136 and an optional dollar sign can be appended to <pattern> to indicate
137 that the pattern is anchored to the beginning (end) of a line of text.
138 Any slash or backslash characters in <pattern> shall be preceded by a
139 backslash character. The anchoring circumflex, dollar sign, and escap‐
140 ing backslash characters shall not be considered part of the search
141 pattern. All other characters in the search pattern shall be considered
142 literal characters.
143
144 An alternative format is:
145
146
147 "%s\t%s\t?%s?\n", <identifier>, <filename>, <pattern>
148
149 which is identical to the first format except that slashes in <pattern>
150 shall not be preceded by escaping backslash characters, and question
151 mark characters in <pattern> shall be preceded by backslash characters.
152
153 A second alternative format is:
154
155
156 "%s\t%s\t%d\n", <identifier>, <filename>, <lineno>
157
158 where <lineno> is a decimal line number that could be used by an editor
159 to find <identifier> in <filename>.
160
161 Neither alternative format shall be produced by ctags when it is used
162 as described by IEEE Std 1003.1-2001, but the standard utilities that
163 process tags files shall be able to process those formats as well as
164 the first format.
165
166 In any of these formats, the file shall be sorted by identifier, based
167 on the collation sequence in the POSIX locale.
168
170 If the operand identifies C-language source, the ctags utility shall
171 attempt to produce an output line for each of the following objects:
172
173 * Function definitions
174
175 * Type definitions
176
177 * Macros with arguments
178
179 It may also produce output for any of the following objects:
180
181 * Function prototypes
182
183 * Structures
184
185 * Unions
186
187 * Global variable definitions
188
189 * Enumeration types
190
191 * Macros without arguments
192
193 * #define statements
194
195 * #line statements
196
197 Any #if and #ifdef statements shall produce no output. The tag main is
198 treated specially in C programs. The tag formed shall be created by
199 prefixing M to the name of the file, with the trailing .c, and leading
200 pathname components (if any) removed.
201
202 On systems that do not support the C-Language Development Utilities
203 option, ctags produces unspecified results for C-language source code
204 files. It should write to standard error a message identifying this
205 condition and cause a non-zero exit status to be produced.
206
207 If the operand identifies FORTRAN source, the ctags utility shall pro‐
208 duce an output line for each function definition. It may also produce
209 output for any of the following objects:
210
211 * Subroutine definitions
212
213 * COMMON statements
214
215 * PARAMETER statements
216
217 * DATA and BLOCK DATA statements
218
219 * Statement numbers
220
221 On systems that do not support the FORTRAN Development Utilities
222 option, ctags produces unspecified results for FORTRAN source code
223 files. It should write to standard error a message identifying this
224 condition and cause a non-zero exit status to be produced.
225
226 It is implementation-defined what other objects (including duplicate
227 identifiers) produce output.
228
230 The following exit values shall be returned:
231
232 0 Successful completion.
233
234 >0 An error occurred.
235
236
238 Default.
239
240 The following sections are informative.
241
243 The output with -x is meant to be a simple index that can be written
244 out as an off-line readable function index. If the input files to ctags
245 (such as .c files) were not created using the same locale as that in
246 effect when ctags -x is run, results might not be as expected.
247
248 The description of C-language processing says "attempts to" because the
249 C language can be greatly confused, especially through the use of
250 #defines, and this utility would be of no use if the real C preproces‐
251 sor were run to identify them. The output from ctags may be fooled and
252 incorrect for various constructs.
253
255 None.
256
258 The option list was significantly reduced from that provided by histor‐
259 ical implementations. The -F option was omitted as redundant, since it
260 is the default. The -B option was omitted as being of very limited use‐
261 fulness. The -t option was omitted since the recognition of typedefs is
262 now required for C source files. The -u option was omitted because the
263 update function was judged to be not only inefficient, but also rarely
264 needed.
265
266 An early proposal included a -w option to suppress warning diagnostics.
267 Since the types of such diagnostics could not be described, the option
268 was omitted as being not useful.
269
270 The text for LC_CTYPE about compatibility with the C locale acknowl‐
271 edges that the ISO C standard imposes requirements on the locale used
272 to process C source. This could easily be a superset of that known as
273 "the C locale" by way of implementation extensions, or one of a few
274 alternative locales for systems supporting different codesets. No
275 statement is made for FORTRAN because the ANSI X3.9-1978 standard (FOR‐
276 TRAN 77) does not (yet) define a similar locale concept. However, a
277 general rule in this volume of IEEE Std 1003.1-2001 is that any time
278 that locales do not match (preparing a file for one locale and process‐
279 ing it in another), the results are suspect.
280
281 The collation sequence of the tags file is not affected by LC_COLLATE
282 because it is typically not used by human readers, but only by programs
283 such as vi to locate the tag within the source files. Using the POSIX
284 locale eliminates some of the problems of coordinating locales between
285 the ctags file creator and the vi file reader.
286
287 Historically, the tags file has been used only by ex and vi. However,
288 the format of the tags file has been published to encourage other pro‐
289 grams to use the tags in new ways. The format allows either patterns or
290 line numbers to find the identifiers because the historical vi recog‐
291 nizes either. The ctags utility does not produce the format using line
292 numbers because it is not useful following any source file changes that
293 add or delete lines. The documented search patterns match historical
294 practice. It should be noted that literal leading circumflex or trail‐
295 ing dollar-sign characters in the search pattern will only behave cor‐
296 rectly if anchored to the beginning of the line or end of the line by
297 an additional circumflex or dollar-sign character.
298
299 Historical implementations also understand the objects used by the lan‐
300 guages Pascal and sometimes LISP, and they understand the C source out‐
301 put by lex and yacc. The ctags utility is not required to accommodate
302 these languages, although implementors are encouraged to do so.
303
304 The following historical option was not specified, as vgrind is not
305 included in this volume of IEEE Std 1003.1-2001:
306
307 -v If the -v flag is given, an index of the form expected by vgrind
308 is produced on the standard output. This listing contains the
309 function name, filename, and page number (assuming 64-line
310 pages). Since the output is sorted into lexicographic order, it
311 may be desired to run the output through sort -f. Sample use:
312
313
314 ctags -v files | sort -f > index vgrind -x index
315
316
317 The special treatment of the tag main makes the use of ctags practical
318 in directories with more than one program.
319
321 None.
322
324 c99 , fort77 , vi
325
327 Portions of this text are reprinted and reproduced in electronic form
328 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
329 -- Portable Operating System Interface (POSIX), The Open Group Base
330 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
331 Electrical and Electronics Engineers, Inc and The Open Group. In the
332 event of any discrepancy between this version and the original IEEE and
333 The Open Group Standard, the original IEEE and The Open Group Standard
334 is the referee document. The original Standard can be obtained online
335 at http://www.opengroup.org/unix/online.html .
336
337
338
339IEEE/The Open Group 2003 CTAGS(P)