1 /* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*-
2 Copyright (C) 1984, 1987, 1988, 1989, 1993, 1994, 1995,
3 1998, 1999, 2000, 2001, 2002, 2003, 2004,
4 2005, 2006 Free Software Foundation, Inc. and Ken Arnold
6 This file is not considered part of GNU Emacs.
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software Foundation,
20 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
24 * Ctags originally by Ken Arnold.
25 * Fortran added by Jim Kleckner.
26 * Ed Pelegri-Llopart added C typedefs.
27 * Gnu Emacs TAGS format and modifications by RMS?
28 * 1989 Sam Kendall added C++.
29 * 1992 Joseph B. Wells improved C and C++ parsing.
30 * 1993 Francesco Potortì reorganised C and C++.
31 * 1994 Line-by-line regexp tags by Tom Tromey.
32 * 2001 Nested classes by Francesco Potortì (concept by Mykola Dzyuba).
33 * 2002 #line directives by Francesco Potortì.
35 * Francesco Potortì <pot@gnu.org> has maintained and improved it since 1993.
39 * If you want to add support for a new language, start by looking at the LUA
40 * language, which is the simplest. Alternatively, consider shipping a
41 * configuration file containing regexp definitions for etags.
44 char pot_etags_version
[] = "@(#) pot revision number is 17.26";
54 # define NDEBUG /* disable assert */
59 /* On some systems, Emacs defines static as nothing for the sake
60 of unexec. We don't want that here since we don't use unexec. */
62 # ifndef PTR /* for XEmacs */
65 # ifndef __P /* for XEmacs */
66 # define __P(args) args
68 #else /* no config.h */
69 # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
70 # define __P(args) args /* use prototypes */
71 # define PTR void * /* for generic pointers */
72 # else /* not standard C */
73 # define __P(args) () /* no prototypes */
74 # define const /* remove const for old compilers' sake */
75 # define PTR long * /* don't use void* */
77 #endif /* !HAVE_CONFIG_H */
80 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
83 /* WIN32_NATIVE is for XEmacs.
84 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */
89 #endif /* WIN32_NATIVE */
95 # include <sys/param.h>
97 # ifndef HAVE_CONFIG_H
99 # include <sys/config.h>
111 # define MAXPATHLEN _MAX_PATH
117 # endif /* undef HAVE_GETCWD */
118 #else /* not WINDOWSNT */
122 # else /* no standard C headers */
123 extern char *getenv ();
125 # define EXIT_SUCCESS 1
126 # define EXIT_FAILURE 0
128 # define EXIT_SUCCESS 0
129 # define EXIT_FAILURE 1
132 #endif /* !WINDOWSNT */
137 # if defined (HAVE_GETCWD) && !defined (WINDOWSNT)
138 extern char *getcwd (char *buf
, size_t size
);
140 #endif /* HAVE_UNISTD_H */
148 #include <sys/types.h>
149 #include <sys/stat.h>
153 # undef assert /* some systems have a buggy assert.h */
154 # define assert(x) ((void) 0)
157 #if !defined (S_ISREG) && defined (S_IFREG)
158 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
161 #ifdef NO_LONG_OPTIONS /* define this if you don't have GNU getopt */
162 # define NO_LONG_OPTIONS TRUE
163 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
165 extern int optind
, opterr
;
167 # define NO_LONG_OPTIONS FALSE
169 #endif /* NO_LONG_OPTIONS */
171 #ifndef HAVE_CONFIG_H /* this is a standalone compilation */
172 # ifdef __CYGWIN__ /* compiling on Cygwin */
174 the regex
.h distributed with Cygwin is
not compatible with etags
, alas
!
175 If you want regular expression support
, you should
delete this notice
and
176 arrange to use the GNU regex
.h
and regex
.c
.
181 /* Define CTAGS to make the program "ctags" compatible with the usual one.
182 Leave it undefined to make the program "etags", which makes emacs-style
183 tag tables and tags typedefs, #defines and struct/union/enum by default. */
191 #define streq(s,t) (assert((s)!=NULL || (t)!=NULL), !strcmp (s, t))
192 #define strcaseeq(s,t) (assert((s)!=NULL && (t)!=NULL), !etags_strcasecmp (s, t))
193 #define strneq(s,t,n) (assert((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
194 #define strncaseeq(s,t,n) (assert((s)!=NULL && (t)!=NULL), !etags_strncasecmp (s, t, n))
196 #define CHARS 256 /* 2^sizeof(char) */
197 #define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
198 #define iswhite(c) (_wht[CHAR(c)]) /* c is white (see white) */
199 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name (see nonam) */
200 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token (see begtk) */
201 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token (see midtk) */
202 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens (see endtk) */
204 #define ISALNUM(c) isalnum (CHAR(c))
205 #define ISALPHA(c) isalpha (CHAR(c))
206 #define ISDIGIT(c) isdigit (CHAR(c))
207 #define ISLOWER(c) islower (CHAR(c))
209 #define lowcase(c) tolower (CHAR(c))
210 #define upcase(c) toupper (CHAR(c))
214 * xnew, xrnew -- allocate, reallocate storage
216 * SYNOPSIS: Type *xnew (int n, Type);
217 * void xrnew (OldPointer, int n, Type);
220 # include "chkmalloc.h"
221 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
222 (n) * sizeof (Type)))
223 # define xrnew(op,n,Type) ((op) = (Type *) trace_realloc (__FILE__, __LINE__, \
224 (char *) (op), (n) * sizeof (Type)))
226 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
227 # define xrnew(op,n,Type) ((op) = (Type *) xrealloc ( \
228 (char *) (op), (n) * sizeof (Type)))
233 typedef void Lang_function
__P((FILE *));
237 char *suffix
; /* file name suffix for this compressor */
238 char *command
; /* takes one arg and decompresses to stdout */
243 char *name
; /* language name */
244 char *help
; /* detailed help for the language */
245 Lang_function
*function
; /* parse function */
246 char **suffixes
; /* name suffixes of this language's files */
247 char **filenames
; /* names of this language's files */
248 char **interpreters
; /* interpreters for this language */
249 bool metasource
; /* source used to generate other sources */
254 struct fdesc
*next
; /* for the linked list */
255 char *infname
; /* uncompressed input file name */
256 char *infabsname
; /* absolute uncompressed input file name */
257 char *infabsdir
; /* absolute dir of input file */
258 char *taggedfname
; /* file name to write in tagfile */
259 language
*lang
; /* language of file */
260 char *prop
; /* file properties to write in tagfile */
261 bool usecharno
; /* etags tags shall contain char number */
262 bool written
; /* entry written in the tags file */
265 typedef struct node_st
266 { /* sorting structure */
267 struct node_st
*left
, *right
; /* left and right sons */
268 fdesc
*fdp
; /* description of file to whom tag belongs */
269 char *name
; /* tag name */
270 char *regex
; /* search regexp */
271 bool valid
; /* write this tag on the tag file */
272 bool is_func
; /* function tag: use regexp in CTAGS mode */
273 bool been_warned
; /* warning already given for duplicated tag */
274 int lno
; /* line number tag is on */
275 long cno
; /* character number line starts on */
279 * A `linebuffer' is a structure which holds a line of text.
280 * `readline_internal' reads a line from a stream into a linebuffer
281 * and works regardless of the length of the line.
282 * SIZE is the size of BUFFER, LEN is the length of the string in
283 * BUFFER after readline reads it.
292 /* Used to support mixing of --lang and file names. */
296 at_language
, /* a language specification */
297 at_regexp
, /* a regular expression */
298 at_filename
, /* a file name */
299 at_stdin
, /* read from stdin here */
300 at_end
/* stop parsing the list */
301 } arg_type
; /* argument type */
302 language
*lang
; /* language associated with the argument */
303 char *what
; /* the argument itself */
306 /* Structure defining a regular expression. */
307 typedef struct regexp
309 struct regexp
*p_next
; /* pointer to next in list */
310 language
*lang
; /* if set, use only for this language */
311 char *pattern
; /* the regexp pattern */
312 char *name
; /* tag name */
313 struct re_pattern_buffer
*pat
; /* the compiled pattern */
314 struct re_registers regs
; /* re registers */
315 bool error_signaled
; /* already signaled for this regexp */
316 bool force_explicit_name
; /* do not allow implict tag name */
317 bool ignore_case
; /* ignore case when matching */
318 bool multi_line
; /* do a multi-line match on the whole file */
322 /* Many compilers barf on this:
323 Lang_function Ada_funcs;
324 so let's write it this way */
325 static void Ada_funcs
__P((FILE *));
326 static void Asm_labels
__P((FILE *));
327 static void C_entries
__P((int c_ext
, FILE *));
328 static void default_C_entries
__P((FILE *));
329 static void plain_C_entries
__P((FILE *));
330 static void Cjava_entries
__P((FILE *));
331 static void Cobol_paragraphs
__P((FILE *));
332 static void Cplusplus_entries
__P((FILE *));
333 static void Cstar_entries
__P((FILE *));
334 static void Erlang_functions
__P((FILE *));
335 static void Forth_words
__P((FILE *));
336 static void Fortran_functions
__P((FILE *));
337 static void HTML_labels
__P((FILE *));
338 static void Lisp_functions
__P((FILE *));
339 static void Lua_functions
__P((FILE *));
340 static void Makefile_targets
__P((FILE *));
341 static void Pascal_functions
__P((FILE *));
342 static void Perl_functions
__P((FILE *));
343 static void PHP_functions
__P((FILE *));
344 static void PS_functions
__P((FILE *));
345 static void Prolog_functions
__P((FILE *));
346 static void Python_functions
__P((FILE *));
347 static void Scheme_functions
__P((FILE *));
348 static void TeX_commands
__P((FILE *));
349 static void Texinfo_nodes
__P((FILE *));
350 static void Yacc_entries
__P((FILE *));
351 static void just_read_file
__P((FILE *));
353 static void print_language_names
__P((void));
354 static void print_version
__P((void));
355 static void print_help
__P((argument
*));
356 int main
__P((int, char **));
358 static compressor
*get_compressor_from_suffix
__P((char *, char **));
359 static language
*get_language_from_langname
__P((const char *));
360 static language
*get_language_from_interpreter
__P((char *));
361 static language
*get_language_from_filename
__P((char *, bool));
362 static void readline
__P((linebuffer
*, FILE *));
363 static long readline_internal
__P((linebuffer
*, FILE *));
364 static bool nocase_tail
__P((char *));
365 static void get_tag
__P((char *, char **));
367 static void analyse_regex
__P((char *));
368 static void free_regexps
__P((void));
369 static void regex_tag_multiline
__P((void));
370 static void error
__P((const char *, const char *));
371 static void suggest_asking_for_help
__P((void));
372 void fatal
__P((char *, char *));
373 static void pfatal
__P((char *));
374 static void add_node
__P((node
*, node
**));
376 static void init
__P((void));
377 static void process_file_name
__P((char *, language
*));
378 static void process_file
__P((FILE *, char *, language
*));
379 static void find_entries
__P((FILE *));
380 static void free_tree
__P((node
*));
381 static void free_fdesc
__P((fdesc
*));
382 static void pfnote
__P((char *, bool, char *, int, int, long));
383 static void make_tag
__P((char *, int, bool, char *, int, int, long));
384 static void invalidate_nodes
__P((fdesc
*, node
**));
385 static void put_entries
__P((node
*));
387 static char *concat
__P((char *, char *, char *));
388 static char *skip_spaces
__P((char *));
389 static char *skip_non_spaces
__P((char *));
390 static char *savenstr
__P((char *, int));
391 static char *savestr
__P((char *));
392 static char *etags_strchr
__P((const char *, int));
393 static char *etags_strrchr
__P((const char *, int));
394 static int etags_strcasecmp
__P((const char *, const char *));
395 static int etags_strncasecmp
__P((const char *, const char *, int));
396 static char *etags_getcwd
__P((void));
397 static char *relative_filename
__P((char *, char *));
398 static char *absolute_filename
__P((char *, char *));
399 static char *absolute_dirname
__P((char *, char *));
400 static bool filename_is_absolute
__P((char *f
));
401 static void canonicalize_filename
__P((char *));
402 static void linebuffer_init
__P((linebuffer
*));
403 static void linebuffer_setlen
__P((linebuffer
*, int));
404 static PTR xmalloc
__P((unsigned int));
405 static PTR xrealloc
__P((char *, unsigned int));
408 static char searchar
= '/'; /* use /.../ searches */
410 static char *tagfile
; /* output file */
411 static char *progname
; /* name this program was invoked with */
412 static char *cwd
; /* current working directory */
413 static char *tagfiledir
; /* directory of tagfile */
414 static FILE *tagf
; /* ioptr for tags file */
416 static fdesc
*fdhead
; /* head of file description list */
417 static fdesc
*curfdp
; /* current file description */
418 static int lineno
; /* line number of current line */
419 static long charno
; /* current character number */
420 static long linecharno
; /* charno of start of current line */
421 static char *dbp
; /* pointer to start of current tag */
423 static const int invalidcharno
= -1;
425 static node
*nodehead
; /* the head of the binary tree of tags */
426 static node
*last_node
; /* the last node created */
428 static linebuffer lb
; /* the current line */
429 static linebuffer filebuf
; /* a buffer containing the whole file */
430 static linebuffer token_name
; /* a buffer containing a tag name */
432 /* boolean "functions" (see init) */
433 static bool _wht
[CHARS
], _nin
[CHARS
], _itk
[CHARS
], _btk
[CHARS
], _etk
[CHARS
];
436 *white
= " \f\t\n\r\v",
438 *nonam
= " \f\t\n\r()=,;", /* look at make_tag before modifying! */
439 /* token ending chars */
440 *endtk
= " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
441 /* token starting chars */
442 *begtk
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
443 /* valid in-token chars */
444 *midtk
= "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
446 static bool append_to_tagfile
; /* -a: append to tags */
447 /* The next four default to TRUE for etags, but to FALSE for ctags. */
448 static bool typedefs
; /* -t: create tags for C and Ada typedefs */
449 static bool typedefs_or_cplusplus
; /* -T: create tags for C typedefs, level */
450 /* 0 struct/enum/union decls, and C++ */
451 /* member functions. */
452 static bool constantypedefs
; /* -d: create tags for C #define, enum */
453 /* constants and variables. */
454 /* -D: opposite of -d. Default under ctags. */
455 static bool globals
; /* create tags for global variables */
456 static bool declarations
; /* --declarations: tag them and extern in C&Co*/
457 static bool members
; /* create tags for C member variables */
458 static bool no_line_directive
; /* ignore #line directives (undocumented) */
459 static bool no_duplicates
; /* no duplicate tags for ctags (undocumented) */
460 static bool update
; /* -u: update tags */
461 static bool vgrind_style
; /* -v: create vgrind style index output */
462 static bool no_warnings
; /* -w: suppress warnings (undocumented) */
463 static bool cxref_style
; /* -x: create cxref style output */
464 static bool cplusplus
; /* .[hc] means C++, not C */
465 static bool ignoreindent
; /* -I: ignore indentation in C */
466 static bool packages_only
; /* --packages-only: in Ada, only tag packages*/
468 /* STDIN is defined in LynxOS system headers */
473 #define STDIN 0x1001 /* returned by getopt_long on --parse-stdin */
474 static bool parsing_stdin
; /* --parse-stdin used */
476 static regexp
*p_head
; /* list of all regexps */
477 static bool need_filebuf
; /* some regexes are multi-line */
479 static struct option longopts
[] =
481 { "append", no_argument
, NULL
, 'a' },
482 { "packages-only", no_argument
, &packages_only
, TRUE
},
483 { "c++", no_argument
, NULL
, 'C' },
484 { "declarations", no_argument
, &declarations
, TRUE
},
485 { "no-line-directive", no_argument
, &no_line_directive
, TRUE
},
486 { "no-duplicates", no_argument
, &no_duplicates
, TRUE
},
487 { "help", no_argument
, NULL
, 'h' },
488 { "help", no_argument
, NULL
, 'H' },
489 { "ignore-indentation", no_argument
, NULL
, 'I' },
490 { "language", required_argument
, NULL
, 'l' },
491 { "members", no_argument
, &members
, TRUE
},
492 { "no-members", no_argument
, &members
, FALSE
},
493 { "output", required_argument
, NULL
, 'o' },
494 { "regex", required_argument
, NULL
, 'r' },
495 { "no-regex", no_argument
, NULL
, 'R' },
496 { "ignore-case-regex", required_argument
, NULL
, 'c' },
497 { "parse-stdin", required_argument
, NULL
, STDIN
},
498 { "version", no_argument
, NULL
, 'V' },
500 #if CTAGS /* Ctags options */
501 { "backward-search", no_argument
, NULL
, 'B' },
502 { "cxref", no_argument
, NULL
, 'x' },
503 { "defines", no_argument
, NULL
, 'd' },
504 { "globals", no_argument
, &globals
, TRUE
},
505 { "typedefs", no_argument
, NULL
, 't' },
506 { "typedefs-and-c++", no_argument
, NULL
, 'T' },
507 { "update", no_argument
, NULL
, 'u' },
508 { "vgrind", no_argument
, NULL
, 'v' },
509 { "no-warn", no_argument
, NULL
, 'w' },
511 #else /* Etags options */
512 { "no-defines", no_argument
, NULL
, 'D' },
513 { "no-globals", no_argument
, &globals
, FALSE
},
514 { "include", required_argument
, NULL
, 'i' },
519 static compressor compressors
[] =
521 { "z", "gzip -d -c"},
522 { "Z", "gzip -d -c"},
523 { "gz", "gzip -d -c"},
524 { "GZ", "gzip -d -c"},
525 { "bz2", "bzip2 -d -c" },
534 static char *Ada_suffixes
[] =
535 { "ads", "adb", "ada", NULL
};
536 static char Ada_help
[] =
537 "In Ada code, functions, procedures, packages, tasks and types are\n\
538 tags. Use the `--packages-only' option to create tags for\n\
540 Ada tag names have suffixes indicating the type of entity:\n\
541 Entity type: Qualifier:\n\
542 ------------ ----------\n\
549 Thus, `M-x find-tag <RET> bidule/b <RET>' will go directly to the\n\
550 body of the package `bidule', while `M-x find-tag <RET> bidule <RET>'\n\
551 will just search for any tag `bidule'.";
554 static char *Asm_suffixes
[] =
555 { "a", /* Unix assembler */
556 "asm", /* Microcontroller assembly */
557 "def", /* BSO/Tasking definition includes */
558 "inc", /* Microcontroller include files */
559 "ins", /* Microcontroller include files */
560 "s", "sa", /* Unix assembler */
561 "S", /* cpp-processed Unix assembler */
562 "src", /* BSO/Tasking C compiler output */
565 static char Asm_help
[] =
566 "In assembler code, labels appearing at the beginning of a line,\n\
567 followed by a colon, are tags.";
570 /* Note that .c and .h can be considered C++, if the --c++ flag was
571 given, or if the `class' or `template' keyowrds are met inside the file.
572 That is why default_C_entries is called for these. */
573 static char *default_C_suffixes
[] =
575 static char default_C_help
[] =
576 "In C code, any C function or typedef is a tag, and so are\n\
577 definitions of `struct', `union' and `enum'. `#define' macro\n\
578 definitions and `enum' constants are tags unless you specify\n\
579 `--no-defines'. Global variables are tags unless you specify\n\
580 `--no-globals'. Use of `--no-globals' and `--no-defines'\n\
581 can make the tags table file much smaller.\n\
582 You can tag function declarations and external variables by\n\
583 using `--declarations', and struct members by using `--members'.";
585 static char *Cplusplus_suffixes
[] =
586 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx",
587 "M", /* Objective C++ */
588 "pdb", /* Postscript with C syntax */
590 static char Cplusplus_help
[] =
591 "In C++ code, all the tag constructs of C code are tagged. (Use\n\
592 --help --lang=c --lang=c++ for full help.)\n\
593 In addition to C tags, member functions are also recognized, and\n\
594 optionally member variables if you use the `--members' option.\n\
595 Tags for variables and functions in classes are named `CLASS::VARIABLE'\n\
596 and `CLASS::FUNCTION'. `operator' definitions have tag names like\n\
599 static char *Cjava_suffixes
[] =
601 static char Cjava_help
[] =
602 "In Java code, all the tags constructs of C and C++ code are\n\
603 tagged. (Use --help --lang=c --lang=c++ --lang=java for full help.)";
606 static char *Cobol_suffixes
[] =
607 { "COB", "cob", NULL
};
608 static char Cobol_help
[] =
609 "In Cobol code, tags are paragraph names; that is, any word\n\
610 starting in column 8 and followed by a period.";
612 static char *Cstar_suffixes
[] =
613 { "cs", "hs", NULL
};
615 static char *Erlang_suffixes
[] =
616 { "erl", "hrl", NULL
};
617 static char Erlang_help
[] =
618 "In Erlang code, the tags are the functions, records and macros\n\
619 defined in the file.";
621 char *Forth_suffixes
[] =
622 { "fth", "tok", NULL
};
623 static char Forth_help
[] =
624 "In Forth code, tags are words defined by `:',\n\
625 constant, code, create, defer, value, variable, buffer:, field.";
627 static char *Fortran_suffixes
[] =
628 { "F", "f", "f90", "for", NULL
};
629 static char Fortran_help
[] =
630 "In Fortran code, functions, subroutines and block data are tags.";
632 static char *HTML_suffixes
[] =
633 { "htm", "html", "shtml", NULL
};
634 static char HTML_help
[] =
635 "In HTML input files, the tags are the `title' and the `h1', `h2',\n\
636 `h3' headers. Also, tags are `name=' in anchors and all\n\
637 occurrences of `id='.";
639 static char *Lisp_suffixes
[] =
640 { "cl", "clisp", "el", "l", "lisp", "LSP", "lsp", "ml", NULL
};
641 static char Lisp_help
[] =
642 "In Lisp code, any function defined with `defun', any variable\n\
643 defined with `defvar' or `defconst', and in general the first\n\
644 argument of any expression that starts with `(def' in column zero\n\
647 static char *Lua_suffixes
[] =
648 { "lua", "LUA", NULL
};
649 static char Lua_help
[] =
650 "In Lua scripts, all functions are tags.";
652 static char *Makefile_filenames
[] =
653 { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL
};
654 static char Makefile_help
[] =
655 "In makefiles, targets are tags; additionally, variables are tags\n\
656 unless you specify `--no-globals'.";
658 static char *Objc_suffixes
[] =
659 { "lm", /* Objective lex file */
660 "m", /* Objective C file */
662 static char Objc_help
[] =
663 "In Objective C code, tags include Objective C definitions for classes,\n\
664 class categories, methods and protocols. Tags for variables and\n\
665 functions in classes are named `CLASS::VARIABLE' and `CLASS::FUNCTION'.\n\
666 (Use --help --lang=c --lang=objc --lang=java for full help.)";
668 static char *Pascal_suffixes
[] =
669 { "p", "pas", NULL
};
670 static char Pascal_help
[] =
671 "In Pascal code, the tags are the functions and procedures defined\n\
673 /* " // this is for working around an Emacs highlighting bug... */
675 static char *Perl_suffixes
[] =
676 { "pl", "pm", NULL
};
677 static char *Perl_interpreters
[] =
678 { "perl", "@PERL@", NULL
};
679 static char Perl_help
[] =
680 "In Perl code, the tags are the packages, subroutines and variables\n\
681 defined by the `package', `sub', `my' and `local' keywords. Use\n\
682 `--globals' if you want to tag global variables. Tags for\n\
683 subroutines are named `PACKAGE::SUB'. The name for subroutines\n\
684 defined in the default package is `main::SUB'.";
686 static char *PHP_suffixes
[] =
687 { "php", "php3", "php4", NULL
};
688 static char PHP_help
[] =
689 "In PHP code, tags are functions, classes and defines. When using\n\
690 the `--members' option, vars are tags too.";
692 static char *plain_C_suffixes
[] =
693 { "pc", /* Pro*C file */
696 static char *PS_suffixes
[] =
697 { "ps", "psw", NULL
}; /* .psw is for PSWrap */
698 static char PS_help
[] =
699 "In PostScript code, the tags are the functions.";
701 static char *Prolog_suffixes
[] =
703 static char Prolog_help
[] =
704 "In Prolog code, tags are predicates and rules at the beginning of\n\
707 static char *Python_suffixes
[] =
709 static char Python_help
[] =
710 "In Python code, `def' or `class' at the beginning of a line\n\
713 /* Can't do the `SCM' or `scm' prefix with a version number. */
714 static char *Scheme_suffixes
[] =
715 { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL
};
716 static char Scheme_help
[] =
717 "In Scheme code, tags include anything defined with `def' or with a\n\
718 construct whose name starts with `def'. They also include\n\
719 variables set with `set!' at top level in the file.";
721 static char *TeX_suffixes
[] =
722 { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL
};
723 static char TeX_help
[] =
724 "In LaTeX text, the argument of any of the commands `\\chapter',\n\
725 `\\section', `\\subsection', `\\subsubsection', `\\eqno', `\\label',\n\
726 `\\ref', `\\cite', `\\bibitem', `\\part', `\\appendix', `\\entry',\n\
727 `\\index', `\\def', `\\newcommand', `\\renewcommand',\n\
728 `\\newenvironment' or `\\renewenvironment' is a tag.\n\
730 Other commands can be specified by setting the environment variable\n\
731 `TEXTAGS' to a colon-separated list like, for example,\n\
732 TEXTAGS=\"mycommand:myothercommand\".";
735 static char *Texinfo_suffixes
[] =
736 { "texi", "texinfo", "txi", NULL
};
737 static char Texinfo_help
[] =
738 "for texinfo files, lines starting with @node are tagged.";
740 static char *Yacc_suffixes
[] =
741 { "y", "y++", "ym", "yxx", "yy", NULL
}; /* .ym is Objective yacc file */
742 static char Yacc_help
[] =
743 "In Bison or Yacc input files, each rule defines as a tag the\n\
744 nonterminal it constructs. The portions of the file that contain\n\
745 C code are parsed as C code (use --help --lang=c --lang=yacc\n\
748 static char auto_help
[] =
749 "`auto' is not a real language, it indicates to use\n\
750 a default language for files base on file name suffix and file contents.";
752 static char none_help
[] =
753 "`none' is not a real language, it indicates to only do\n\
754 regexp processing on files.";
756 static char no_lang_help
[] =
757 "No detailed help available for this language.";
761 * Table of languages.
763 * It is ok for a given function to be listed under more than one
764 * name. I just didn't.
767 static language lang_names
[] =
769 { "ada", Ada_help
, Ada_funcs
, Ada_suffixes
},
770 { "asm", Asm_help
, Asm_labels
, Asm_suffixes
},
771 { "c", default_C_help
, default_C_entries
, default_C_suffixes
},
772 { "c++", Cplusplus_help
, Cplusplus_entries
, Cplusplus_suffixes
},
773 { "c*", no_lang_help
, Cstar_entries
, Cstar_suffixes
},
774 { "cobol", Cobol_help
, Cobol_paragraphs
, Cobol_suffixes
},
775 { "erlang", Erlang_help
, Erlang_functions
, Erlang_suffixes
},
776 { "forth", Forth_help
, Forth_words
, Forth_suffixes
},
777 { "fortran", Fortran_help
, Fortran_functions
, Fortran_suffixes
},
778 { "html", HTML_help
, HTML_labels
, HTML_suffixes
},
779 { "java", Cjava_help
, Cjava_entries
, Cjava_suffixes
},
780 { "lisp", Lisp_help
, Lisp_functions
, Lisp_suffixes
},
781 { "lua", Lua_help
, Lua_functions
, Lua_suffixes
},
782 { "makefile", Makefile_help
,Makefile_targets
,NULL
,Makefile_filenames
},
783 { "objc", Objc_help
, plain_C_entries
, Objc_suffixes
},
784 { "pascal", Pascal_help
, Pascal_functions
, Pascal_suffixes
},
785 { "perl",Perl_help
,Perl_functions
,Perl_suffixes
,NULL
,Perl_interpreters
},
786 { "php", PHP_help
, PHP_functions
, PHP_suffixes
},
787 { "postscript",PS_help
, PS_functions
, PS_suffixes
},
788 { "proc", no_lang_help
, plain_C_entries
, plain_C_suffixes
},
789 { "prolog", Prolog_help
, Prolog_functions
, Prolog_suffixes
},
790 { "python", Python_help
, Python_functions
, Python_suffixes
},
791 { "scheme", Scheme_help
, Scheme_functions
, Scheme_suffixes
},
792 { "tex", TeX_help
, TeX_commands
, TeX_suffixes
},
793 { "texinfo", Texinfo_help
, Texinfo_nodes
, Texinfo_suffixes
},
794 { "yacc", Yacc_help
,Yacc_entries
,Yacc_suffixes
,NULL
,NULL
,TRUE
},
795 { "auto", auto_help
}, /* default guessing scheme */
796 { "none", none_help
, just_read_file
}, /* regexp matching only */
797 { NULL
} /* end of list */
802 print_language_names ()
807 puts ("\nThese are the currently supported languages, along with the\n\
808 default file names and dot suffixes:");
809 for (lang
= lang_names
; lang
->name
!= NULL
; lang
++)
811 printf (" %-*s", 10, lang
->name
);
812 if (lang
->filenames
!= NULL
)
813 for (name
= lang
->filenames
; *name
!= NULL
; name
++)
814 printf (" %s", *name
);
815 if (lang
->suffixes
!= NULL
)
816 for (ext
= lang
->suffixes
; *ext
!= NULL
; ext
++)
817 printf (" .%s", *ext
);
820 puts ("where `auto' means use default language for files based on file\n\
821 name suffix, and `none' means only do regexp processing on files.\n\
822 If no language is specified and no matching suffix is found,\n\
823 the first line of the file is read for a sharp-bang (#!) sequence\n\
824 followed by the name of an interpreter. If no such sequence is found,\n\
825 Fortran is tried first; if no tags are found, C is tried next.\n\
826 When parsing any C file, a \"class\" or \"template\" keyword\n\
828 puts ("Compressed files are supported using gzip and bzip2.\n\
830 For detailed help on a given language use, for example,\n\
831 etags --help --lang=ada.");
835 # define EMACS_NAME "standalone"
838 # define VERSION "version"
843 printf ("%s (%s %s)\n", (CTAGS
) ? "ctags" : "etags", EMACS_NAME
, VERSION
);
844 puts ("Copyright (C) 2006 Free Software Foundation, Inc. and Ken Arnold");
845 puts ("This program is distributed under the same terms as Emacs");
851 print_help (argbuffer
)
854 bool help_for_lang
= FALSE
;
856 for (; argbuffer
->arg_type
!= at_end
; argbuffer
++)
857 if (argbuffer
->arg_type
== at_language
)
861 puts (argbuffer
->lang
->help
);
862 help_for_lang
= TRUE
;
868 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
870 These are the options accepted by %s.\n", progname
, progname
);
872 puts ("WARNING: long option names do not work with this executable,\n\
873 as it is not linked with GNU getopt.");
875 puts ("You may use unambiguous abbreviations for the long option names.");
876 puts (" A - as file name means read names from stdin (one per line).\n\
877 Absolute names are stored in the output file as they are.\n\
878 Relative ones are stored relative to the output file's directory.\n");
880 puts ("-a, --append\n\
881 Append tag entries to existing tags file.");
883 puts ("--packages-only\n\
884 For Ada files, only generate tags for packages.");
887 puts ("-B, --backward-search\n\
888 Write the search commands for the tag entries using '?', the\n\
889 backward-search command instead of '/', the forward-search command.");
891 /* This option is mostly obsolete, because etags can now automatically
892 detect C++. Retained for backward compatibility and for debugging and
893 experimentation. In principle, we could want to tag as C++ even
894 before any "class" or "template" keyword.
896 Treat files whose name suffix defaults to C language as C++ files.");
899 puts ("--declarations\n\
900 In C and derived languages, create tags for function declarations,");
902 puts ("\tand create tags for extern variables if --globals is used.");
905 ("\tand create tags for extern variables unless --no-globals is used.");
908 puts ("-d, --defines\n\
909 Create tag entries for C #define constants and enum constants, too.");
911 puts ("-D, --no-defines\n\
912 Don't create tag entries for C #define constants and enum constants.\n\
913 This makes the tags file smaller.");
916 puts ("-i FILE, --include=FILE\n\
917 Include a note in tag file indicating that, when searching for\n\
918 a tag, one should also consult the tags file FILE after\n\
919 checking the current file.");
921 puts ("-l LANG, --language=LANG\n\
922 Force the following files to be considered as written in the\n\
923 named language up to the next --language=LANG option.");
927 Create tag entries for global variables in some languages.");
929 puts ("--no-globals\n\
930 Do not create tag entries for global variables in some\n\
931 languages. This makes the tags file smaller.");
933 Create tag entries for members of structures in some languages.");
935 puts ("-r REGEXP, --regex=REGEXP or --regex=@regexfile\n\
936 Make a tag for each line matching a regular expression pattern\n\
937 in the following files. {LANGUAGE}REGEXP uses REGEXP for LANGUAGE\n\
938 files only. REGEXFILE is a file containing one REGEXP per line.\n\
939 REGEXP takes the form /TAGREGEXP/TAGNAME/MODS, where TAGNAME/ is\n\
940 optional. The TAGREGEXP pattern is anchored (as if preceded by ^).");
941 puts (" If TAGNAME/ is present, the tags created are named.\n\
942 For example Tcl named tags can be created with:\n\
943 --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\".\n\
944 MODS are optional one-letter modifiers: `i' means to ignore case,\n\
945 `m' means to allow multi-line matches, `s' implies `m' and\n\
946 causes dot to match any character, including newline.");
947 puts ("-R, --no-regex\n\
948 Don't create tags from regexps for the following files.");
949 puts ("-I, --ignore-indentation\n\
950 In C and C++ do not assume that a closing brace in the first\n\
951 column is the final brace of a function or structure definition.");
952 puts ("-o FILE, --output=FILE\n\
953 Write the tags to FILE.");
954 puts ("--parse-stdin=NAME\n\
955 Read from standard input and record tags as belonging to file NAME.");
959 puts ("-t, --typedefs\n\
960 Generate tag entries for C and Ada typedefs.");
961 puts ("-T, --typedefs-and-c++\n\
962 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
963 and C++ member functions.");
967 puts ("-u, --update\n\
968 Update the tag entries for the given files, leaving tag\n\
969 entries for other files in place. Currently, this is\n\
970 implemented by deleting the existing entries for the given\n\
971 files and then rewriting the new entries at the end of the\n\
972 tags file. It is often faster to simply rebuild the entire\n\
973 tag file than to use this.");
977 puts ("-v, --vgrind\n\
978 Print on the standard output an index of items intended for\n\
979 human consumption, similar to the output of vgrind. The index\n\
980 is sorted, and gives the page number of each item.");
981 # if PRINT_UNDOCUMENTED_OPTIONS_HELP
982 puts ("-w, --no-duplicates\n\
983 Do not create duplicate tag entries, for compatibility with\n\
984 traditional ctags.");
985 puts ("-w, --no-warn\n\
986 Suppress warning messages about duplicate tag entries.");
987 # endif /* PRINT_UNDOCUMENTED_OPTIONS_HELP */
988 puts ("-x, --cxref\n\
989 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
990 The output uses line numbers instead of page numbers, but\n\
991 beyond that the differences are cosmetic; try both to see\n\
995 puts ("-V, --version\n\
996 Print the version of the program.\n\
998 Print this help message.\n\
999 Followed by one or more `--language' options prints detailed\n\
1000 help about tag generation for the specified languages.");
1002 print_language_names ();
1005 puts ("Report bugs to bug-gnu-emacs@gnu.org");
1007 exit (EXIT_SUCCESS
);
1011 #ifdef VMS /* VMS specific functions */
1015 /* This is a BUG! ANY arbitrary limit is a BUG!
1016 Won't someone please fix this? */
1017 #define MAX_FILE_SPEC_LEN 255
1020 char body
[MAX_FILE_SPEC_LEN
+ 1];
1024 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
1025 returning in each successive call the next file name matching the input
1026 spec. The function expects that each in_spec passed
1027 to it will be processed to completion; in particular, up to and
1028 including the call following that in which the last matching name
1029 is returned, the function ignores the value of in_spec, and will
1030 only start processing a new spec with the following call.
1031 If an error occurs, on return out_spec contains the value
1032 of in_spec when the error occurred.
1034 With each successive file name returned in out_spec, the
1035 function's return value is one. When there are no more matching
1036 names the function returns zero. If on the first call no file
1037 matches in_spec, or there is any other error, -1 is returned.
1041 #include <descrip.h>
1042 #define OUTSIZE MAX_FILE_SPEC_LEN
1048 static long context
= 0;
1049 static struct dsc$descriptor_s o
;
1050 static struct dsc$descriptor_s i
;
1051 static bool pass1
= TRUE
;
1058 o
.dsc$a_pointer
= (char *) out
;
1059 o
.dsc$w_length
= (short)OUTSIZE
;
1060 i
.dsc$a_pointer
= in
;
1061 i
.dsc$w_length
= (short)strlen(in
);
1062 i
.dsc$b_dtype
= DSC$K_DTYPE_T
;
1063 i
.dsc$b_class
= DSC$K_CLASS_S
;
1064 o
.dsc$b_dtype
= DSC$K_DTYPE_VT
;
1065 o
.dsc$b_class
= DSC$K_CLASS_VS
;
1067 if ((status
= lib$
find_file(&i
, &o
, &context
, 0, 0)) == RMS$_NORMAL
)
1069 out
->body
[out
->curlen
] = EOS
;
1072 else if (status
== RMS$_NMF
)
1076 strcpy(out
->body
, in
);
1079 lib$
find_file_end(&context
);
1085 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
1086 name of each file specified by the provided arg expanding wildcards.
1089 gfnames (arg
, p_error
)
1093 static vspec filename
= {MAX_FILE_SPEC_LEN
, "\0"};
1095 switch (fn_exp (&filename
, arg
))
1099 return filename
.body
;
1105 return filename
.body
;
1109 #ifndef OLD /* Newer versions of VMS do provide `system'. */
1113 error ("%s", "system() function not implemented under VMS");
1117 #define VERSION_DELIM ';'
1118 char *massage_name (s
)
1124 if (*s
== VERSION_DELIM
)
1142 unsigned int nincluded_files
;
1143 char **included_files
;
1144 argument
*argbuffer
;
1145 int current_arg
, file_count
;
1146 linebuffer filename_lb
;
1147 bool help_asked
= FALSE
;
1156 _fmode
= O_BINARY
; /* all of files are treated as binary files */
1160 nincluded_files
= 0;
1161 included_files
= xnew (argc
, char *);
1165 /* Allocate enough no matter what happens. Overkill, but each one
1167 argbuffer
= xnew (argc
, argument
);
1170 * If etags, always find typedefs and structure tags. Why not?
1171 * Also default to find macro constants, enum constants and
1176 typedefs
= typedefs_or_cplusplus
= constantypedefs
= TRUE
;
1180 /* When the optstring begins with a '-' getopt_long does not rearrange the
1181 non-options arguments to be at the end, but leaves them alone. */
1182 optstring
= concat (NO_LONG_OPTIONS
? "" : "-",
1183 "ac:Cf:Il:o:r:RSVhH",
1184 (CTAGS
) ? "BxdtTuvw" : "Di:");
1186 while ((opt
= getopt_long (argc
, argv
, optstring
, longopts
, NULL
)) != EOF
)
1190 /* If getopt returns 0, then it has already processed a
1191 long-named option. We should do nothing. */
1195 /* This means that a file name has been seen. Record it. */
1196 argbuffer
[current_arg
].arg_type
= at_filename
;
1197 argbuffer
[current_arg
].what
= optarg
;
1203 /* Parse standard input. Idea by Vivek <vivek@etla.org>. */
1204 argbuffer
[current_arg
].arg_type
= at_stdin
;
1205 argbuffer
[current_arg
].what
= optarg
;
1209 fatal ("cannot parse standard input more than once", (char *)NULL
);
1210 parsing_stdin
= TRUE
;
1213 /* Common options. */
1214 case 'a': append_to_tagfile
= TRUE
; break;
1215 case 'C': cplusplus
= TRUE
; break;
1216 case 'f': /* for compatibility with old makefiles */
1220 error ("-o option may only be given once.", (char *)NULL
);
1221 suggest_asking_for_help ();
1227 case 'S': /* for backward compatibility */
1228 ignoreindent
= TRUE
;
1232 language
*lang
= get_language_from_langname (optarg
);
1235 argbuffer
[current_arg
].lang
= lang
;
1236 argbuffer
[current_arg
].arg_type
= at_language
;
1242 /* Backward compatibility: support obsolete --ignore-case-regexp. */
1243 optarg
= concat (optarg
, "i", ""); /* memory leak here */
1246 argbuffer
[current_arg
].arg_type
= at_regexp
;
1247 argbuffer
[current_arg
].what
= optarg
;
1251 argbuffer
[current_arg
].arg_type
= at_regexp
;
1252 argbuffer
[current_arg
].what
= NULL
;
1264 case 'D': constantypedefs
= FALSE
; break;
1265 case 'i': included_files
[nincluded_files
++] = optarg
; break;
1267 /* Ctags options. */
1268 case 'B': searchar
= '?'; break;
1269 case 'd': constantypedefs
= TRUE
; break;
1270 case 't': typedefs
= TRUE
; break;
1271 case 'T': typedefs
= typedefs_or_cplusplus
= TRUE
; break;
1272 case 'u': update
= TRUE
; break;
1273 case 'v': vgrind_style
= TRUE
; /*FALLTHRU*/
1274 case 'x': cxref_style
= TRUE
; break;
1275 case 'w': no_warnings
= TRUE
; break;
1277 suggest_asking_for_help ();
1281 /* No more options. Store the rest of arguments. */
1282 for (; optind
< argc
; optind
++)
1284 argbuffer
[current_arg
].arg_type
= at_filename
;
1285 argbuffer
[current_arg
].what
= argv
[optind
];
1290 argbuffer
[current_arg
].arg_type
= at_end
;
1293 print_help (argbuffer
);
1296 if (nincluded_files
== 0 && file_count
== 0)
1298 error ("no input files specified.", (char *)NULL
);
1299 suggest_asking_for_help ();
1303 if (tagfile
== NULL
)
1304 tagfile
= CTAGS
? "tags" : "TAGS";
1305 cwd
= etags_getcwd (); /* the current working directory */
1306 if (cwd
[strlen (cwd
) - 1] != '/')
1309 cwd
= concat (oldcwd
, "/", "");
1312 /* Relative file names are made relative to the current directory. */
1313 if (streq (tagfile
, "-")
1314 || strneq (tagfile
, "/dev/", 5))
1317 tagfiledir
= absolute_dirname (tagfile
, cwd
);
1319 init (); /* set up boolean "functions" */
1321 linebuffer_init (&lb
);
1322 linebuffer_init (&filename_lb
);
1323 linebuffer_init (&filebuf
);
1324 linebuffer_init (&token_name
);
1328 if (streq (tagfile
, "-"))
1332 /* Switch redirected `stdout' to binary mode (setting `_fmode'
1333 doesn't take effect until after `stdout' is already open). */
1334 if (!isatty (fileno (stdout
)))
1335 setmode (fileno (stdout
), O_BINARY
);
1339 tagf
= fopen (tagfile
, append_to_tagfile
? "a" : "w");
1345 * Loop through files finding functions.
1347 for (i
= 0; i
< current_arg
; i
++)
1349 static language
*lang
; /* non-NULL if language is forced */
1352 switch (argbuffer
[i
].arg_type
)
1355 lang
= argbuffer
[i
].lang
;
1358 analyse_regex (argbuffer
[i
].what
);
1362 while ((this_file
= gfnames (argbuffer
[i
].what
, &got_err
)) != NULL
)
1366 error ("can't find file %s\n", this_file
);
1371 this_file
= massage_name (this_file
);
1374 this_file
= argbuffer
[i
].what
;
1376 /* Input file named "-" means read file names from stdin
1377 (one per line) and use them. */
1378 if (streq (this_file
, "-"))
1381 fatal ("cannot parse standard input AND read file names from it",
1383 while (readline_internal (&filename_lb
, stdin
) > 0)
1384 process_file_name (filename_lb
.buffer
, lang
);
1387 process_file_name (this_file
, lang
);
1393 this_file
= argbuffer
[i
].what
;
1394 process_file (stdin
, this_file
, lang
);
1401 free (filebuf
.buffer
);
1402 free (token_name
.buffer
);
1404 if (!CTAGS
|| cxref_style
)
1406 /* Write the remaining tags to tagf (ETAGS) or stdout (CXREF). */
1407 put_entries (nodehead
);
1408 free_tree (nodehead
);
1414 /* Output file entries that have no tags. */
1415 for (fdp
= fdhead
; fdp
!= NULL
; fdp
= fdp
->next
)
1417 fprintf (tagf
, "\f\n%s,0\n", fdp
->taggedfname
);
1419 while (nincluded_files
-- > 0)
1420 fprintf (tagf
, "\f\n%s,include\n", *included_files
++);
1422 if (fclose (tagf
) == EOF
)
1426 exit (EXIT_SUCCESS
);
1432 for (i
= 0; i
< current_arg
; ++i
)
1434 switch (argbuffer
[i
].arg_type
)
1440 continue; /* the for loop */
1443 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
1444 tagfile
, argbuffer
[i
].what
, tagfile
);
1445 if (system (cmd
) != EXIT_SUCCESS
)
1446 fatal ("failed to execute shell command", (char *)NULL
);
1448 append_to_tagfile
= TRUE
;
1451 tagf
= fopen (tagfile
, append_to_tagfile
? "a" : "w");
1454 put_entries (nodehead
); /* write all the tags (CTAGS) */
1455 free_tree (nodehead
);
1457 if (fclose (tagf
) == EOF
)
1461 if (append_to_tagfile
|| update
)
1463 char cmd
[2*BUFSIZ
+20];
1464 /* Maybe these should be used:
1465 setenv ("LC_COLLATE", "C", 1);
1466 setenv ("LC_ALL", "C", 1); */
1467 sprintf (cmd
, "sort -u -o %.*s %.*s", BUFSIZ
, tagfile
, BUFSIZ
, tagfile
);
1468 exit (system (cmd
));
1470 return EXIT_SUCCESS
;
1475 * Return a compressor given the file name. If EXTPTR is non-zero,
1476 * return a pointer into FILE where the compressor-specific
1477 * extension begins. If no compressor is found, NULL is returned
1478 * and EXTPTR is not significant.
1479 * Idea by Vladimir Alexiev <vladimir@cs.ualberta.ca> (1998)
1482 get_compressor_from_suffix (file
, extptr
)
1487 char *slash
, *suffix
;
1489 /* This relies on FN to be after canonicalize_filename,
1490 so we don't need to consider backslashes on DOS_NT. */
1491 slash
= etags_strrchr (file
, '/');
1492 suffix
= etags_strrchr (file
, '.');
1493 if (suffix
== NULL
|| suffix
< slash
)
1498 /* Let those poor souls who live with DOS 8+3 file name limits get
1499 some solace by treating foo.cgz as if it were foo.c.gz, etc.
1500 Only the first do loop is run if not MSDOS */
1503 for (compr
= compressors
; compr
->suffix
!= NULL
; compr
++)
1504 if (streq (compr
->suffix
, suffix
))
1507 break; /* do it only once: not really a loop */
1510 } while (*suffix
!= '\0');
1517 * Return a language given the name.
1520 get_language_from_langname (name
)
1526 error ("empty language name", (char *)NULL
);
1529 for (lang
= lang_names
; lang
->name
!= NULL
; lang
++)
1530 if (streq (name
, lang
->name
))
1532 error ("unknown language \"%s\"", name
);
1540 * Return a language given the interpreter name.
1543 get_language_from_interpreter (interpreter
)
1549 if (interpreter
== NULL
)
1551 for (lang
= lang_names
; lang
->name
!= NULL
; lang
++)
1552 if (lang
->interpreters
!= NULL
)
1553 for (iname
= lang
->interpreters
; *iname
!= NULL
; iname
++)
1554 if (streq (*iname
, interpreter
))
1563 * Return a language given the file name.
1566 get_language_from_filename (file
, case_sensitive
)
1568 bool case_sensitive
;
1571 char **name
, **ext
, *suffix
;
1573 /* Try whole file name first. */
1574 for (lang
= lang_names
; lang
->name
!= NULL
; lang
++)
1575 if (lang
->filenames
!= NULL
)
1576 for (name
= lang
->filenames
; *name
!= NULL
; name
++)
1577 if ((case_sensitive
)
1578 ? streq (*name
, file
)
1579 : strcaseeq (*name
, file
))
1582 /* If not found, try suffix after last dot. */
1583 suffix
= etags_strrchr (file
, '.');
1587 for (lang
= lang_names
; lang
->name
!= NULL
; lang
++)
1588 if (lang
->suffixes
!= NULL
)
1589 for (ext
= lang
->suffixes
; *ext
!= NULL
; ext
++)
1590 if ((case_sensitive
)
1591 ? streq (*ext
, suffix
)
1592 : strcaseeq (*ext
, suffix
))
1599 * This routine is called on each file argument.
1602 process_file_name (file
, lang
)
1606 struct stat stat_buf
;
1610 char *compressed_name
, *uncompressed_name
;
1611 char *ext
, *real_name
;
1614 canonicalize_filename (file
);
1615 if (streq (file
, tagfile
) && !streq (tagfile
, "-"))
1617 error ("skipping inclusion of %s in self.", file
);
1620 if ((compr
= get_compressor_from_suffix (file
, &ext
)) == NULL
)
1622 compressed_name
= NULL
;
1623 real_name
= uncompressed_name
= savestr (file
);
1627 real_name
= compressed_name
= savestr (file
);
1628 uncompressed_name
= savenstr (file
, ext
- file
);
1631 /* If the canonicalized uncompressed name
1632 has already been dealt with, skip it silently. */
1633 for (fdp
= fdhead
; fdp
!= NULL
; fdp
= fdp
->next
)
1635 assert (fdp
->infname
!= NULL
);
1636 if (streq (uncompressed_name
, fdp
->infname
))
1640 if (stat (real_name
, &stat_buf
) != 0)
1642 /* Reset real_name and try with a different name. */
1644 if (compressed_name
!= NULL
) /* try with the given suffix */
1646 if (stat (uncompressed_name
, &stat_buf
) == 0)
1647 real_name
= uncompressed_name
;
1649 else /* try all possible suffixes */
1651 for (compr
= compressors
; compr
->suffix
!= NULL
; compr
++)
1653 compressed_name
= concat (file
, ".", compr
->suffix
);
1654 if (stat (compressed_name
, &stat_buf
) != 0)
1658 char *suf
= compressed_name
+ strlen (file
);
1659 size_t suflen
= strlen (compr
->suffix
) + 1;
1660 for ( ; suf
[1]; suf
++, suflen
--)
1662 memmove (suf
, suf
+ 1, suflen
);
1663 if (stat (compressed_name
, &stat_buf
) == 0)
1665 real_name
= compressed_name
;
1669 if (real_name
!= NULL
)
1672 free (compressed_name
);
1673 compressed_name
= NULL
;
1677 real_name
= compressed_name
;
1682 if (real_name
== NULL
)
1687 } /* try with a different name */
1689 if (!S_ISREG (stat_buf
.st_mode
))
1691 error ("skipping %s: it is not a regular file.", real_name
);
1694 if (real_name
== compressed_name
)
1696 char *cmd
= concat (compr
->command
, " ", real_name
);
1697 inf
= (FILE *) popen (cmd
, "r");
1701 inf
= fopen (real_name
, "r");
1708 process_file (inf
, uncompressed_name
, lang
);
1710 if (real_name
== compressed_name
)
1711 retval
= pclose (inf
);
1713 retval
= fclose (inf
);
1718 if (compressed_name
) free (compressed_name
);
1719 if (uncompressed_name
) free (uncompressed_name
);
1726 process_file (fh
, fn
, lang
)
1731 static const fdesc emptyfdesc
;
1734 /* Create a new input file description entry. */
1735 fdp
= xnew (1, fdesc
);
1738 fdp
->infname
= savestr (fn
);
1740 fdp
->infabsname
= absolute_filename (fn
, cwd
);
1741 fdp
->infabsdir
= absolute_dirname (fn
, cwd
);
1742 if (filename_is_absolute (fn
))
1744 /* An absolute file name. Canonicalize it. */
1745 fdp
->taggedfname
= absolute_filename (fn
, NULL
);
1749 /* A file name relative to cwd. Make it relative
1750 to the directory of the tags file. */
1751 fdp
->taggedfname
= relative_filename (fn
, tagfiledir
);
1753 fdp
->usecharno
= TRUE
; /* use char position when making tags */
1755 fdp
->written
= FALSE
; /* not written on tags file yet */
1758 curfdp
= fdhead
; /* the current file description */
1762 /* If not Ctags, and if this is not metasource and if it contained no #line
1763 directives, we can write the tags and free all nodes pointing to
1766 && curfdp
->usecharno
/* no #line directives in this file */
1767 && !curfdp
->lang
->metasource
)
1771 /* Look for the head of the sublist relative to this file. See add_node
1772 for the structure of the node tree. */
1774 for (np
= nodehead
; np
!= NULL
; prev
= np
, np
= np
->left
)
1775 if (np
->fdp
== curfdp
)
1778 /* If we generated tags for this file, write and delete them. */
1781 /* This is the head of the last sublist, if any. The following
1782 instructions depend on this being true. */
1783 assert (np
->left
== NULL
);
1785 assert (fdhead
== curfdp
);
1786 assert (last_node
->fdp
== curfdp
);
1787 put_entries (np
); /* write tags for file curfdp->taggedfname */
1788 free_tree (np
); /* remove the written nodes */
1790 nodehead
= NULL
; /* no nodes left */
1792 prev
->left
= NULL
; /* delete the pointer to the sublist */
1798 * This routine sets up the boolean pseudo-functions which work
1799 * by setting boolean flags dependent upon the corresponding character.
1800 * Every char which is NOT in that string is not a white char. Therefore,
1801 * all of the array "_wht" is set to FALSE, and then the elements
1802 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
1803 * of a char is TRUE if it is the string "white", else FALSE.
1811 for (i
= 0; i
< CHARS
; i
++)
1812 iswhite(i
) = notinname(i
) = begtoken(i
) = intoken(i
) = endtoken(i
) = FALSE
;
1813 for (sp
= white
; *sp
!= '\0'; sp
++) iswhite (*sp
) = TRUE
;
1814 for (sp
= nonam
; *sp
!= '\0'; sp
++) notinname (*sp
) = TRUE
;
1815 notinname('\0') = notinname('\n');
1816 for (sp
= begtk
; *sp
!= '\0'; sp
++) begtoken (*sp
) = TRUE
;
1817 begtoken('\0') = begtoken('\n');
1818 for (sp
= midtk
; *sp
!= '\0'; sp
++) intoken (*sp
) = TRUE
;
1819 intoken('\0') = intoken('\n');
1820 for (sp
= endtk
; *sp
!= '\0'; sp
++) endtoken (*sp
) = TRUE
;
1821 endtoken('\0') = endtoken('\n');
1825 * This routine opens the specified file and calls the function
1826 * which finds the function and type definitions.
1833 language
*lang
= curfdp
->lang
;
1834 Lang_function
*parser
= NULL
;
1836 /* If user specified a language, use it. */
1837 if (lang
!= NULL
&& lang
->function
!= NULL
)
1839 parser
= lang
->function
;
1842 /* Else try to guess the language given the file name. */
1845 lang
= get_language_from_filename (curfdp
->infname
, TRUE
);
1846 if (lang
!= NULL
&& lang
->function
!= NULL
)
1848 curfdp
->lang
= lang
;
1849 parser
= lang
->function
;
1853 /* Else look for sharp-bang as the first two characters. */
1855 && readline_internal (&lb
, inf
) > 0
1857 && lb
.buffer
[0] == '#'
1858 && lb
.buffer
[1] == '!')
1862 /* Set lp to point at the first char after the last slash in the
1863 line or, if no slashes, at the first nonblank. Then set cp to
1864 the first successive blank and terminate the string. */
1865 lp
= etags_strrchr (lb
.buffer
+2, '/');
1869 lp
= skip_spaces (lb
.buffer
+ 2);
1870 cp
= skip_non_spaces (lp
);
1873 if (strlen (lp
) > 0)
1875 lang
= get_language_from_interpreter (lp
);
1876 if (lang
!= NULL
&& lang
->function
!= NULL
)
1878 curfdp
->lang
= lang
;
1879 parser
= lang
->function
;
1884 /* We rewind here, even if inf may be a pipe. We fail if the
1885 length of the first line is longer than the pipe block size,
1886 which is unlikely. */
1889 /* Else try to guess the language given the case insensitive file name. */
1892 lang
= get_language_from_filename (curfdp
->infname
, FALSE
);
1893 if (lang
!= NULL
&& lang
->function
!= NULL
)
1895 curfdp
->lang
= lang
;
1896 parser
= lang
->function
;
1900 /* Else try Fortran or C. */
1903 node
*old_last_node
= last_node
;
1905 curfdp
->lang
= get_language_from_langname ("fortran");
1908 if (old_last_node
== last_node
)
1909 /* No Fortran entries found. Try C. */
1911 /* We do not tag if rewind fails.
1912 Only the file name will be recorded in the tags file. */
1914 curfdp
->lang
= get_language_from_langname (cplusplus
? "c++" : "c");
1920 if (!no_line_directive
1921 && curfdp
->lang
!= NULL
&& curfdp
->lang
->metasource
)
1922 /* It may be that this is a bingo.y file, and we already parsed a bingo.c
1923 file, or anyway we parsed a file that is automatically generated from
1924 this one. If this is the case, the bingo.c file contained #line
1925 directives that generated tags pointing to this file. Let's delete
1926 them all before parsing this file, which is the real source. */
1928 fdesc
**fdpp
= &fdhead
;
1929 while (*fdpp
!= NULL
)
1931 && streq ((*fdpp
)->taggedfname
, curfdp
->taggedfname
))
1932 /* We found one of those! We must delete both the file description
1933 and all tags referring to it. */
1935 fdesc
*badfdp
= *fdpp
;
1937 /* Delete the tags referring to badfdp->taggedfname
1938 that were obtained from badfdp->infname. */
1939 invalidate_nodes (badfdp
, &nodehead
);
1941 *fdpp
= badfdp
->next
; /* remove the bad description from the list */
1942 free_fdesc (badfdp
);
1945 fdpp
= &(*fdpp
)->next
; /* advance the list pointer */
1948 assert (parser
!= NULL
);
1950 /* Generic initialisations before reading from file. */
1951 linebuffer_setlen (&filebuf
, 0); /* reset the file buffer */
1953 /* Generic initialisations before parsing file with readline. */
1954 lineno
= 0; /* reset global line number */
1955 charno
= 0; /* reset global char number */
1956 linecharno
= 0; /* reset global char number of line start */
1960 regex_tag_multiline ();
1965 * Check whether an implicitly named tag should be created,
1966 * then call `pfnote'.
1967 * NAME is a string that is internally copied by this function.
1969 * TAGS format specification
1970 * Idea by Sam Kendall <kendall@mv.mv.com> (1997)
1971 * The following is explained in some more detail in etc/ETAGS.EBNF.
1973 * make_tag creates tags with "implicit tag names" (unnamed tags)
1974 * if the following are all true, assuming NONAM=" \f\t\n\r()=,;":
1975 * 1. NAME does not contain any of the characters in NONAM;
1976 * 2. LINESTART contains name as either a rightmost, or rightmost but
1977 * one character, substring;
1978 * 3. the character, if any, immediately before NAME in LINESTART must
1979 * be a character in NONAM;
1980 * 4. the character, if any, immediately after NAME in LINESTART must
1981 * also be a character in NONAM.
1983 * The implementation uses the notinname() macro, which recognises the
1984 * characters stored in the string `nonam'.
1985 * etags.el needs to use the same characters that are in NONAM.
1988 make_tag (name
, namelen
, is_func
, linestart
, linelen
, lno
, cno
)
1989 char *name
; /* tag name, or NULL if unnamed */
1990 int namelen
; /* tag length */
1991 bool is_func
; /* tag is a function */
1992 char *linestart
; /* start of the line where tag is */
1993 int linelen
; /* length of the line where tag is */
1994 int lno
; /* line number */
1995 long cno
; /* character number */
1997 bool named
= (name
!= NULL
&& namelen
> 0);
1999 if (!CTAGS
&& named
) /* maybe set named to false */
2000 /* Let's try to make an implicit tag name, that is, create an unnamed tag
2001 such that etags.el can guess a name from it. */
2004 register char *cp
= name
;
2006 for (i
= 0; i
< namelen
; i
++)
2007 if (notinname (*cp
++))
2009 if (i
== namelen
) /* rule #1 */
2011 cp
= linestart
+ linelen
- namelen
;
2012 if (notinname (linestart
[linelen
-1]))
2013 cp
-= 1; /* rule #4 */
2014 if (cp
>= linestart
/* rule #2 */
2016 || notinname (cp
[-1])) /* rule #3 */
2017 && strneq (name
, cp
, namelen
)) /* rule #2 */
2018 named
= FALSE
; /* use implicit tag name */
2023 name
= savenstr (name
, namelen
);
2026 pfnote (name
, is_func
, linestart
, linelen
, lno
, cno
);
2031 pfnote (name
, is_func
, linestart
, linelen
, lno
, cno
)
2032 char *name
; /* tag name, or NULL if unnamed */
2033 bool is_func
; /* tag is a function */
2034 char *linestart
; /* start of the line where tag is */
2035 int linelen
; /* length of the line where tag is */
2036 int lno
; /* line number */
2037 long cno
; /* character number */
2041 assert (name
== NULL
|| name
[0] != '\0');
2042 if (CTAGS
&& name
== NULL
)
2045 np
= xnew (1, node
);
2047 /* If ctags mode, change name "main" to M<thisfilename>. */
2048 if (CTAGS
&& !cxref_style
&& streq (name
, "main"))
2050 register char *fp
= etags_strrchr (curfdp
->taggedfname
, '/');
2051 np
->name
= concat ("M", fp
== NULL
? curfdp
->taggedfname
: fp
+ 1, "");
2052 fp
= etags_strrchr (np
->name
, '.');
2053 if (fp
!= NULL
&& fp
[1] != '\0' && fp
[2] == '\0')
2059 np
->been_warned
= FALSE
;
2061 np
->is_func
= is_func
;
2063 if (np
->fdp
->usecharno
)
2064 /* Our char numbers are 0-base, because of C language tradition?
2065 ctags compatibility? old versions compatibility? I don't know.
2066 Anyway, since emacs's are 1-base we expect etags.el to take care
2067 of the difference. If we wanted to have 1-based numbers, we would
2068 uncomment the +1 below. */
2069 np
->cno
= cno
/* + 1 */ ;
2071 np
->cno
= invalidcharno
;
2072 np
->left
= np
->right
= NULL
;
2073 if (CTAGS
&& !cxref_style
)
2075 if (strlen (linestart
) < 50)
2076 np
->regex
= concat (linestart
, "$", "");
2078 np
->regex
= savenstr (linestart
, 50);
2081 np
->regex
= savenstr (linestart
, linelen
);
2083 add_node (np
, &nodehead
);
2088 * recurse on left children, iterate on right children.
2096 register node
*node_right
= np
->right
;
2097 free_tree (np
->left
);
2098 if (np
->name
!= NULL
)
2108 * delete a file description
2112 register fdesc
*fdp
;
2114 if (fdp
->infname
!= NULL
) free (fdp
->infname
);
2115 if (fdp
->infabsname
!= NULL
) free (fdp
->infabsname
);
2116 if (fdp
->infabsdir
!= NULL
) free (fdp
->infabsdir
);
2117 if (fdp
->taggedfname
!= NULL
) free (fdp
->taggedfname
);
2118 if (fdp
->prop
!= NULL
) free (fdp
->prop
);
2124 * Adds a node to the tree of nodes. In etags mode, sort by file
2125 * name. In ctags mode, sort by tag name. Make no attempt at
2128 * add_node is the only function allowed to add nodes, so it can
2132 add_node (np
, cur_node_p
)
2133 node
*np
, **cur_node_p
;
2136 register node
*cur_node
= *cur_node_p
;
2138 if (cur_node
== NULL
)
2148 /* For each file name, tags are in a linked sublist on the right
2149 pointer. The first tags of different files are a linked list
2150 on the left pointer. last_node points to the end of the last
2152 if (last_node
!= NULL
&& last_node
->fdp
== np
->fdp
)
2154 /* Let's use the same sublist as the last added node. */
2155 assert (last_node
->right
== NULL
);
2156 last_node
->right
= np
;
2159 else if (cur_node
->fdp
== np
->fdp
)
2161 /* Scanning the list we found the head of a sublist which is
2162 good for us. Let's scan this sublist. */
2163 add_node (np
, &cur_node
->right
);
2166 /* The head of this sublist is not good for us. Let's try the
2168 add_node (np
, &cur_node
->left
);
2169 } /* if ETAGS mode */
2174 dif
= strcmp (np
->name
, cur_node
->name
);
2177 * If this tag name matches an existing one, then
2178 * do not add the node, but maybe print a warning.
2180 if (no_duplicates
&& !dif
)
2182 if (np
->fdp
== cur_node
->fdp
)
2186 fprintf (stderr
, "Duplicate entry in file %s, line %d: %s\n",
2187 np
->fdp
->infname
, lineno
, np
->name
);
2188 fprintf (stderr
, "Second entry ignored\n");
2191 else if (!cur_node
->been_warned
&& !no_warnings
)
2195 "Duplicate entry in files %s and %s: %s (Warning only)\n",
2196 np
->fdp
->infname
, cur_node
->fdp
->infname
, np
->name
);
2197 cur_node
->been_warned
= TRUE
;
2202 /* Actually add the node */
2203 add_node (np
, dif
< 0 ? &cur_node
->left
: &cur_node
->right
);
2204 } /* if CTAGS mode */
2208 * invalidate_nodes ()
2209 * Scan the node tree and invalidate all nodes pointing to the
2210 * given file description (CTAGS case) or free them (ETAGS case).
2213 invalidate_nodes (badfdp
, npp
)
2224 if (np
->left
!= NULL
)
2225 invalidate_nodes (badfdp
, &np
->left
);
2226 if (np
->fdp
== badfdp
)
2228 if (np
->right
!= NULL
)
2229 invalidate_nodes (badfdp
, &np
->right
);
2233 assert (np
->fdp
!= NULL
);
2234 if (np
->fdp
== badfdp
)
2236 *npp
= np
->left
; /* detach the sublist from the list */
2237 np
->left
= NULL
; /* isolate it */
2238 free_tree (np
); /* free it */
2239 invalidate_nodes (badfdp
, npp
);
2242 invalidate_nodes (badfdp
, &np
->left
);
2247 static int total_size_of_entries
__P((node
*));
2248 static int number_len
__P((long));
2250 /* Length of a non-negative number's decimal representation. */
2256 while ((num
/= 10) > 0)
2262 * Return total number of characters that put_entries will output for
2263 * the nodes in the linked list at the right of the specified node.
2264 * This count is irrelevant with etags.el since emacs 19.34 at least,
2265 * but is still supplied for backward compatibility.
2268 total_size_of_entries (np
)
2271 register int total
= 0;
2273 for (; np
!= NULL
; np
= np
->right
)
2276 total
+= strlen (np
->regex
) + 1; /* pat\177 */
2277 if (np
->name
!= NULL
)
2278 total
+= strlen (np
->name
) + 1; /* name\001 */
2279 total
+= number_len ((long) np
->lno
) + 1; /* lno, */
2280 if (np
->cno
!= invalidcharno
) /* cno */
2281 total
+= number_len (np
->cno
);
2282 total
+= 1; /* newline */
2293 static fdesc
*fdp
= NULL
;
2298 /* Output subentries that precede this one */
2300 put_entries (np
->left
);
2302 /* Output this entry */
2311 fprintf (tagf
, "\f\n%s,%d\n",
2312 fdp
->taggedfname
, total_size_of_entries (np
));
2313 fdp
->written
= TRUE
;
2315 fputs (np
->regex
, tagf
);
2316 fputc ('\177', tagf
);
2317 if (np
->name
!= NULL
)
2319 fputs (np
->name
, tagf
);
2320 fputc ('\001', tagf
);
2322 fprintf (tagf
, "%d,", np
->lno
);
2323 if (np
->cno
!= invalidcharno
)
2324 fprintf (tagf
, "%ld", np
->cno
);
2330 if (np
->name
== NULL
)
2331 error ("internal error: NULL name in ctags mode.", (char *)NULL
);
2336 fprintf (stdout
, "%s %s %d\n",
2337 np
->name
, np
->fdp
->taggedfname
, (np
->lno
+ 63) / 64);
2339 fprintf (stdout
, "%-16s %3d %-16s %s\n",
2340 np
->name
, np
->lno
, np
->fdp
->taggedfname
, np
->regex
);
2344 fprintf (tagf
, "%s\t%s\t", np
->name
, np
->fdp
->taggedfname
);
2347 { /* function or #define macro with args */
2348 putc (searchar
, tagf
);
2351 for (sp
= np
->regex
; *sp
; sp
++)
2353 if (*sp
== '\\' || *sp
== searchar
)
2357 putc (searchar
, tagf
);
2360 { /* anything else; text pattern inadequate */
2361 fprintf (tagf
, "%d", np
->lno
);
2366 } /* if this node contains a valid tag */
2368 /* Output subentries that follow this one */
2369 put_entries (np
->right
);
2371 put_entries (np
->left
);
2376 #define C_EXT 0x00fff /* C extensions */
2377 #define C_PLAIN 0x00000 /* C */
2378 #define C_PLPL 0x00001 /* C++ */
2379 #define C_STAR 0x00003 /* C* */
2380 #define C_JAVA 0x00005 /* JAVA */
2381 #define C_AUTO 0x01000 /* C, but switch to C++ if `class' is met */
2382 #define YACC 0x10000 /* yacc file */
2385 * The C symbol tables.
2390 st_C_objprot
, st_C_objimpl
, st_C_objend
,
2392 st_C_ignore
, st_C_attribute
,
2395 st_C_class
, st_C_template
,
2396 st_C_struct
, st_C_extern
, st_C_enum
, st_C_define
, st_C_typedef
2399 static unsigned int hash
__P((const char *, unsigned int));
2400 static struct C_stab_entry
* in_word_set
__P((const char *, unsigned int));
2401 static enum sym_type C_symtype
__P((char *, int, int));
2403 /* Feed stuff between (but not including) %[ and %] lines to:
2409 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
2413 while, 0, st_C_ignore
2414 switch, 0, st_C_ignore
2415 return, 0, st_C_ignore
2416 __attribute__, 0, st_C_attribute
2417 @interface, 0, st_C_objprot
2418 @protocol, 0, st_C_objprot
2419 @implementation,0, st_C_objimpl
2420 @end, 0, st_C_objend
2421 import, (C_JAVA & !C_PLPL), st_C_ignore
2422 package, (C_JAVA & !C_PLPL), st_C_ignore
2423 friend, C_PLPL, st_C_ignore
2424 extends, (C_JAVA & !C_PLPL), st_C_javastruct
2425 implements, (C_JAVA & !C_PLPL), st_C_javastruct
2426 interface, (C_JAVA & !C_PLPL), st_C_struct
2427 class, 0, st_C_class
2428 namespace, C_PLPL, st_C_struct
2429 domain, C_STAR, st_C_struct
2430 union, 0, st_C_struct
2431 struct, 0, st_C_struct
2432 extern, 0, st_C_extern
2434 typedef, 0, st_C_typedef
2435 define, 0, st_C_define
2436 undef, 0, st_C_define
2437 operator, C_PLPL, st_C_operator
2438 template, 0, st_C_template
2439 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
2440 DEFUN, 0, st_C_gnumacro
2441 SYSCALL, 0, st_C_gnumacro
2442 ENTRY, 0, st_C_gnumacro
2443 PSEUDO, 0, st_C_gnumacro
2444 # These are defined inside C functions, so currently they are not met.
2445 # EXFUN used in glibc, DEFVAR_* in emacs.
2446 #EXFUN, 0, st_C_gnumacro
2447 #DEFVAR_, 0, st_C_gnumacro
2449 and replace lines between %< and %> with its output, then:
2450 - remove the #if characterset check
2451 - make in_word_set static and not inline. */
2453 /* C code produced by gperf version 3.0.1 */
2454 /* Command-line: gperf -m 5 */
2455 /* Computed positions: -k'2-3' */
2457 struct C_stab_entry
{ char *name
; int c_ext
; enum sym_type type
; };
2458 /* maximum key range = 33, duplicates = 0 */
2469 register const char *str
;
2470 register unsigned int len
;
2472 static unsigned char asso_values
[] =
2474 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2475 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2476 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2477 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2478 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2479 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2480 35, 35, 35, 35, 35, 35, 35, 35, 35, 15,
2481 14, 35, 35, 35, 35, 35, 35, 35, 14, 35,
2482 35, 35, 35, 12, 13, 35, 35, 35, 35, 12,
2483 35, 35, 35, 35, 35, 1, 35, 16, 35, 6,
2484 23, 0, 0, 35, 22, 0, 35, 35, 5, 0,
2485 0, 15, 1, 35, 6, 35, 8, 19, 35, 16,
2486 4, 5, 35, 35, 35, 35, 35, 35, 35, 35,
2487 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2488 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2489 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2490 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2491 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2492 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2493 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2494 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2495 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2496 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2497 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2498 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
2499 35, 35, 35, 35, 35, 35
2501 register int hval
= len
;
2506 hval
+= asso_values
[(unsigned char)str
[2]];
2509 hval
+= asso_values
[(unsigned char)str
[1]];
2515 static struct C_stab_entry
*
2516 in_word_set (str
, len
)
2517 register const char *str
;
2518 register unsigned int len
;
2522 TOTAL_KEYWORDS
= 32,
2523 MIN_WORD_LENGTH
= 2,
2524 MAX_WORD_LENGTH
= 15,
2529 static struct C_stab_entry wordlist
[] =
2532 {"if", 0, st_C_ignore
},
2534 {"@end", 0, st_C_objend
},
2535 {"union", 0, st_C_struct
},
2536 {"define", 0, st_C_define
},
2537 {"import", (C_JAVA
& !C_PLPL
), st_C_ignore
},
2538 {"template", 0, st_C_template
},
2539 {"operator", C_PLPL
, st_C_operator
},
2540 {"@interface", 0, st_C_objprot
},
2541 {"implements", (C_JAVA
& !C_PLPL
), st_C_javastruct
},
2542 {"friend", C_PLPL
, st_C_ignore
},
2543 {"typedef", 0, st_C_typedef
},
2544 {"return", 0, st_C_ignore
},
2545 {"@implementation",0, st_C_objimpl
},
2546 {"@protocol", 0, st_C_objprot
},
2547 {"interface", (C_JAVA
& !C_PLPL
), st_C_struct
},
2548 {"extern", 0, st_C_extern
},
2549 {"extends", (C_JAVA
& !C_PLPL
), st_C_javastruct
},
2550 {"struct", 0, st_C_struct
},
2551 {"domain", C_STAR
, st_C_struct
},
2552 {"switch", 0, st_C_ignore
},
2553 {"enum", 0, st_C_enum
},
2554 {"for", 0, st_C_ignore
},
2555 {"namespace", C_PLPL
, st_C_struct
},
2556 {"class", 0, st_C_class
},
2557 {"while", 0, st_C_ignore
},
2558 {"undef", 0, st_C_define
},
2559 {"package", (C_JAVA
& !C_PLPL
), st_C_ignore
},
2560 {"__attribute__", 0, st_C_attribute
},
2561 {"SYSCALL", 0, st_C_gnumacro
},
2562 {"ENTRY", 0, st_C_gnumacro
},
2563 {"PSEUDO", 0, st_C_gnumacro
},
2564 {"DEFUN", 0, st_C_gnumacro
}
2567 if (len
<= MAX_WORD_LENGTH
&& len
>= MIN_WORD_LENGTH
)
2569 register int key
= hash (str
, len
);
2571 if (key
<= MAX_HASH_VALUE
&& key
>= 0)
2573 register const char *s
= wordlist
[key
].name
;
2575 if (*str
== *s
&& !strncmp (str
+ 1, s
+ 1, len
- 1) && s
[len
] == '\0')
2576 return &wordlist
[key
];
2583 static enum sym_type
2584 C_symtype (str
, len
, c_ext
)
2589 register struct C_stab_entry
*se
= in_word_set (str
, len
);
2591 if (se
== NULL
|| (se
->c_ext
&& !(c_ext
& se
->c_ext
)))
2598 * Ignoring __attribute__ ((list))
2600 static bool inattribute
; /* looking at an __attribute__ construct */
2603 * C functions and variables are recognized using a simple
2604 * finite automaton. fvdef is its state variable.
2608 fvnone
, /* nothing seen */
2609 fdefunkey
, /* Emacs DEFUN keyword seen */
2610 fdefunname
, /* Emacs DEFUN name seen */
2611 foperator
, /* func: operator keyword seen (cplpl) */
2612 fvnameseen
, /* function or variable name seen */
2613 fstartlist
, /* func: just after open parenthesis */
2614 finlist
, /* func: in parameter list */
2615 flistseen
, /* func: after parameter list */
2616 fignore
, /* func: before open brace */
2617 vignore
/* var-like: ignore until ';' */
2620 static bool fvextern
; /* func or var: extern keyword seen; */
2623 * typedefs are recognized using a simple finite automaton.
2624 * typdef is its state variable.
2628 tnone
, /* nothing seen */
2629 tkeyseen
, /* typedef keyword seen */
2630 ttypeseen
, /* defined type seen */
2631 tinbody
, /* inside typedef body */
2632 tend
, /* just before typedef tag */
2633 tignore
/* junk after typedef tag */
2637 * struct-like structures (enum, struct and union) are recognized
2638 * using another simple finite automaton. `structdef' is its state
2643 snone
, /* nothing seen yet,
2644 or in struct body if bracelev > 0 */
2645 skeyseen
, /* struct-like keyword seen */
2646 stagseen
, /* struct-like tag seen */
2647 scolonseen
/* colon seen after struct-like tag */
2651 * When objdef is different from onone, objtag is the name of the class.
2653 static char *objtag
= "<uninited>";
2656 * Yet another little state machine to deal with preprocessor lines.
2660 dnone
, /* nothing seen */
2661 dsharpseen
, /* '#' seen as first char on line */
2662 ddefineseen
, /* '#' and 'define' seen */
2663 dignorerest
/* ignore rest of line */
2667 * State machine for Objective C protocols and implementations.
2668 * Idea by Tom R.Hageman <tom@basil.icce.rug.nl> (1995)
2672 onone
, /* nothing seen */
2673 oprotocol
, /* @interface or @protocol seen */
2674 oimplementation
, /* @implementations seen */
2675 otagseen
, /* class name seen */
2676 oparenseen
, /* parenthesis before category seen */
2677 ocatseen
, /* category name seen */
2678 oinbody
, /* in @implementation body */
2679 omethodsign
, /* in @implementation body, after +/- */
2680 omethodtag
, /* after method name */
2681 omethodcolon
, /* after method colon */
2682 omethodparm
, /* after method parameter */
2683 oignore
/* wait for @end */
2688 * Use this structure to keep info about the token read, and how it
2689 * should be tagged. Used by the make_C_tag function to build a tag.
2693 char *line
; /* string containing the token */
2694 int offset
; /* where the token starts in LINE */
2695 int length
; /* token length */
2697 The previous members can be used to pass strings around for generic
2698 purposes. The following ones specifically refer to creating tags. In this
2699 case the token contained here is the pattern that will be used to create a
2702 bool valid
; /* do not create a tag; the token should be
2703 invalidated whenever a state machine is
2704 reset prematurely */
2705 bool named
; /* create a named tag */
2706 int lineno
; /* source line number of tag */
2707 long linepos
; /* source char number of tag */
2708 } token
; /* latest token read */
2711 * Variables and functions for dealing with nested structures.
2712 * Idea by Mykola Dzyuba <mdzyuba@yahoo.com> (2001)
2714 static void pushclass_above
__P((int, char *, int));
2715 static void popclass_above
__P((int));
2716 static void write_classname
__P((linebuffer
*, char *qualifier
));
2719 char **cname
; /* nested class names */
2720 int *bracelev
; /* nested class brace level */
2721 int nl
; /* class nesting level (elements used) */
2722 int size
; /* length of the array */
2723 } cstack
; /* stack for nested declaration tags */
2724 /* Current struct nesting depth (namespace, class, struct, union, enum). */
2725 #define nestlev (cstack.nl)
2726 /* After struct keyword or in struct body, not inside a nested function. */
2727 #define instruct (structdef == snone && nestlev > 0 \
2728 && bracelev == cstack.bracelev[nestlev-1] + 1)
2731 pushclass_above (bracelev
, str
, len
)
2738 popclass_above (bracelev
);
2740 if (nl
>= cstack
.size
)
2742 int size
= cstack
.size
*= 2;
2743 xrnew (cstack
.cname
, size
, char *);
2744 xrnew (cstack
.bracelev
, size
, int);
2746 assert (nl
== 0 || cstack
.bracelev
[nl
-1] < bracelev
);
2747 cstack
.cname
[nl
] = (str
== NULL
) ? NULL
: savenstr (str
, len
);
2748 cstack
.bracelev
[nl
] = bracelev
;
2753 popclass_above (bracelev
)
2758 for (nl
= cstack
.nl
- 1;
2759 nl
>= 0 && cstack
.bracelev
[nl
] >= bracelev
;
2762 if (cstack
.cname
[nl
] != NULL
)
2763 free (cstack
.cname
[nl
]);
2769 write_classname (cn
, qualifier
)
2774 int qlen
= strlen (qualifier
);
2776 if (cstack
.nl
== 0 || cstack
.cname
[0] == NULL
)
2780 cn
->buffer
[0] = '\0';
2784 len
= strlen (cstack
.cname
[0]);
2785 linebuffer_setlen (cn
, len
);
2786 strcpy (cn
->buffer
, cstack
.cname
[0]);
2788 for (i
= 1; i
< cstack
.nl
; i
++)
2793 s
= cstack
.cname
[i
];
2798 linebuffer_setlen (cn
, len
);
2799 strncat (cn
->buffer
, qualifier
, qlen
);
2800 strncat (cn
->buffer
, s
, slen
);
2805 static bool consider_token
__P((char *, int, int, int *, int, int, bool *));
2806 static void make_C_tag
__P((bool));
2810 * checks to see if the current token is at the start of a
2811 * function or variable, or corresponds to a typedef, or
2812 * is a struct/union/enum tag, or #define, or an enum constant.
2814 * *IS_FUNC gets TRUE iff the token is a function or #define macro
2815 * with args. C_EXTP points to which language we are looking at.
2826 consider_token (str
, len
, c
, c_extp
, bracelev
, parlev
, is_func_or_var
)
2827 register char *str
; /* IN: token pointer */
2828 register int len
; /* IN: token length */
2829 register int c
; /* IN: first char after the token */
2830 int *c_extp
; /* IN, OUT: C extensions mask */
2831 int bracelev
; /* IN: brace level */
2832 int parlev
; /* IN: parenthesis level */
2833 bool *is_func_or_var
; /* OUT: function or variable found */
2835 /* When structdef is stagseen, scolonseen, or snone with bracelev > 0,
2836 structtype is the type of the preceding struct-like keyword, and
2837 structbracelev is the brace level where it has been seen. */
2838 static enum sym_type structtype
;
2839 static int structbracelev
;
2840 static enum sym_type toktype
;
2843 toktype
= C_symtype (str
, len
, *c_extp
);
2846 * Skip __attribute__
2848 if (toktype
== st_C_attribute
)
2855 * Advance the definedef state machine.
2860 /* We're not on a preprocessor line. */
2861 if (toktype
== st_C_gnumacro
)
2868 if (toktype
== st_C_define
)
2870 definedef
= ddefineseen
;
2874 definedef
= dignorerest
;
2879 * Make a tag for any macro, unless it is a constant
2880 * and constantypedefs is FALSE.
2882 definedef
= dignorerest
;
2883 *is_func_or_var
= (c
== '(');
2884 if (!*is_func_or_var
&& !constantypedefs
)
2891 error ("internal error: definedef value.", (char *)NULL
);
2900 if (toktype
== st_C_typedef
)
2920 if (structdef
== snone
&& fvdef
== fvnone
)
2938 * This structdef business is NOT invoked when we are ctags and the
2939 * file is plain C. This is because a struct tag may have the same
2940 * name as another tag, and this loses with ctags.
2944 case st_C_javastruct
:
2945 if (structdef
== stagseen
)
2946 structdef
= scolonseen
;
2950 if ((*c_extp
& C_AUTO
) /* automatic detection of C++ language */
2952 && definedef
== dnone
&& structdef
== snone
2953 && typdef
== tnone
&& fvdef
== fvnone
)
2954 *c_extp
= (*c_extp
| C_PLPL
) & ~C_AUTO
;
2955 if (toktype
== st_C_template
)
2962 && (typdef
== tkeyseen
2963 || (typedefs_or_cplusplus
&& structdef
== snone
)))
2965 structdef
= skeyseen
;
2966 structtype
= toktype
;
2967 structbracelev
= bracelev
;
2968 if (fvdef
== fvnameseen
)
2974 if (structdef
== skeyseen
)
2976 structdef
= stagseen
;
2980 if (typdef
!= tnone
)
2983 /* Detect Objective C constructs. */
2993 objdef
= oimplementation
;
2997 case oimplementation
:
2998 /* Save the class tag for functions or variables defined inside. */
2999 objtag
= savenstr (str
, len
);
3003 /* Save the class tag for categories. */
3004 objtag
= savenstr (str
, len
);
3006 *is_func_or_var
= TRUE
;
3010 *is_func_or_var
= TRUE
;
3018 objdef
= omethodtag
;
3019 linebuffer_setlen (&token_name
, len
);
3020 strncpy (token_name
.buffer
, str
, len
);
3021 token_name
.buffer
[len
] = '\0';
3027 objdef
= omethodparm
;
3033 objdef
= omethodtag
;
3034 linebuffer_setlen (&token_name
, token_name
.len
+ len
);
3035 strncat (token_name
.buffer
, str
, len
);
3040 if (toktype
== st_C_objend
)
3042 /* Memory leakage here: the string pointed by objtag is
3043 never released, because many tests would be needed to
3044 avoid breaking on incorrect input code. The amount of
3045 memory leaked here is the sum of the lengths of the
3053 /* A function, variable or enum constant? */
3075 *is_func_or_var
= TRUE
;
3079 && structdef
== snone
3080 && structtype
== st_C_enum
&& bracelev
> structbracelev
)
3081 return TRUE
; /* enum constant */
3087 fvdef
= fdefunname
; /* GNU macro */
3088 *is_func_or_var
= TRUE
;
3096 if ((strneq (str
, "asm", 3) && endtoken (str
[3]))
3097 || (strneq (str
, "__asm__", 7) && endtoken (str
[7])))
3106 if (len
>= 10 && strneq (str
+len
-10, "::operator", 10))
3108 if (*c_extp
& C_AUTO
) /* automatic detection of C++ */
3109 *c_extp
= (*c_extp
| C_PLPL
) & ~C_AUTO
;
3111 *is_func_or_var
= TRUE
;
3114 if (bracelev
> 0 && !instruct
)
3116 fvdef
= fvnameseen
; /* function or variable */
3117 *is_func_or_var
= TRUE
;
3128 * C_entries often keeps pointers to tokens or lines which are older than
3129 * the line currently read. By keeping two line buffers, and switching
3130 * them at end of line, it is possible to use those pointers.
3138 #define current_lb_is_new (newndx == curndx)
3139 #define switch_line_buffers() (curndx = 1 - curndx)
3141 #define curlb (lbs[curndx].lb)
3142 #define newlb (lbs[newndx].lb)
3143 #define curlinepos (lbs[curndx].linepos)
3144 #define newlinepos (lbs[newndx].linepos)
3146 #define plainc ((c_ext & C_EXT) == C_PLAIN)
3147 #define cplpl (c_ext & C_PLPL)
3148 #define cjava ((c_ext & C_JAVA) == C_JAVA)
3150 #define CNL_SAVE_DEFINEDEF() \
3152 curlinepos = charno; \
3153 readline (&curlb, inf); \
3154 lp = curlb.buffer; \
3161 CNL_SAVE_DEFINEDEF(); \
3162 if (savetoken.valid) \
3164 token = savetoken; \
3165 savetoken.valid = FALSE; \
3167 definedef = dnone; \
3175 /* This function is never called when token.valid is FALSE, but
3176 we must protect against invalid input or internal errors. */
3177 if (!DEBUG
&& !token
.valid
)
3181 make_tag (token_name
.buffer
, token_name
.len
, isfun
, token
.line
,
3182 token
.offset
+token
.length
+1, token
.lineno
, token
.linepos
);
3183 else /* this case is optimised away if !DEBUG */
3184 make_tag (concat ("INVALID TOKEN:-->", token_name
.buffer
, ""),
3185 token_name
.len
+ 17, isfun
, token
.line
,
3186 token
.offset
+token
.length
+1, token
.lineno
, token
.linepos
);
3188 token
.valid
= FALSE
;
3194 * This routine finds functions, variables, typedefs,
3195 * #define's, enum constants and struct/union/enum definitions in
3196 * C syntax and adds them to the list.
3199 C_entries (c_ext
, inf
)
3200 int c_ext
; /* extension of C */
3201 FILE *inf
; /* input file */
3203 register char c
; /* latest char read; '\0' for end of line */
3204 register char *lp
; /* pointer one beyond the character `c' */
3205 int curndx
, newndx
; /* indices for current and new lb */
3206 register int tokoff
; /* offset in line of start of current token */
3207 register int toklen
; /* length of current token */
3208 char *qualifier
; /* string used to qualify names */
3209 int qlen
; /* length of qualifier */
3210 int bracelev
; /* current brace level */
3211 int bracketlev
; /* current bracket level */
3212 int parlev
; /* current parenthesis level */
3213 int attrparlev
; /* __attribute__ parenthesis level */
3214 int templatelev
; /* current template level */
3215 int typdefbracelev
; /* bracelev where a typedef struct body begun */
3216 bool incomm
, inquote
, inchar
, quotednl
, midtoken
;
3217 bool yacc_rules
; /* in the rules part of a yacc file */
3218 struct tok savetoken
= {0}; /* token saved during preprocessor handling */
3221 linebuffer_init (&lbs
[0].lb
);
3222 linebuffer_init (&lbs
[1].lb
);
3223 if (cstack
.size
== 0)
3225 cstack
.size
= (DEBUG
) ? 1 : 4;
3227 cstack
.cname
= xnew (cstack
.size
, char *);
3228 cstack
.bracelev
= xnew (cstack
.size
, int);
3231 tokoff
= toklen
= typdefbracelev
= 0; /* keep compiler quiet */
3232 curndx
= newndx
= 0;
3236 fvdef
= fvnone
; fvextern
= FALSE
; typdef
= tnone
;
3237 structdef
= snone
; definedef
= dnone
; objdef
= onone
;
3239 midtoken
= inquote
= inchar
= incomm
= quotednl
= FALSE
;
3240 token
.valid
= savetoken
.valid
= FALSE
;
3241 bracelev
= bracketlev
= parlev
= attrparlev
= templatelev
= 0;
3243 { qualifier
= "."; qlen
= 1; }
3245 { qualifier
= "::"; qlen
= 2; }
3253 /* If we are at the end of the line, the next character is a
3254 '\0'; do not skip it, because it is what tells us
3255 to read the next line. */
3276 /* Newlines inside comments do not end macro definitions in
3278 CNL_SAVE_DEFINEDEF ();
3291 /* Newlines inside strings do not end macro definitions
3292 in traditional cpp, even though compilers don't
3293 usually accept them. */
3294 CNL_SAVE_DEFINEDEF ();
3304 /* Hmmm, something went wrong. */
3313 else if (bracketlev
> 0)
3318 if (--bracketlev
> 0)
3322 CNL_SAVE_DEFINEDEF ();
3350 if (fvdef
!= finlist
&& fvdef
!= fignore
&& fvdef
!=vignore
)
3363 else if (/* cplpl && */ *lp
== '/')
3371 if ((c_ext
& YACC
) && *lp
== '%')
3373 /* Entering or exiting rules section in yacc file. */
3375 definedef
= dnone
; fvdef
= fvnone
; fvextern
= FALSE
;
3376 typdef
= tnone
; structdef
= snone
;
3377 midtoken
= inquote
= inchar
= incomm
= quotednl
= FALSE
;
3379 yacc_rules
= !yacc_rules
;
3385 if (definedef
== dnone
)
3388 bool cpptoken
= TRUE
;
3390 /* Look back on this line. If all blanks, or nonblanks
3391 followed by an end of comment, this is a preprocessor
3393 for (cp
= newlb
.buffer
; cp
< lp
-1; cp
++)
3396 if (*cp
== '*' && *(cp
+1) == '/')
3405 definedef
= dsharpseen
;
3406 } /* if (definedef == dnone) */
3414 /* Consider token only if some involved conditions are satisfied. */
3415 if (typdef
!= tignore
3416 && definedef
!= dignorerest
3419 && (definedef
!= dnone
3420 || structdef
!= scolonseen
)
3427 if (c
== ':' && *lp
== ':' && begtoken (lp
[1]))
3428 /* This handles :: in the middle,
3429 but not at the beginning of an identifier.
3430 Also, space-separated :: is not recognised. */
3432 if (c_ext
& C_AUTO
) /* automatic detection of C++ */
3433 c_ext
= (c_ext
| C_PLPL
) & ~C_AUTO
;
3437 goto still_in_token
;
3441 bool funorvar
= FALSE
;
3444 || consider_token (newlb
.buffer
+ tokoff
, toklen
, c
,
3445 &c_ext
, bracelev
, parlev
,
3448 if (fvdef
== foperator
)
3451 lp
= skip_spaces (lp
-1);
3455 && !iswhite (*lp
) && *lp
!= '(')
3458 toklen
+= lp
- oldlp
;
3460 token
.named
= FALSE
;
3462 && nestlev
> 0 && definedef
== dnone
)
3463 /* in struct body */
3465 write_classname (&token_name
, qualifier
);
3466 linebuffer_setlen (&token_name
,
3467 token_name
.len
+qlen
+toklen
);
3468 strcat (token_name
.buffer
, qualifier
);
3469 strncat (token_name
.buffer
,
3470 newlb
.buffer
+ tokoff
, toklen
);
3473 else if (objdef
== ocatseen
)
3474 /* Objective C category */
3476 int len
= strlen (objtag
) + 2 + toklen
;
3477 linebuffer_setlen (&token_name
, len
);
3478 strcpy (token_name
.buffer
, objtag
);
3479 strcat (token_name
.buffer
, "(");
3480 strncat (token_name
.buffer
,
3481 newlb
.buffer
+ tokoff
, toklen
);
3482 strcat (token_name
.buffer
, ")");
3485 else if (objdef
== omethodtag
3486 || objdef
== omethodparm
)
3487 /* Objective C method */
3491 else if (fvdef
== fdefunname
)
3492 /* GNU DEFUN and similar macros */
3494 bool defun
= (newlb
.buffer
[tokoff
] == 'F');
3498 /* Rewrite the tag so that emacs lisp DEFUNs
3499 can be found by their elisp name */
3505 linebuffer_setlen (&token_name
, len
);
3506 strncpy (token_name
.buffer
,
3507 newlb
.buffer
+ off
, len
);
3508 token_name
.buffer
[len
] = '\0';
3511 if (token_name
.buffer
[len
] == '_')
3512 token_name
.buffer
[len
] = '-';
3513 token
.named
= defun
;
3517 linebuffer_setlen (&token_name
, toklen
);
3518 strncpy (token_name
.buffer
,
3519 newlb
.buffer
+ tokoff
, toklen
);
3520 token_name
.buffer
[toklen
] = '\0';
3521 /* Name macros and members. */
3522 token
.named
= (structdef
== stagseen
3523 || typdef
== ttypeseen
3526 && definedef
== dignorerest
)
3528 && definedef
== dnone
3529 && structdef
== snone
3532 token
.lineno
= lineno
;
3533 token
.offset
= tokoff
;
3534 token
.length
= toklen
;
3535 token
.line
= newlb
.buffer
;
3536 token
.linepos
= newlinepos
;
3539 if (definedef
== dnone
3540 && (fvdef
== fvnameseen
3541 || fvdef
== foperator
3542 || structdef
== stagseen
3544 || typdef
== ttypeseen
3545 || objdef
!= onone
))
3547 if (current_lb_is_new
)
3548 switch_line_buffers ();
3550 else if (definedef
!= dnone
3551 || fvdef
== fdefunname
3553 make_C_tag (funorvar
);
3555 else /* not yacc and consider_token failed */
3557 if (inattribute
&& fvdef
== fignore
)
3559 /* We have just met __attribute__ after a
3560 function parameter list: do not tag the
3567 } /* if (endtoken (c)) */
3568 else if (intoken (c
))
3574 } /* if (midtoken) */
3575 else if (begtoken (c
))
3583 /* This prevents tagging fb in
3584 void (__attribute__((noreturn)) *fb) (void);
3585 Fixing this is not easy and not very important. */
3589 if (plainc
|| declarations
)
3591 make_C_tag (TRUE
); /* a function */
3596 if (structdef
== stagseen
&& !cjava
)
3598 popclass_above (bracelev
);
3606 if (!yacc_rules
|| lp
== newlb
.buffer
+ 1)
3608 tokoff
= lp
- 1 - newlb
.buffer
;
3613 } /* if (begtoken) */
3614 } /* if must look at token */
3617 /* Detect end of line, colon, comma, semicolon and various braces
3618 after having handled a token.*/
3624 if (yacc_rules
&& token
.offset
== 0 && token
.valid
)
3626 make_C_tag (FALSE
); /* a yacc function */
3629 if (definedef
!= dnone
)
3635 make_C_tag (TRUE
); /* an Objective C class */
3639 objdef
= omethodcolon
;
3640 linebuffer_setlen (&token_name
, token_name
.len
+ 1);
3641 strcat (token_name
.buffer
, ":");
3644 if (structdef
== stagseen
)
3646 structdef
= scolonseen
;
3649 /* Should be useless, but may be work as a safety net. */
3650 if (cplpl
&& fvdef
== flistseen
)
3652 make_C_tag (TRUE
); /* a function */
3658 if (definedef
!= dnone
|| inattribute
)
3664 make_C_tag (FALSE
); /* a typedef */
3674 if (typdef
== tignore
|| cplpl
)
3678 if ((globals
&& bracelev
== 0 && (!fvextern
|| declarations
))
3679 || (members
&& instruct
))
3680 make_C_tag (FALSE
); /* a variable */
3683 token
.valid
= FALSE
;
3687 && (cplpl
|| !instruct
)
3688 && (typdef
== tnone
|| (typdef
!= tignore
&& instruct
)))
3690 && plainc
&& instruct
))
3691 make_C_tag (TRUE
); /* a function */
3697 && cplpl
&& structdef
== stagseen
)
3698 make_C_tag (FALSE
); /* forward declaration */
3700 token
.valid
= FALSE
;
3701 } /* switch (fvdef) */
3707 if (structdef
== stagseen
)
3711 if (definedef
!= dnone
|| inattribute
)
3717 make_C_tag (TRUE
); /* an Objective C method */
3738 && (!fvextern
|| declarations
))
3739 || (members
&& instruct
)))
3740 make_C_tag (FALSE
); /* a variable */
3743 if ((declarations
&& typdef
== tnone
&& !instruct
)
3744 || (members
&& typdef
!= tignore
&& instruct
))
3746 make_C_tag (TRUE
); /* a function */
3749 else if (!declarations
)
3751 token
.valid
= FALSE
;
3756 if (structdef
== stagseen
)
3760 if (definedef
!= dnone
|| inattribute
)
3762 if (structdef
== stagseen
)
3769 make_C_tag (FALSE
); /* a typedef */
3781 if ((members
&& bracelev
== 1)
3782 || (globals
&& bracelev
== 0
3783 && (!fvextern
|| declarations
)))
3784 make_C_tag (FALSE
); /* a variable */
3798 if (definedef
!= dnone
)
3800 if (objdef
== otagseen
&& parlev
== 0)
3801 objdef
= oparenseen
;
3805 if (typdef
== ttypeseen
3809 /* This handles constructs like:
3810 typedef void OperatorFun (int fun); */
3829 if (--attrparlev
== 0)
3830 inattribute
= FALSE
;
3833 if (definedef
!= dnone
)
3835 if (objdef
== ocatseen
&& parlev
== 1)
3837 make_C_tag (TRUE
); /* an Objective C category */
3851 || typdef
== ttypeseen
))
3854 make_C_tag (FALSE
); /* a typedef */
3857 else if (parlev
< 0) /* can happen due to ill-conceived #if's. */
3861 if (definedef
!= dnone
)
3863 if (typdef
== ttypeseen
)
3865 /* Whenever typdef is set to tinbody (currently only
3866 here), typdefbracelev should be set to bracelev. */
3868 typdefbracelev
= bracelev
;
3873 make_C_tag (TRUE
); /* a function */
3882 make_C_tag (TRUE
); /* an Objective C class */
3887 make_C_tag (TRUE
); /* an Objective C method */
3891 /* Neutralize `extern "C" {' grot. */
3892 if (bracelev
== 0 && structdef
== snone
&& nestlev
== 0
3900 case skeyseen
: /* unnamed struct */
3901 pushclass_above (bracelev
, NULL
, 0);
3904 case stagseen
: /* named struct or enum */
3905 case scolonseen
: /* a class */
3906 pushclass_above (bracelev
,token
.line
+token
.offset
, token
.length
);
3908 make_C_tag (FALSE
); /* a struct or enum */
3914 if (definedef
!= dnone
)
3916 if (fvdef
== fstartlist
)
3918 fvdef
= fvnone
; /* avoid tagging `foo' in `foo (*bar()) ()' */
3919 token
.valid
= FALSE
;
3923 if (definedef
!= dnone
)
3925 if (!ignoreindent
&& lp
== newlb
.buffer
+ 1)
3928 token
.valid
= FALSE
;
3929 bracelev
= 0; /* reset brace level if first column */
3930 parlev
= 0; /* also reset paren level, just in case... */
3932 else if (bracelev
> 0)
3935 token
.valid
= FALSE
; /* something gone amiss, token unreliable */
3936 popclass_above (bracelev
);
3938 /* Only if typdef == tinbody is typdefbracelev significant. */
3939 if (typdef
== tinbody
&& bracelev
<= typdefbracelev
)
3941 assert (bracelev
== typdefbracelev
);
3946 if (definedef
!= dnone
)
3956 if ((members
&& bracelev
== 1)
3957 || (globals
&& bracelev
== 0 && (!fvextern
|| declarations
)))
3958 make_C_tag (FALSE
); /* a variable */
3966 && (structdef
== stagseen
|| fvdef
== fvnameseen
))
3973 if (templatelev
> 0)
3981 if (objdef
== oinbody
&& bracelev
== 0)
3983 objdef
= omethodsign
;
3988 case '#': case '~': case '&': case '%': case '/':
3989 case '|': case '^': case '!': case '.': case '?':
3990 if (definedef
!= dnone
)
3992 /* These surely cannot follow a function tag in C. */
4005 if (objdef
== otagseen
)
4007 make_C_tag (TRUE
); /* an Objective C class */
4010 /* If a macro spans multiple lines don't reset its state. */
4012 CNL_SAVE_DEFINEDEF ();
4018 } /* while not eof */
4020 free (lbs
[0].lb
.buffer
);
4021 free (lbs
[1].lb
.buffer
);
4025 * Process either a C++ file or a C file depending on the setting
4029 default_C_entries (inf
)
4032 C_entries (cplusplus
? C_PLPL
: C_AUTO
, inf
);
4035 /* Always do plain C. */
4037 plain_C_entries (inf
)
4043 /* Always do C++. */
4045 Cplusplus_entries (inf
)
4048 C_entries (C_PLPL
, inf
);
4051 /* Always do Java. */
4056 C_entries (C_JAVA
, inf
);
4064 C_entries (C_STAR
, inf
);
4067 /* Always do Yacc. */
4072 C_entries (YACC
, inf
);
4076 /* Useful macros. */
4077 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
4078 for (; /* loop initialization */ \
4079 !feof (file_pointer) /* loop test */ \
4080 && /* instructions at start of loop */ \
4081 (readline (&line_buffer, file_pointer), \
4082 char_pointer = line_buffer.buffer, \
4086 #define LOOKING_AT(cp, kw) /* kw is the keyword, a literal string */ \
4087 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \
4088 && strneq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \
4089 && notinname ((cp)[sizeof(kw)-1]) /* end of kw */ \
4090 && ((cp) = skip_spaces((cp)+sizeof(kw)-1))) /* skip spaces */
4092 /* Similar to LOOKING_AT but does not use notinname, does not skip */
4093 #define LOOKING_AT_NOCASE(cp, kw) /* the keyword is a literal string */ \
4094 ((assert("" kw), TRUE) /* syntax error if not a literal string */ \
4095 && strncaseeq ((cp), kw, sizeof(kw)-1) /* cp points at kw */ \
4096 && ((cp) += sizeof(kw)-1)) /* skip spaces */
4099 * Read a file, but do no processing. This is used to do regexp
4100 * matching on files that have no language defined.
4103 just_read_file (inf
)
4106 register char *dummy
;
4108 LOOP_ON_INPUT_LINES (inf
, lb
, dummy
)
4113 /* Fortran parsing */
4115 static void F_takeprec
__P((void));
4116 static void F_getit
__P((FILE *));
4121 dbp
= skip_spaces (dbp
);
4125 dbp
= skip_spaces (dbp
);
4126 if (strneq (dbp
, "(*)", 3))
4131 if (!ISDIGIT (*dbp
))
4133 --dbp
; /* force failure */
4138 while (ISDIGIT (*dbp
));
4147 dbp
= skip_spaces (dbp
);
4150 readline (&lb
, inf
);
4155 dbp
= skip_spaces (dbp
);
4157 if (!ISALPHA (*dbp
) && *dbp
!= '_' && *dbp
!= '$')
4159 for (cp
= dbp
+ 1; *cp
!= '\0' && intoken (*cp
); cp
++)
4161 make_tag (dbp
, cp
-dbp
, TRUE
,
4162 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4167 Fortran_functions (inf
)
4170 LOOP_ON_INPUT_LINES (inf
, lb
, dbp
)
4173 dbp
++; /* Ratfor escape to fortran */
4174 dbp
= skip_spaces (dbp
);
4177 switch (lowcase (*dbp
))
4180 if (nocase_tail ("integer"))
4184 if (nocase_tail ("real"))
4188 if (nocase_tail ("logical"))
4192 if (nocase_tail ("complex") || nocase_tail ("character"))
4196 if (nocase_tail ("double"))
4198 dbp
= skip_spaces (dbp
);
4201 if (nocase_tail ("precision"))
4207 dbp
= skip_spaces (dbp
);
4210 switch (lowcase (*dbp
))
4213 if (nocase_tail ("function"))
4217 if (nocase_tail ("subroutine"))
4221 if (nocase_tail ("entry"))
4225 if (nocase_tail ("blockdata") || nocase_tail ("block data"))
4227 dbp
= skip_spaces (dbp
);
4228 if (*dbp
== '\0') /* assume un-named */
4229 make_tag ("blockdata", 9, TRUE
,
4230 lb
.buffer
, dbp
- lb
.buffer
, lineno
, linecharno
);
4232 F_getit (inf
); /* look for name */
4243 * Philippe Waroquiers (1998)
4246 static void Ada_getit
__P((FILE *, char *));
4248 /* Once we are positioned after an "interesting" keyword, let's get
4249 the real tag value necessary. */
4251 Ada_getit (inf
, name_qualifier
)
4253 char *name_qualifier
;
4261 dbp
= skip_spaces (dbp
);
4263 || (dbp
[0] == '-' && dbp
[1] == '-'))
4265 readline (&lb
, inf
);
4268 switch (lowcase(*dbp
))
4271 if (nocase_tail ("body"))
4273 /* Skipping body of procedure body or package body or ....
4274 resetting qualifier to body instead of spec. */
4275 name_qualifier
= "/b";
4280 /* Skipping type of task type or protected type ... */
4281 if (nocase_tail ("type"))
4288 for (cp
= dbp
; *cp
!= '\0' && *cp
!= '"'; cp
++)
4293 dbp
= skip_spaces (dbp
);
4296 && (ISALPHA (*cp
) || ISDIGIT (*cp
) || *cp
== '_' || *cp
== '.'));
4304 name
= concat (dbp
, name_qualifier
, "");
4306 make_tag (name
, strlen (name
), TRUE
,
4307 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4319 bool inquote
= FALSE
;
4320 bool skip_till_semicolumn
= FALSE
;
4322 LOOP_ON_INPUT_LINES (inf
, lb
, dbp
)
4324 while (*dbp
!= '\0')
4326 /* Skip a string i.e. "abcd". */
4327 if (inquote
|| (*dbp
== '"'))
4329 dbp
= etags_strchr ((inquote
) ? dbp
: dbp
+1, '"');
4334 continue; /* advance char */
4339 break; /* advance line */
4343 /* Skip comments. */
4344 if (dbp
[0] == '-' && dbp
[1] == '-')
4345 break; /* advance line */
4347 /* Skip character enclosed in single quote i.e. 'a'
4348 and skip single quote starting an attribute i.e. 'Image. */
4357 if (skip_till_semicolumn
)
4360 skip_till_semicolumn
= FALSE
;
4362 continue; /* advance char */
4365 /* Search for beginning of a token. */
4366 if (!begtoken (*dbp
))
4369 continue; /* advance char */
4372 /* We are at the beginning of a token. */
4373 switch (lowcase(*dbp
))
4376 if (!packages_only
&& nocase_tail ("function"))
4377 Ada_getit (inf
, "/f");
4379 break; /* from switch */
4380 continue; /* advance char */
4382 if (!packages_only
&& nocase_tail ("procedure"))
4383 Ada_getit (inf
, "/p");
4384 else if (nocase_tail ("package"))
4385 Ada_getit (inf
, "/s");
4386 else if (nocase_tail ("protected")) /* protected type */
4387 Ada_getit (inf
, "/t");
4389 break; /* from switch */
4390 continue; /* advance char */
4393 if (typedefs
&& !packages_only
&& nocase_tail ("use"))
4395 /* when tagging types, avoid tagging use type Pack.Typename;
4396 for this, we will skip everything till a ; */
4397 skip_till_semicolumn
= TRUE
;
4398 continue; /* advance char */
4402 if (!packages_only
&& nocase_tail ("task"))
4403 Ada_getit (inf
, "/k");
4404 else if (typedefs
&& !packages_only
&& nocase_tail ("type"))
4406 Ada_getit (inf
, "/t");
4407 while (*dbp
!= '\0')
4411 break; /* from switch */
4412 continue; /* advance char */
4415 /* Look for the end of the token. */
4416 while (!endtoken (*dbp
))
4419 } /* advance char */
4420 } /* advance line */
4425 * Unix and microcontroller assembly tag handling
4426 * Labels: /^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]/
4427 * Idea by Bob Weiner, Motorola Inc. (1994)
4435 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
4437 /* If first char is alphabetic or one of [_.$], test for colon
4438 following identifier. */
4439 if (ISALPHA (*cp
) || *cp
== '_' || *cp
== '.' || *cp
== '$')
4441 /* Read past label. */
4443 while (ISALNUM (*cp
) || *cp
== '_' || *cp
== '.' || *cp
== '$')
4445 if (*cp
== ':' || iswhite (*cp
))
4446 /* Found end of label, so copy it and add it to the table. */
4447 make_tag (lb
.buffer
, cp
- lb
.buffer
, TRUE
,
4448 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4456 * Perl sub names: /^sub[ \t\n]+[^ \t\n{]+/
4457 * Perl variable names: /^(my|local).../
4458 * Original code by Bart Robinson <lomew@cs.utah.edu> (1995)
4459 * Additions by Michael Ernst <mernst@alum.mit.edu> (1997)
4460 * Ideas by Kai Großjohann <Kai.Grossjohann@CS.Uni-Dortmund.DE> (2001)
4463 Perl_functions (inf
)
4466 char *package
= savestr ("main"); /* current package name */
4469 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
4473 if (LOOKING_AT (cp
, "package"))
4476 get_tag (cp
, &package
);
4478 else if (LOOKING_AT (cp
, "sub"))
4483 while (!notinname (*cp
))
4486 continue; /* nothing found */
4487 if ((pos
= etags_strchr (sp
, ':')) != NULL
4488 && pos
< cp
&& pos
[1] == ':')
4489 /* The name is already qualified. */
4490 make_tag (sp
, cp
- sp
, TRUE
,
4491 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4495 char savechar
, *name
;
4499 name
= concat (package
, "::", sp
);
4501 make_tag (name
, strlen(name
), TRUE
,
4502 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4506 else if (globals
) /* only if we are tagging global vars */
4508 /* Skip a qualifier, if any. */
4509 bool qual
= LOOKING_AT (cp
, "my") || LOOKING_AT (cp
, "local");
4510 /* After "my" or "local", but before any following paren or space. */
4511 char *varstart
= cp
;
4513 if (qual
/* should this be removed? If yes, how? */
4514 && (*cp
== '$' || *cp
== '@' || *cp
== '%'))
4519 while (ISALNUM (*cp
) || *cp
== '_');
4523 /* Should be examining a variable list at this point;
4524 could insist on seeing an open parenthesis. */
4525 while (*cp
!= '\0' && *cp
!= ';' && *cp
!= '=' && *cp
!= ')')
4531 make_tag (varstart
, cp
- varstart
, FALSE
,
4532 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4541 * Look for /^[\t]*def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
4542 * Idea by Eric S. Raymond <esr@thyrsus.com> (1997)
4543 * More ideas by seb bacon <seb@jamkit.com> (2002)
4546 Python_functions (inf
)
4551 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
4553 cp
= skip_spaces (cp
);
4554 if (LOOKING_AT (cp
, "def") || LOOKING_AT (cp
, "class"))
4557 while (!notinname (*cp
) && *cp
!= ':')
4559 make_tag (name
, cp
- name
, TRUE
,
4560 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4569 * - /^[ \t]*function[ \t\n]+[^ \t\n(]+/
4570 * - /^[ \t]*class[ \t\n]+[^ \t\n]+/
4571 * - /^[ \t]*define\(\"[^\"]+/
4572 * Only with --members:
4573 * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
4574 * Idea by Diez B. Roggisch (2001)
4580 register char *cp
, *name
;
4581 bool search_identifier
= FALSE
;
4583 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
4585 cp
= skip_spaces (cp
);
4587 if (search_identifier
4590 while (!notinname (*cp
))
4592 make_tag (name
, cp
- name
, TRUE
,
4593 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4594 search_identifier
= FALSE
;
4596 else if (LOOKING_AT (cp
, "function"))
4599 cp
= skip_spaces (cp
+1);
4603 while (!notinname (*cp
))
4605 make_tag (name
, cp
- name
, TRUE
,
4606 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4609 search_identifier
= TRUE
;
4611 else if (LOOKING_AT (cp
, "class"))
4616 while (*cp
!= '\0' && !iswhite (*cp
))
4618 make_tag (name
, cp
- name
, FALSE
,
4619 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4622 search_identifier
= TRUE
;
4624 else if (strneq (cp
, "define", 6)
4625 && (cp
= skip_spaces (cp
+6))
4627 && (*cp
== '"' || *cp
== '\''))
4631 while (*cp
!= quote
&& *cp
!= '\0')
4633 make_tag (name
, cp
- name
, FALSE
,
4634 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4637 && LOOKING_AT (cp
, "var")
4641 while (!notinname(*cp
))
4643 make_tag (name
, cp
- name
, FALSE
,
4644 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
4651 * Cobol tag functions
4652 * We could look for anything that could be a paragraph name.
4653 * i.e. anything that starts in column 8 is one word and ends in a full stop.
4654 * Idea by Corny de Souza (1993)
4657 Cobol_paragraphs (inf
)
4660 register char *bp
, *ep
;
4662 LOOP_ON_INPUT_LINES (inf
, lb
, bp
)
4668 /* If eoln, compiler option or comment ignore whole line. */
4669 if (bp
[-1] != ' ' || !ISALNUM (bp
[0]))
4672 for (ep
= bp
; ISALNUM (*ep
) || *ep
== '-'; ep
++)
4675 make_tag (bp
, ep
- bp
, TRUE
,
4676 lb
.buffer
, ep
- lb
.buffer
+ 1, lineno
, linecharno
);
4683 * Ideas by Assar Westerlund <assar@sics.se> (2001)
4686 Makefile_targets (inf
)
4691 LOOP_ON_INPUT_LINES (inf
, lb
, bp
)
4693 if (*bp
== '\t' || *bp
== '#')
4695 while (*bp
!= '\0' && *bp
!= '=' && *bp
!= ':')
4697 if (*bp
== ':' || (globals
&& *bp
== '='))
4699 /* We should detect if there is more than one tag, but we do not.
4700 We just skip initial and final spaces. */
4701 char * namestart
= skip_spaces (lb
.buffer
);
4702 while (--bp
> namestart
)
4703 if (!notinname (*bp
))
4705 make_tag (namestart
, bp
- namestart
+ 1, TRUE
,
4706 lb
.buffer
, bp
- lb
.buffer
+ 2, lineno
, linecharno
);
4714 * Original code by Mosur K. Mohan (1989)
4716 * Locates tags for procedures & functions. Doesn't do any type- or
4717 * var-definitions. It does look for the keyword "extern" or
4718 * "forward" immediately following the procedure statement; if found,
4719 * the tag is skipped.
4722 Pascal_functions (inf
)
4725 linebuffer tline
; /* mostly copied from C_entries */
4727 int save_lineno
, namelen
, taglen
;
4730 bool /* each of these flags is TRUE iff: */
4731 incomment
, /* point is inside a comment */
4732 inquote
, /* point is inside '..' string */
4733 get_tagname
, /* point is after PROCEDURE/FUNCTION
4734 keyword, so next item = potential tag */
4735 found_tag
, /* point is after a potential tag */
4736 inparms
, /* point is within parameter-list */
4737 verify_tag
; /* point has passed the parm-list, so the
4738 next token will determine whether this
4739 is a FORWARD/EXTERN to be ignored, or
4740 whether it is a real tag */
4742 save_lcno
= save_lineno
= namelen
= taglen
= 0; /* keep compiler quiet */
4743 name
= NULL
; /* keep compiler quiet */
4746 linebuffer_init (&tline
);
4748 incomment
= inquote
= FALSE
;
4749 found_tag
= FALSE
; /* have a proc name; check if extern */
4750 get_tagname
= FALSE
; /* found "procedure" keyword */
4751 inparms
= FALSE
; /* found '(' after "proc" */
4752 verify_tag
= FALSE
; /* check if "extern" is ahead */
4755 while (!feof (inf
)) /* long main loop to get next char */
4758 if (c
== '\0') /* if end of line */
4760 readline (&lb
, inf
);
4764 if (!((found_tag
&& verify_tag
)
4766 c
= *dbp
++; /* only if don't need *dbp pointing
4767 to the beginning of the name of
4768 the procedure or function */
4772 if (c
== '}') /* within { } comments */
4774 else if (c
== '*' && *dbp
== ')') /* within (* *) comments */
4791 inquote
= TRUE
; /* found first quote */
4793 case '{': /* found open { comment */
4797 if (*dbp
== '*') /* found open (* comment */
4802 else if (found_tag
) /* found '(' after tag, i.e., parm-list */
4805 case ')': /* end of parms list */
4810 if (found_tag
&& !inparms
) /* end of proc or fn stmt */
4817 if (found_tag
&& verify_tag
&& (*dbp
!= ' '))
4819 /* Check if this is an "extern" declaration. */
4822 if (lowcase (*dbp
== 'e'))
4824 if (nocase_tail ("extern")) /* superfluous, really! */
4830 else if (lowcase (*dbp
) == 'f')
4832 if (nocase_tail ("forward")) /* check for forward reference */
4838 if (found_tag
&& verify_tag
) /* not external proc, so make tag */
4842 make_tag (name
, namelen
, TRUE
,
4843 tline
.buffer
, taglen
, save_lineno
, save_lcno
);
4847 if (get_tagname
) /* grab name of proc or fn */
4854 /* Find block name. */
4855 for (cp
= dbp
+ 1; *cp
!= '\0' && !endtoken (*cp
); cp
++)
4858 /* Save all values for later tagging. */
4859 linebuffer_setlen (&tline
, lb
.len
);
4860 strcpy (tline
.buffer
, lb
.buffer
);
4861 save_lineno
= lineno
;
4862 save_lcno
= linecharno
;
4863 name
= tline
.buffer
+ (dbp
- lb
.buffer
);
4865 taglen
= cp
- lb
.buffer
+ 1;
4867 dbp
= cp
; /* set dbp to e-o-token */
4868 get_tagname
= FALSE
;
4872 /* And proceed to check for "extern". */
4874 else if (!incomment
&& !inquote
&& !found_tag
)
4876 /* Check for proc/fn keywords. */
4877 switch (lowcase (c
))
4880 if (nocase_tail ("rocedure")) /* c = 'p', dbp has advanced */
4884 if (nocase_tail ("unction"))
4889 } /* while not eof */
4891 free (tline
.buffer
);
4896 * Lisp tag functions
4897 * look for (def or (DEF, quote or QUOTE
4900 static void L_getit
__P((void));
4905 if (*dbp
== '\'') /* Skip prefix quote */
4907 else if (*dbp
== '(')
4910 /* Try to skip "(quote " */
4911 if (!LOOKING_AT (dbp
, "quote") && !LOOKING_AT (dbp
, "QUOTE"))
4912 /* Ok, then skip "(" before name in (defstruct (foo)) */
4913 dbp
= skip_spaces (dbp
);
4915 get_tag (dbp
, NULL
);
4919 Lisp_functions (inf
)
4922 LOOP_ON_INPUT_LINES (inf
, lb
, dbp
)
4927 if (strneq (dbp
+1, "def", 3) || strneq (dbp
+1, "DEF", 3))
4929 dbp
= skip_non_spaces (dbp
);
4930 dbp
= skip_spaces (dbp
);
4935 /* Check for (foo::defmumble name-defined ... */
4938 while (!notinname (*dbp
) && *dbp
!= ':');
4943 while (*dbp
== ':');
4945 if (strneq (dbp
, "def", 3) || strneq (dbp
, "DEF", 3))
4947 dbp
= skip_non_spaces (dbp
);
4948 dbp
= skip_spaces (dbp
);
4958 * Lua script language parsing
4959 * Original code by David A. Capello <dacap@users.sourceforge.net> (2004)
4961 * "function" and "local function" are tags if they start at column 1.
4969 LOOP_ON_INPUT_LINES (inf
, lb
, bp
)
4971 if (bp
[0] != 'f' && bp
[0] != 'l')
4974 (void)LOOKING_AT (bp
, "local"); /* skip possible "local" */
4976 if (LOOKING_AT (bp
, "function"))
4984 * Just look for lines where the first character is '/'
4985 * Also look at "defineps" for PSWrap
4987 * Richard Mlynarik <mly@adoc.xerox.com> (1997)
4988 * Masatake Yamato <masata-y@is.aist-nara.ac.jp> (1999)
4994 register char *bp
, *ep
;
4996 LOOP_ON_INPUT_LINES (inf
, lb
, bp
)
5001 *ep
!= '\0' && *ep
!= ' ' && *ep
!= '{';
5004 make_tag (bp
, ep
- bp
, TRUE
,
5005 lb
.buffer
, ep
- lb
.buffer
+ 1, lineno
, linecharno
);
5007 else if (LOOKING_AT (bp
, "defineps"))
5015 * Ignore anything after \ followed by space or in ( )
5016 * Look for words defined by :
5017 * Look for constant, code, create, defer, value, and variable
5018 * OBP extensions: Look for buffer:, field,
5019 * Ideas by Eduardo Horvath <eeh@netbsd.org> (2004)
5027 LOOP_ON_INPUT_LINES (inf
, lb
, bp
)
5028 while ((bp
= skip_spaces (bp
))[0] != '\0')
5029 if (bp
[0] == '\\' && iswhite(bp
[1]))
5030 break; /* read next line */
5031 else if (bp
[0] == '(' && iswhite(bp
[1]))
5032 do /* skip to ) or eol */
5034 while (*bp
!= ')' && *bp
!= '\0');
5035 else if ((bp
[0] == ':' && iswhite(bp
[1]) && bp
++)
5036 || LOOKING_AT_NOCASE (bp
, "constant")
5037 || LOOKING_AT_NOCASE (bp
, "code")
5038 || LOOKING_AT_NOCASE (bp
, "create")
5039 || LOOKING_AT_NOCASE (bp
, "defer")
5040 || LOOKING_AT_NOCASE (bp
, "value")
5041 || LOOKING_AT_NOCASE (bp
, "variable")
5042 || LOOKING_AT_NOCASE (bp
, "buffer:")
5043 || LOOKING_AT_NOCASE (bp
, "field"))
5044 get_tag (skip_spaces (bp
), NULL
); /* Yay! A definition! */
5046 bp
= skip_non_spaces (bp
);
5051 * Scheme tag functions
5052 * look for (def... xyzzy
5054 * (def ... ((...(xyzzy ....
5056 * Original code by Ken Haase (1985?)
5059 Scheme_functions (inf
)
5064 LOOP_ON_INPUT_LINES (inf
, lb
, bp
)
5066 if (strneq (bp
, "(def", 4) || strneq (bp
, "(DEF", 4))
5068 bp
= skip_non_spaces (bp
+4);
5069 /* Skip over open parens and white space */
5070 while (notinname (*bp
))
5074 if (LOOKING_AT (bp
, "(SET!") || LOOKING_AT (bp
, "(set!"))
5080 /* Find tags in TeX and LaTeX input files. */
5082 /* TEX_toktab is a table of TeX control sequences that define tags.
5083 * Each entry records one such control sequence.
5085 * Original code from who knows whom.
5087 * Stefan Monnier (2002)
5090 static linebuffer
*TEX_toktab
= NULL
; /* Table with tag tokens */
5092 /* Default set of control sequences to put into TEX_toktab.
5093 The value of environment var TEXTAGS is prepended to this. */
5094 static char *TEX_defenv
= "\
5095 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
5096 :part:appendix:entry:index:def\
5097 :newcommand:renewcommand:newenvironment:renewenvironment";
5099 static void TEX_mode
__P((FILE *));
5100 static void TEX_decode_env
__P((char *, char *));
5102 static char TEX_esc
= '\\';
5103 static char TEX_opgrp
= '{';
5104 static char TEX_clgrp
= '}';
5107 * TeX/LaTeX scanning loop.
5116 /* Select either \ or ! as escape character. */
5119 /* Initialize token table once from environment. */
5120 if (TEX_toktab
== NULL
)
5121 TEX_decode_env ("TEXTAGS", TEX_defenv
);
5123 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
5125 /* Look at each TEX keyword in line. */
5128 /* Look for a TEX escape. */
5129 while (*cp
++ != TEX_esc
)
5130 if (cp
[-1] == '\0' || cp
[-1] == '%')
5133 for (key
= TEX_toktab
; key
->buffer
!= NULL
; key
++)
5134 if (strneq (cp
, key
->buffer
, key
->len
))
5137 int namelen
, linelen
;
5140 cp
= skip_spaces (cp
+ key
->len
);
5141 if (*cp
== TEX_opgrp
)
5147 (!iswhite (*p
) && *p
!= '#' &&
5148 *p
!= TEX_opgrp
&& *p
!= TEX_clgrp
);
5153 if (!opgrp
|| *p
== TEX_clgrp
)
5155 while (*p
!= '\0' && *p
!= TEX_opgrp
&& *p
!= TEX_clgrp
)
5157 linelen
= p
- lb
.buffer
+ 1;
5159 make_tag (cp
, namelen
, TRUE
,
5160 lb
.buffer
, linelen
, lineno
, linecharno
);
5161 goto tex_next_line
; /* We only tag a line once */
5169 #define TEX_LESC '\\'
5170 #define TEX_SESC '!'
5172 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
5173 chars accordingly. */
5180 while ((c
= getc (inf
)) != EOF
)
5182 /* Skip to next line if we hit the TeX comment char. */
5184 while (c
!= '\n' && c
!= EOF
)
5186 else if (c
== TEX_LESC
|| c
== TEX_SESC
)
5202 /* If the input file is compressed, inf is a pipe, and rewind may fail.
5203 No attempt is made to correct the situation. */
5207 /* Read environment and prepend it to the default string.
5208 Build token table. */
5210 TEX_decode_env (evarname
, defenv
)
5214 register char *env
, *p
;
5217 /* Append default string to environment. */
5218 env
= getenv (evarname
);
5224 env
= concat (oldenv
, defenv
, "");
5227 /* Allocate a token table */
5228 for (len
= 1, p
= env
; p
;)
5229 if ((p
= etags_strchr (p
, ':')) && *++p
!= '\0')
5231 TEX_toktab
= xnew (len
, linebuffer
);
5233 /* Unpack environment string into token table. Be careful about */
5234 /* zero-length strings (leading ':', "::" and trailing ':') */
5235 for (i
= 0; *env
!= '\0';)
5237 p
= etags_strchr (env
, ':');
5238 if (!p
) /* End of environment string. */
5239 p
= env
+ strlen (env
);
5241 { /* Only non-zero strings. */
5242 TEX_toktab
[i
].buffer
= savenstr (env
, p
- env
);
5243 TEX_toktab
[i
].len
= p
- env
;
5250 TEX_toktab
[i
].buffer
= NULL
; /* Mark end of table. */
5251 TEX_toktab
[i
].len
= 0;
5258 /* Texinfo support. Dave Love, Mar. 2000. */
5264 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
5265 if (LOOKING_AT (cp
, "@node"))
5268 while (*cp
!= '\0' && *cp
!= ',')
5270 make_tag (start
, cp
- start
, TRUE
,
5271 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
5278 * Contents of <title>, <h1>, <h2>, <h3> are tags.
5279 * Contents of <a name=xxx> are tags with name xxx.
5281 * Francesco Potortì, 2002.
5287 bool getnext
= FALSE
; /* next text outside of HTML tags is a tag */
5288 bool skiptag
= FALSE
; /* skip to the end of the current HTML tag */
5289 bool intag
= FALSE
; /* inside an html tag, looking for ID= */
5290 bool inanchor
= FALSE
; /* when INTAG, is an anchor, look for NAME= */
5294 linebuffer_setlen (&token_name
, 0); /* no name in buffer */
5296 LOOP_ON_INPUT_LINES (inf
, lb
, dbp
)
5297 for (;;) /* loop on the same line */
5299 if (skiptag
) /* skip HTML tag */
5301 while (*dbp
!= '\0' && *dbp
!= '>')
5307 continue; /* look on the same line */
5309 break; /* go to next line */
5312 else if (intag
) /* look for "name=" or "id=" */
5314 while (*dbp
!= '\0' && *dbp
!= '>'
5315 && lowcase (*dbp
) != 'n' && lowcase (*dbp
) != 'i')
5318 break; /* go to next line */
5323 continue; /* look on the same line */
5325 if ((inanchor
&& LOOKING_AT_NOCASE (dbp
, "name="))
5326 || LOOKING_AT_NOCASE (dbp
, "id="))
5328 bool quoted
= (dbp
[0] == '"');
5331 for (end
= ++dbp
; *end
!= '\0' && *end
!= '"'; end
++)
5334 for (end
= dbp
; *end
!= '\0' && intoken (*end
); end
++)
5336 linebuffer_setlen (&token_name
, end
- dbp
);
5337 strncpy (token_name
.buffer
, dbp
, end
- dbp
);
5338 token_name
.buffer
[end
- dbp
] = '\0';
5341 intag
= FALSE
; /* we found what we looked for */
5342 skiptag
= TRUE
; /* skip to the end of the tag */
5343 getnext
= TRUE
; /* then grab the text */
5344 continue; /* look on the same line */
5349 else if (getnext
) /* grab next tokens and tag them */
5351 dbp
= skip_spaces (dbp
);
5353 break; /* go to next line */
5357 inanchor
= (lowcase (dbp
[1]) == 'a' && !intoken (dbp
[2]));
5358 continue; /* look on the same line */
5361 for (end
= dbp
+ 1; *end
!= '\0' && *end
!= '<'; end
++)
5363 make_tag (token_name
.buffer
, token_name
.len
, TRUE
,
5364 dbp
, end
- dbp
, lineno
, linecharno
);
5365 linebuffer_setlen (&token_name
, 0); /* no name in buffer */
5367 break; /* go to next line */
5370 else /* look for an interesting HTML tag */
5372 while (*dbp
!= '\0' && *dbp
!= '<')
5375 break; /* go to next line */
5377 if (lowcase (dbp
[1]) == 'a' && !intoken (dbp
[2]))
5380 continue; /* look on the same line */
5382 else if (LOOKING_AT_NOCASE (dbp
, "<title>")
5383 || LOOKING_AT_NOCASE (dbp
, "<h1>")
5384 || LOOKING_AT_NOCASE (dbp
, "<h2>")
5385 || LOOKING_AT_NOCASE (dbp
, "<h3>"))
5389 continue; /* look on the same line */
5400 * Assumes that the predicate or rule starts at column 0.
5401 * Only the first clause of a predicate or rule is added.
5402 * Original code by Sunichirou Sugou (1989)
5403 * Rewritten by Anders Lindgren (1996)
5405 static int prolog_pr
__P((char *, char *));
5406 static void prolog_skip_comment
__P((linebuffer
*, FILE *));
5407 static int prolog_atom
__P((char *, int));
5410 Prolog_functions (inf
)
5421 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
5423 if (cp
[0] == '\0') /* Empty line */
5425 else if (iswhite (cp
[0])) /* Not a predicate */
5427 else if (cp
[0] == '/' && cp
[1] == '*') /* comment. */
5428 prolog_skip_comment (&lb
, inf
);
5429 else if ((len
= prolog_pr (cp
, last
)) > 0)
5431 /* Predicate or rule. Store the function name so that we
5432 only generate a tag for the first clause. */
5434 last
= xnew(len
+ 1, char);
5435 else if (len
+ 1 > allocated
)
5436 xrnew (last
, len
+ 1, char);
5437 allocated
= len
+ 1;
5438 strncpy (last
, cp
, len
);
5448 prolog_skip_comment (plb
, inf
)
5456 for (cp
= plb
->buffer
; *cp
!= '\0'; cp
++)
5457 if (cp
[0] == '*' && cp
[1] == '/')
5459 readline (plb
, inf
);
5465 * A predicate or rule definition is added if it matches:
5466 * <beginning of line><Prolog Atom><whitespace>(
5467 * or <beginning of line><Prolog Atom><whitespace>:-
5469 * It is added to the tags database if it doesn't match the
5470 * name of the previous clause header.
5472 * Return the size of the name of the predicate or rule, or 0 if no
5478 char *last
; /* Name of last clause. */
5483 pos
= prolog_atom (s
, 0);
5488 pos
= skip_spaces (s
+ pos
) - s
;
5491 || (s
[pos
] == '(' && (pos
+= 1))
5492 || (s
[pos
] == ':' && s
[pos
+ 1] == '-' && (pos
+= 2)))
5493 && (last
== NULL
/* save only the first clause */
5494 || len
!= (int)strlen (last
)
5495 || !strneq (s
, last
, len
)))
5497 make_tag (s
, len
, TRUE
, s
, pos
, lineno
, linecharno
);
5505 * Consume a Prolog atom.
5506 * Return the number of bytes consumed, or -1 if there was an error.
5508 * A prolog atom, in this context, could be one of:
5509 * - An alphanumeric sequence, starting with a lower case letter.
5510 * - A quoted arbitrary string. Single quotes can escape themselves.
5511 * Backslash quotes everything.
5514 prolog_atom (s
, pos
)
5522 if (ISLOWER(s
[pos
]) || (s
[pos
] == '_'))
5524 /* The atom is unquoted. */
5526 while (ISALNUM(s
[pos
]) || (s
[pos
] == '_'))
5530 return pos
- origpos
;
5532 else if (s
[pos
] == '\'')
5543 pos
++; /* A double quote */
5545 else if (s
[pos
] == '\0')
5546 /* Multiline quoted atoms are ignored. */
5548 else if (s
[pos
] == '\\')
5550 if (s
[pos
+1] == '\0')
5557 return pos
- origpos
;
5565 * Support for Erlang
5567 * Generates tags for functions, defines, and records.
5568 * Assumes that Erlang functions start at column 0.
5569 * Original code by Anders Lindgren (1996)
5571 static int erlang_func
__P((char *, char *));
5572 static void erlang_attribute
__P((char *));
5573 static int erlang_atom
__P((char *));
5576 Erlang_functions (inf
)
5587 LOOP_ON_INPUT_LINES (inf
, lb
, cp
)
5589 if (cp
[0] == '\0') /* Empty line */
5591 else if (iswhite (cp
[0])) /* Not function nor attribute */
5593 else if (cp
[0] == '%') /* comment */
5595 else if (cp
[0] == '"') /* Sometimes, strings start in column one */
5597 else if (cp
[0] == '-') /* attribute, e.g. "-define" */
5599 erlang_attribute (cp
);
5606 else if ((len
= erlang_func (cp
, last
)) > 0)
5609 * Function. Store the function name so that we only
5610 * generates a tag for the first clause.
5613 last
= xnew (len
+ 1, char);
5614 else if (len
+ 1 > allocated
)
5615 xrnew (last
, len
+ 1, char);
5616 allocated
= len
+ 1;
5617 strncpy (last
, cp
, len
);
5627 * A function definition is added if it matches:
5628 * <beginning of line><Erlang Atom><whitespace>(
5630 * It is added to the tags database if it doesn't match the
5631 * name of the previous clause header.
5633 * Return the size of the name of the function, or 0 if no function
5637 erlang_func (s
, last
)
5639 char *last
; /* Name of last clause. */
5644 pos
= erlang_atom (s
);
5649 pos
= skip_spaces (s
+ pos
) - s
;
5651 /* Save only the first clause. */
5654 || len
!= (int)strlen (last
)
5655 || !strneq (s
, last
, len
)))
5657 make_tag (s
, len
, TRUE
, s
, pos
, lineno
, linecharno
);
5666 * Handle attributes. Currently, tags are generated for defines
5669 * They are on the form:
5670 * -define(foo, bar).
5671 * -define(Foo(M, N), M+N).
5672 * -record(graph, {vtab = notable, cyclic = true}).
5675 erlang_attribute (s
)
5680 if ((LOOKING_AT (cp
, "-define") || LOOKING_AT (cp
, "-record"))
5683 int len
= erlang_atom (skip_spaces (cp
));
5685 make_tag (cp
, len
, TRUE
, s
, cp
+ len
- s
, lineno
, linecharno
);
5692 * Consume an Erlang atom (or variable).
5693 * Return the number of bytes consumed, or -1 if there was an error.
5701 if (ISALPHA (s
[pos
]) || s
[pos
] == '_')
5703 /* The atom is unquoted. */
5706 while (ISALNUM (s
[pos
]) || s
[pos
] == '_');
5708 else if (s
[pos
] == '\'')
5710 for (pos
++; s
[pos
] != '\''; pos
++)
5711 if (s
[pos
] == '\0' /* multiline quoted atoms are ignored */
5712 || (s
[pos
] == '\\' && s
[++pos
] == '\0'))
5721 static char *scan_separators
__P((char *));
5722 static void add_regex
__P((char *, language
*));
5723 static char *substitute
__P((char *, char *, struct re_registers
*));
5726 * Take a string like "/blah/" and turn it into "blah", verifying
5727 * that the first and last characters are the same, and handling
5728 * quoted separator characters. Actually, stops on the occurrence of
5729 * an unquoted separator. Also process \t, \n, etc. and turn into
5730 * appropriate characters. Works in place. Null terminates name string.
5731 * Returns pointer to terminating separator, or NULL for
5732 * unterminated regexps.
5735 scan_separators (name
)
5739 char *copyto
= name
;
5740 bool quoted
= FALSE
;
5742 for (++name
; *name
!= '\0'; ++name
)
5748 case 'a': *copyto
++ = '\007'; break; /* BEL (bell) */
5749 case 'b': *copyto
++ = '\b'; break; /* BS (back space) */
5750 case 'd': *copyto
++ = 0177; break; /* DEL (delete) */
5751 case 'e': *copyto
++ = 033; break; /* ESC (delete) */
5752 case 'f': *copyto
++ = '\f'; break; /* FF (form feed) */
5753 case 'n': *copyto
++ = '\n'; break; /* NL (new line) */
5754 case 'r': *copyto
++ = '\r'; break; /* CR (carriage return) */
5755 case 't': *copyto
++ = '\t'; break; /* TAB (horizontal tab) */
5756 case 'v': *copyto
++ = '\v'; break; /* VT (vertical tab) */
5762 /* Something else is quoted, so preserve the quote. */
5770 else if (*name
== '\\')
5772 else if (*name
== sep
)
5778 name
= NULL
; /* signal unterminated regexp */
5780 /* Terminate copied string. */
5785 /* Look at the argument of --regex or --no-regex and do the right
5786 thing. Same for each line of a regexp file. */
5788 analyse_regex (regex_arg
)
5791 if (regex_arg
== NULL
)
5793 free_regexps (); /* --no-regex: remove existing regexps */
5797 /* A real --regexp option or a line in a regexp file. */
5798 switch (regex_arg
[0])
5800 /* Comments in regexp file or null arg to --regex. */
5806 /* Read a regex file. This is recursive and may result in a
5807 loop, which will stop when the file descriptors are exhausted. */
5811 linebuffer regexbuf
;
5812 char *regexfile
= regex_arg
+ 1;
5814 /* regexfile is a file containing regexps, one per line. */
5815 regexfp
= fopen (regexfile
, "r");
5816 if (regexfp
== NULL
)
5821 linebuffer_init (®exbuf
);
5822 while (readline_internal (®exbuf
, regexfp
) > 0)
5823 analyse_regex (regexbuf
.buffer
);
5824 free (regexbuf
.buffer
);
5829 /* Regexp to be used for a specific language only. */
5833 char *lang_name
= regex_arg
+ 1;
5836 for (cp
= lang_name
; *cp
!= '}'; cp
++)
5839 error ("unterminated language name in regex: %s", regex_arg
);
5843 lang
= get_language_from_langname (lang_name
);
5846 add_regex (cp
, lang
);
5850 /* Regexp to be used for any language. */
5852 add_regex (regex_arg
, NULL
);
5857 /* Separate the regexp pattern, compile it,
5858 and care for optional name and modifiers. */
5860 add_regex (regexp_pattern
, lang
)
5861 char *regexp_pattern
;
5864 static struct re_pattern_buffer zeropattern
;
5865 char sep
, *pat
, *name
, *modifiers
;
5867 struct re_pattern_buffer
*patbuf
;
5870 force_explicit_name
= TRUE
, /* do not use implicit tag names */
5871 ignore_case
= FALSE
, /* case is significant */
5872 multi_line
= FALSE
, /* matches are done one line at a time */
5873 single_line
= FALSE
; /* dot does not match newline */
5876 if (strlen(regexp_pattern
) < 3)
5878 error ("null regexp", (char *)NULL
);
5881 sep
= regexp_pattern
[0];
5882 name
= scan_separators (regexp_pattern
);
5885 error ("%s: unterminated regexp", regexp_pattern
);
5890 error ("null name for regexp \"%s\"", regexp_pattern
);
5893 modifiers
= scan_separators (name
);
5894 if (modifiers
== NULL
) /* no terminating separator --> no name */
5900 modifiers
+= 1; /* skip separator */
5902 /* Parse regex modifiers. */
5903 for (; modifiers
[0] != '\0'; modifiers
++)
5904 switch (modifiers
[0])
5907 if (modifiers
== name
)
5908 error ("forcing explicit tag name but no name, ignoring", NULL
);
5909 force_explicit_name
= TRUE
;
5919 need_filebuf
= TRUE
;
5924 wrongmod
[0] = modifiers
[0];
5926 error ("invalid regexp modifier `%s', ignoring", wrongmod
);
5931 patbuf
= xnew (1, struct re_pattern_buffer
);
5932 *patbuf
= zeropattern
;
5935 static char lc_trans
[CHARS
];
5937 for (i
= 0; i
< CHARS
; i
++)
5938 lc_trans
[i
] = lowcase (i
);
5939 patbuf
->translate
= lc_trans
; /* translation table to fold case */
5943 pat
= concat ("^", regexp_pattern
, ""); /* anchor to beginning of line */
5945 pat
= regexp_pattern
;
5948 re_set_syntax (RE_SYNTAX_EMACS
| RE_DOT_NEWLINE
);
5950 re_set_syntax (RE_SYNTAX_EMACS
);
5952 err
= re_compile_pattern (pat
, strlen (regexp_pattern
), patbuf
);
5957 error ("%s while compiling pattern", err
);
5962 p_head
= xnew (1, regexp
);
5963 p_head
->pattern
= savestr (regexp_pattern
);
5964 p_head
->p_next
= rp
;
5965 p_head
->lang
= lang
;
5966 p_head
->pat
= patbuf
;
5967 p_head
->name
= savestr (name
);
5968 p_head
->error_signaled
= FALSE
;
5969 p_head
->force_explicit_name
= force_explicit_name
;
5970 p_head
->ignore_case
= ignore_case
;
5971 p_head
->multi_line
= multi_line
;
5975 * Do the substitutions indicated by the regular expression and
5979 substitute (in
, out
, regs
)
5981 struct re_registers
*regs
;
5984 int size
, dig
, diglen
;
5987 size
= strlen (out
);
5989 /* Pass 1: figure out how much to allocate by finding all \N strings. */
5990 if (out
[size
- 1] == '\\')
5991 fatal ("pattern error in \"%s\"", out
);
5992 for (t
= etags_strchr (out
, '\\');
5994 t
= etags_strchr (t
+ 2, '\\'))
5998 diglen
= regs
->end
[dig
] - regs
->start
[dig
];
6004 /* Allocate space and do the substitutions. */
6006 result
= xnew (size
+ 1, char);
6008 for (t
= result
; *out
!= '\0'; out
++)
6009 if (*out
== '\\' && ISDIGIT (*++out
))
6012 diglen
= regs
->end
[dig
] - regs
->start
[dig
];
6013 strncpy (t
, in
+ regs
->start
[dig
], diglen
);
6020 assert (t
<= result
+ size
);
6021 assert (t
- result
== (int)strlen (result
));
6026 /* Deallocate all regexps. */
6031 while (p_head
!= NULL
)
6033 rp
= p_head
->p_next
;
6034 free (p_head
->pattern
);
6035 free (p_head
->name
);
6043 * Reads the whole file as a single string from `filebuf' and looks for
6044 * multi-line regular expressions, creating tags on matches.
6045 * readline already dealt with normal regexps.
6047 * Idea by Ben Wing <ben@666.com> (2002).
6050 regex_tag_multiline ()
6052 char *buffer
= filebuf
.buffer
;
6056 for (rp
= p_head
; rp
!= NULL
; rp
= rp
->p_next
)
6060 if (!rp
->multi_line
)
6061 continue; /* skip normal regexps */
6063 /* Generic initialisations before parsing file from memory. */
6064 lineno
= 1; /* reset global line number */
6065 charno
= 0; /* reset global char number */
6066 linecharno
= 0; /* reset global char number of line start */
6068 /* Only use generic regexps or those for the current language. */
6069 if (rp
->lang
!= NULL
&& rp
->lang
!= curfdp
->lang
)
6072 while (match
>= 0 && match
< filebuf
.len
)
6074 match
= re_search (rp
->pat
, buffer
, filebuf
.len
, charno
,
6075 filebuf
.len
- match
, &rp
->regs
);
6080 if (!rp
->error_signaled
)
6082 error ("regexp stack overflow while matching \"%s\"",
6084 rp
->error_signaled
= TRUE
;
6091 if (match
== rp
->regs
.end
[0])
6093 if (!rp
->error_signaled
)
6095 error ("regexp matches the empty string: \"%s\"",
6097 rp
->error_signaled
= TRUE
;
6099 match
= -3; /* exit from while loop */
6103 /* Match occurred. Construct a tag. */
6104 while (charno
< rp
->regs
.end
[0])
6105 if (buffer
[charno
++] == '\n')
6106 lineno
++, linecharno
= charno
;
6108 if (name
[0] == '\0')
6110 else /* make a named tag */
6111 name
= substitute (buffer
, rp
->name
, &rp
->regs
);
6112 if (rp
->force_explicit_name
)
6113 /* Force explicit tag name, if a name is there. */
6114 pfnote (name
, TRUE
, buffer
+ linecharno
,
6115 charno
- linecharno
+ 1, lineno
, linecharno
);
6117 make_tag (name
, strlen (name
), TRUE
, buffer
+ linecharno
,
6118 charno
- linecharno
+ 1, lineno
, linecharno
);
6130 register int len
= 0;
6132 while (*cp
!= '\0' && lowcase (*cp
) == lowcase (dbp
[len
]))
6134 if (*cp
== '\0' && !intoken (dbp
[len
]))
6143 get_tag (bp
, namepp
)
6147 register char *cp
= bp
;
6151 /* Go till you get to white space or a syntactic break */
6152 for (cp
= bp
+ 1; !notinname (*cp
); cp
++)
6154 make_tag (bp
, cp
- bp
, TRUE
,
6155 lb
.buffer
, cp
- lb
.buffer
+ 1, lineno
, linecharno
);
6159 *namepp
= savenstr (bp
, cp
- bp
);
6163 * Read a line of text from `stream' into `lbp', excluding the
6164 * newline or CR-NL, if any. Return the number of characters read from
6165 * `stream', which is the length of the line including the newline.
6167 * On DOS or Windows we do not count the CR character, if any before the
6168 * NL, in the returned length; this mirrors the behavior of Emacs on those
6169 * platforms (for text files, it translates CR-NL to NL as it reads in the
6172 * If multi-line regular expressions are requested, each line read is
6173 * appended to `filebuf'.
6176 readline_internal (lbp
, stream
)
6178 register FILE *stream
;
6180 char *buffer
= lbp
->buffer
;
6181 register char *p
= lbp
->buffer
;
6182 register char *pend
;
6185 pend
= p
+ lbp
->size
; /* Separate to avoid 386/IX compiler bug. */
6189 register int c
= getc (stream
);
6192 /* We're at the end of linebuffer: expand it. */
6194 xrnew (buffer
, lbp
->size
, char);
6195 p
+= buffer
- lbp
->buffer
;
6196 pend
= buffer
+ lbp
->size
;
6197 lbp
->buffer
= buffer
;
6207 if (p
> buffer
&& p
[-1] == '\r')
6211 /* Assume CRLF->LF translation will be performed by Emacs
6212 when loading this file, so CRs won't appear in the buffer.
6213 It would be cleaner to compensate within Emacs;
6214 however, Emacs does not know how many CRs were deleted
6215 before any given point in the file. */
6230 lbp
->len
= p
- buffer
;
6232 if (need_filebuf
/* we need filebuf for multi-line regexps */
6233 && chars_deleted
> 0) /* not at EOF */
6235 while (filebuf
.size
<= filebuf
.len
+ lbp
->len
+ 1) /* +1 for \n */
6237 /* Expand filebuf. */
6239 xrnew (filebuf
.buffer
, filebuf
.size
, char);
6241 strncpy (filebuf
.buffer
+ filebuf
.len
, lbp
->buffer
, lbp
->len
);
6242 filebuf
.len
+= lbp
->len
;
6243 filebuf
.buffer
[filebuf
.len
++] = '\n';
6244 filebuf
.buffer
[filebuf
.len
] = '\0';
6247 return lbp
->len
+ chars_deleted
;
6251 * Like readline_internal, above, but in addition try to match the
6252 * input line against relevant regular expressions and manage #line
6256 readline (lbp
, stream
)
6262 linecharno
= charno
; /* update global char number of line start */
6263 result
= readline_internal (lbp
, stream
); /* read line */
6264 lineno
+= 1; /* increment global line number */
6265 charno
+= result
; /* increment global char number */
6267 /* Honour #line directives. */
6268 if (!no_line_directive
)
6270 static bool discard_until_line_directive
;
6272 /* Check whether this is a #line directive. */
6273 if (result
> 12 && strneq (lbp
->buffer
, "#line ", 6))
6278 if (sscanf (lbp
->buffer
, "#line %u \"%n", &lno
, &start
) >= 1
6279 && start
> 0) /* double quote character found */
6281 char *endp
= lbp
->buffer
+ start
;
6283 while ((endp
= etags_strchr (endp
, '"')) != NULL
6284 && endp
[-1] == '\\')
6287 /* Ok, this is a real #line directive. Let's deal with it. */
6289 char *taggedabsname
; /* absolute name of original file */
6290 char *taggedfname
; /* name of original file as given */
6291 char *name
; /* temp var */
6293 discard_until_line_directive
= FALSE
; /* found it */
6294 name
= lbp
->buffer
+ start
;
6296 canonicalize_filename (name
); /* for DOS */
6297 taggedabsname
= absolute_filename (name
, tagfiledir
);
6298 if (filename_is_absolute (name
)
6299 || filename_is_absolute (curfdp
->infname
))
6300 taggedfname
= savestr (taggedabsname
);
6302 taggedfname
= relative_filename (taggedabsname
,tagfiledir
);
6304 if (streq (curfdp
->taggedfname
, taggedfname
))
6305 /* The #line directive is only a line number change. We
6306 deal with this afterwards. */
6309 /* The tags following this #line directive should be
6310 attributed to taggedfname. In order to do this, set
6311 curfdp accordingly. */
6313 fdesc
*fdp
; /* file description pointer */
6315 /* Go look for a file description already set up for the
6316 file indicated in the #line directive. If there is
6317 one, use it from now until the next #line
6319 for (fdp
= fdhead
; fdp
!= NULL
; fdp
= fdp
->next
)
6320 if (streq (fdp
->infname
, curfdp
->infname
)
6321 && streq (fdp
->taggedfname
, taggedfname
))
6322 /* If we remove the second test above (after the &&)
6323 then all entries pertaining to the same file are
6324 coalesced in the tags file. If we use it, then
6325 entries pertaining to the same file but generated
6326 from different files (via #line directives) will
6327 go into separate sections in the tags file. These
6328 alternatives look equivalent. The first one
6329 destroys some apparently useless information. */
6335 /* Else, if we already tagged the real file, skip all
6336 input lines until the next #line directive. */
6337 if (fdp
== NULL
) /* not found */
6338 for (fdp
= fdhead
; fdp
!= NULL
; fdp
= fdp
->next
)
6339 if (streq (fdp
->infabsname
, taggedabsname
))
6341 discard_until_line_directive
= TRUE
;
6345 /* Else create a new file description and use that from
6346 now on, until the next #line directive. */
6347 if (fdp
== NULL
) /* not found */
6350 fdhead
= xnew (1, fdesc
);
6351 *fdhead
= *curfdp
; /* copy curr. file description */
6353 fdhead
->infname
= savestr (curfdp
->infname
);
6354 fdhead
->infabsname
= savestr (curfdp
->infabsname
);
6355 fdhead
->infabsdir
= savestr (curfdp
->infabsdir
);
6356 fdhead
->taggedfname
= taggedfname
;
6357 fdhead
->usecharno
= FALSE
;
6358 fdhead
->prop
= NULL
;
6359 fdhead
->written
= FALSE
;
6363 free (taggedabsname
);
6365 readline (lbp
, stream
);
6367 } /* if a real #line directive */
6368 } /* if #line is followed by a a number */
6369 } /* if line begins with "#line " */
6371 /* If we are here, no #line directive was found. */
6372 if (discard_until_line_directive
)
6376 /* Do a tail recursion on ourselves, thus discarding the contents
6377 of the line buffer. */
6378 readline (lbp
, stream
);
6382 discard_until_line_directive
= FALSE
;
6385 } /* if #line directives should be considered */
6392 /* Match against relevant regexps. */
6394 for (rp
= p_head
; rp
!= NULL
; rp
= rp
->p_next
)
6396 /* Only use generic regexps or those for the current language.
6397 Also do not use multiline regexps, which is the job of
6398 regex_tag_multiline. */
6399 if ((rp
->lang
!= NULL
&& rp
->lang
!= fdhead
->lang
)
6403 match
= re_match (rp
->pat
, lbp
->buffer
, lbp
->len
, 0, &rp
->regs
);
6408 if (!rp
->error_signaled
)
6410 error ("regexp stack overflow while matching \"%s\"",
6412 rp
->error_signaled
= TRUE
;
6419 /* Empty string matched. */
6420 if (!rp
->error_signaled
)
6422 error ("regexp matches the empty string: \"%s\"", rp
->pattern
);
6423 rp
->error_signaled
= TRUE
;
6427 /* Match occurred. Construct a tag. */
6429 if (name
[0] == '\0')
6431 else /* make a named tag */
6432 name
= substitute (lbp
->buffer
, rp
->name
, &rp
->regs
);
6433 if (rp
->force_explicit_name
)
6434 /* Force explicit tag name, if a name is there. */
6435 pfnote (name
, TRUE
, lbp
->buffer
, match
, lineno
, linecharno
);
6437 make_tag (name
, strlen (name
), TRUE
,
6438 lbp
->buffer
, match
, lineno
, linecharno
);
6447 * Return a pointer to a space of size strlen(cp)+1 allocated
6448 * with xnew where the string CP has been copied.
6454 return savenstr (cp
, strlen (cp
));
6458 * Return a pointer to a space of size LEN+1 allocated with xnew where
6459 * the string CP has been copied for at most the first LEN characters.
6468 dp
= xnew (len
+ 1, char);
6469 strncpy (dp
, cp
, len
);
6475 * Return the ptr in sp at which the character c last
6476 * appears; NULL if not found
6478 * Identical to POSIX strrchr, included for portability.
6481 etags_strrchr (sp
, c
)
6482 register const char *sp
;
6485 register const char *r
;
6497 * Return the ptr in sp at which the character c first
6498 * appears; NULL if not found
6500 * Identical to POSIX strchr, included for portability.
6503 etags_strchr (sp
, c
)
6504 register const char *sp
;
6516 * Compare two strings, ignoring case for alphabetic characters.
6518 * Same as BSD's strcasecmp, included for portability.
6521 etags_strcasecmp (s1
, s2
)
6522 register const char *s1
;
6523 register const char *s2
;
6526 && (ISALPHA (*s1
) && ISALPHA (*s2
)
6527 ? lowcase (*s1
) == lowcase (*s2
)
6531 return (ISALPHA (*s1
) && ISALPHA (*s2
)
6532 ? lowcase (*s1
) - lowcase (*s2
)
6537 * Compare two strings, ignoring case for alphabetic characters.
6538 * Stop after a given number of characters
6540 * Same as BSD's strncasecmp, included for portability.
6543 etags_strncasecmp (s1
, s2
, n
)
6544 register const char *s1
;
6545 register const char *s2
;
6548 while (*s1
!= '\0' && n
-- > 0
6549 && (ISALPHA (*s1
) && ISALPHA (*s2
)
6550 ? lowcase (*s1
) == lowcase (*s2
)
6557 return (ISALPHA (*s1
) && ISALPHA (*s2
)
6558 ? lowcase (*s1
) - lowcase (*s2
)
6562 /* Skip spaces (end of string is not space), return new pointer. */
6567 while (iswhite (*cp
))
6572 /* Skip non spaces, except end of string, return new pointer. */
6574 skip_non_spaces (cp
)
6577 while (*cp
!= '\0' && !iswhite (*cp
))
6582 /* Print error message and exit. */
6588 exit (EXIT_FAILURE
);
6596 exit (EXIT_FAILURE
);
6600 suggest_asking_for_help ()
6602 fprintf (stderr
, "\tTry `%s %s' for a complete list of options.\n",
6603 progname
, NO_LONG_OPTIONS
? "-h" : "--help");
6604 exit (EXIT_FAILURE
);
6607 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
6610 const char *s1
, *s2
;
6612 fprintf (stderr
, "%s: ", progname
);
6613 fprintf (stderr
, s1
, s2
);
6614 fprintf (stderr
, "\n");
6617 /* Return a newly-allocated string whose contents
6618 concatenate those of s1, s2, s3. */
6623 int len1
= strlen (s1
), len2
= strlen (s2
), len3
= strlen (s3
);
6624 char *result
= xnew (len1
+ len2
+ len3
+ 1, char);
6626 strcpy (result
, s1
);
6627 strcpy (result
+ len1
, s2
);
6628 strcpy (result
+ len1
+ len2
, s3
);
6629 result
[len1
+ len2
+ len3
] = '\0';
6635 /* Does the same work as the system V getcwd, but does not need to
6636 guess the buffer size in advance. */
6642 char *path
= xnew (bufsize
, char);
6644 while (getcwd (path
, bufsize
) == NULL
)
6646 if (errno
!= ERANGE
)
6650 path
= xnew (bufsize
, char);
6653 canonicalize_filename (path
);
6656 #else /* not HAVE_GETCWD */
6659 char *p
, path
[MAXPATHLEN
+ 1]; /* Fixed size is safe on MSDOS. */
6663 for (p
= path
; *p
!= '\0'; p
++)
6669 return strdup (path
);
6670 #else /* not MSDOS */
6674 linebuffer_init (&path
);
6675 pipe
= (FILE *) popen ("pwd 2>/dev/null", "r");
6676 if (pipe
== NULL
|| readline_internal (&path
, pipe
) == 0)
6681 #endif /* not MSDOS */
6682 #endif /* not HAVE_GETCWD */
6685 /* Return a newly allocated string containing the file name of FILE
6686 relative to the absolute directory DIR (which should end with a slash). */
6688 relative_filename (file
, dir
)
6691 char *fp
, *dp
, *afn
, *res
;
6694 /* Find the common root of file and dir (with a trailing slash). */
6695 afn
= absolute_filename (file
, cwd
);
6698 while (*fp
++ == *dp
++)
6700 fp
--, dp
--; /* back to the first differing char */
6702 if (fp
== afn
&& afn
[0] != '/') /* cannot build a relative name */
6705 do /* look at the equal chars until '/' */
6709 /* Build a sequence of "../" strings for the resulting relative file name. */
6711 while ((dp
= etags_strchr (dp
+ 1, '/')) != NULL
)
6713 res
= xnew (3*i
+ strlen (fp
+ 1) + 1, char);
6716 strcat (res
, "../");
6718 /* Add the file name relative to the common root of file and dir. */
6719 strcat (res
, fp
+ 1);
6725 /* Return a newly allocated string containing the absolute file name
6726 of FILE given DIR (which should end with a slash). */
6728 absolute_filename (file
, dir
)
6731 char *slashp
, *cp
, *res
;
6733 if (filename_is_absolute (file
))
6734 res
= savestr (file
);
6736 /* We don't support non-absolute file names with a drive
6737 letter, like `d:NAME' (it's too much hassle). */
6738 else if (file
[1] == ':')
6739 fatal ("%s: relative file names with drive letters not supported", file
);
6742 res
= concat (dir
, file
, "");
6744 /* Delete the "/dirname/.." and "/." substrings. */
6745 slashp
= etags_strchr (res
, '/');
6746 while (slashp
!= NULL
&& slashp
[0] != '\0')
6748 if (slashp
[1] == '.')
6750 if (slashp
[2] == '.'
6751 && (slashp
[3] == '/' || slashp
[3] == '\0'))
6756 while (cp
>= res
&& !filename_is_absolute (cp
));
6758 cp
= slashp
; /* the absolute name begins with "/.." */
6760 /* Under MSDOS and NT we get `d:/NAME' as absolute
6761 file name, so the luser could say `d:/../NAME'.
6762 We silently treat this as `d:/NAME'. */
6763 else if (cp
[0] != '/')
6766 strcpy (cp
, slashp
+ 3);
6770 else if (slashp
[2] == '/' || slashp
[2] == '\0')
6772 strcpy (slashp
, slashp
+ 2);
6777 slashp
= etags_strchr (slashp
+ 1, '/');
6780 if (res
[0] == '\0') /* just a safety net: should never happen */
6783 return savestr ("/");
6789 /* Return a newly allocated string containing the absolute
6790 file name of dir where FILE resides given DIR (which should
6791 end with a slash). */
6793 absolute_dirname (file
, dir
)
6799 canonicalize_filename (file
);
6800 slashp
= etags_strrchr (file
, '/');
6802 return savestr (dir
);
6805 res
= absolute_filename (file
, dir
);
6811 /* Whether the argument string is an absolute file name. The argument
6812 string must have been canonicalized with canonicalize_filename. */
6814 filename_is_absolute (fn
)
6817 return (fn
[0] == '/'
6819 || (ISALPHA(fn
[0]) && fn
[1] == ':' && fn
[2] == '/')
6824 /* Translate backslashes into slashes. Works in place. */
6826 canonicalize_filename (fn
)
6830 /* Canonicalize drive letter case. */
6831 if (fn
[0] != '\0' && fn
[1] == ':' && ISLOWER (fn
[0]))
6832 fn
[0] = upcase (fn
[0]);
6833 /* Convert backslashes to slashes. */
6834 for (; *fn
!= '\0'; fn
++)
6839 fn
= NULL
; /* shut up the compiler */
6844 /* Initialize a linebuffer for use */
6846 linebuffer_init (lbp
)
6849 lbp
->size
= (DEBUG
) ? 3 : 200;
6850 lbp
->buffer
= xnew (lbp
->size
, char);
6851 lbp
->buffer
[0] = '\0';
6855 /* Set the minimum size of a string contained in a linebuffer. */
6857 linebuffer_setlen (lbp
, toksize
)
6861 while (lbp
->size
<= toksize
)
6864 xrnew (lbp
->buffer
, lbp
->size
, char);
6869 /* Like malloc but get fatal error if memory is exhausted. */
6874 PTR result
= (PTR
) malloc (size
);
6876 fatal ("virtual memory exhausted", (char *)NULL
);
6881 xrealloc (ptr
, size
)
6885 PTR result
= (PTR
) realloc (ptr
, size
);
6887 fatal ("virtual memory exhausted", (char *)NULL
);
6893 * indent-tabs-mode: t
6896 * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer" "fdesc" "node" "regexp")
6901 /* arch-tag: 8a9b748d-390c-4922-99db-2eeefa921051
6902 (do not change this comment) */
6904 /* etags.c ends here */