annotate lib-src/etags.c @ 13404:9d6c77b66cfb

* etags.c (get_lang_from_name, get_lang_from_interpreter, get_lang_from_suffix): New functions. (get_language): Function deleted. (lang_entry): Two members added to struct. (lang_names): Reflect the new layout of lang_entry. (print_language_names, main, find_entries): Use the new functions. (find_entries): Look at the first line for #! if no language. (C_entries): Invalidate the token when funcdef is reset. (Perl_functions): New function. (lang_suffixes): .pl and .pm are Perl suffixes.
author Francesco Potortì <pot@gnu.org>
date Mon, 06 Nov 1995 17:21:24 +0000
parents 12bfc1ecec61
children f89aa5a5c485
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1 /* Tags file maker to go with GNU Emacs
11231
3cf67df24e7f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 10990
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95
3cf67df24e7f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 10990
diff changeset
3 Free Software Foundation, Inc. and Ken Arnold
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
4 This file is not considered part of GNU Emacs.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
5
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
6 This program is free software; you can redistribute it and/or modify
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
7 it under the terms of the GNU General Public License as published by
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
8 the Free Software Foundation; either version 2 of the License, or
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
9 (at your option) any later version.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
10
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
11 This program is distributed in the hope that it will be useful,
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14 GNU General Public License for more details.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
17 along with this program; if not, write to the Free Software
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 * Authors:
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
22 * Ctags originally by Ken Arnold.
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
23 * Fortran added by Jim Kleckner.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 * Ed Pelegri-Llopart added C typedefs.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 * Gnu Emacs TAGS format and modifications by RMS?
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
26 * Sam Kendall added C++.
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
27 * Francesco Potorti` reorganised C and C++ based on work by Joe Wells.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
28 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
29 * Regexp tags by Tom Tromey.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
30 #endif
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
31 *
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
32 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33 */
10761
7aa80669e697 * etags.c (C_entries): Bug corrected in xrealloc of token_str.
Francesco Potortì <pot@gnu.org>
parents: 10754
diff changeset
34
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
35 char pot_etags_version[] = "@(#) pot revision number is 11.45";
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
36
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
37 #define TRUE 1
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
38 #define FALSE 0
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
39 #ifndef DEBUG
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
40 # define DEBUG FALSE
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
41 #endif
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
42
5448
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
43 #ifdef MSDOS
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
44 #include <fcntl.h>
7227
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
45 #include <sys/param.h>
5448
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
46 #endif /* MSDOS */
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
47
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
48 #ifdef WINDOWSNT
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
49 #include <stdlib.h>
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
50 #include <fcntl.h>
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
51 #include <string.h>
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
52 #define MAXPATHLEN _MAX_PATH
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
53 #endif
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
54
4052
9535e8ffb209 * etags.c (alloca): removed all references to it.
Jim Blandy <jimb@redhat.com>
parents: 4051
diff changeset
55 #ifdef HAVE_CONFIG_H
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
56 #include <config.h>
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
57 /* On some systems, Emacs defines static as nothing for the sake
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
58 of unexec. We don't want that here since we don't use unexec. */
6831
dbfdd66854c9 #undef static.
Richard M. Stallman <rms@gnu.org>
parents: 6756
diff changeset
59 #undef static
3208
daf2762a353c * etags.c: Replace the CPP tangle for alloca with the one from the
Jim Blandy <jimb@redhat.com>
parents: 3099
diff changeset
60 #endif
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
61
3921
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
62 #include <stdio.h>
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
63 #include <ctype.h>
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
64 #include <errno.h>
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
65 #ifndef errno
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
66 extern int errno;
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
67 #endif
3921
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
68 #include <sys/types.h>
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
69 #include <sys/stat.h>
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
70
4804
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
71 #if !defined (S_ISREG) && defined (S_IFREG)
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
72 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
73 #endif
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
74
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
75 #include <getopt.h>
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
76
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
77 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
78 #include <regex.h>
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
79 #endif /* ETAGS_REGEXPS */
3921
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
80
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
81 /* Define CTAGS to make the program "ctags" compatible with the usual one.
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
82 Let it undefined to make the program "etags", which makes emacs-style
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
83 tag tables and tags typedefs, #defines and struct/union/enum by default. */
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
84 #ifdef CTAGS
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
85 # undef CTAGS
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
86 # define CTAGS TRUE
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
87 #else
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
88 # define CTAGS FALSE
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
89 #endif
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
90
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 /* Exit codes for success and failure. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
92 #ifdef VMS
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
93 #define GOOD 1
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
94 #define BAD 0
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95 #else
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
96 #define GOOD 0
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
97 #define BAD 1
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 #endif
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
100 /* C extensions. */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
101 #define C_PLPL 0x00001 /* C++ */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
102 #define C_STAR 0x00003 /* C* */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
103 #define YACC 0x10000 /* yacc file */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
105 #define streq(s,t) (strcmp (s, t) == 0)
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
106 #define strneq(s,t,n) (strncmp (s, t, n) == 0)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
108 #define lowcase(c) tolower ((unsigned char)c)
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
109
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 #define iswhite(arg) (_wht[arg]) /* T if char is white */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 #define begtoken(arg) (_btk[arg]) /* T if char can start token */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 #define intoken(arg) (_itk[arg]) /* T if char can be in token */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 #define endtoken(arg) (_etk[arg]) /* T if char ends tokens */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114
12344
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
115 #ifdef DOS_NT
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
116 # define absolutefn(fn) (fn[0] == '/' || (isalpha (fn[0]) && fn[1] == ':'))
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
117 #else
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
118 # define absolutefn(fn) (fn[0] == '/')
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
119 #endif
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
120
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
121
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
122 /*
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
123 * xnew -- allocate storage
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
124 *
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
125 * SYNOPSIS: Type *xnew (int n, Type);
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
126 */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
127 #define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
129 typedef int logical;
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
130
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
131 typedef struct nd_st
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
132 { /* sorting structure */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 char *name; /* function or type name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 char *file; /* file name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 logical is_func; /* use pattern or line no */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 logical been_warned; /* set if noticed dup */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137 int lno; /* line number tag is on */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 long cno; /* character number line starts on */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 char *pat; /* search pattern */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 struct nd_st *left, *right; /* left and right sons */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
141 } NODE;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
142
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
143 extern char *getenv ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 char *concat ();
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
146 char *savenstr (), *savestr ();
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
147 char *etags_strchr (), *etags_strrchr ();
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
148 char *etags_getcwd ();
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
149 char *relative_filename (), *absolute_filename (), *absolute_dirname ();
11673
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
150 long *xmalloc (), *xrealloc ();
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
151
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
152 typedef void Lang_function ();
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
153 #if FALSE /* many compilers barf on this */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
154 Lang_function Asm_labels;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
155 Lang_function default_C_entries;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
156 Lang_function C_entries;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
157 Lang_function Cplusplus_entries;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
158 Lang_function Cstar_entries;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
159 Lang_function Fortran_functions;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
160 Lang_function Yacc_entries;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
161 Lang_function Lisp_functions;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
162 Lang_function Pascal_functions;
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
163 Lang_function Perl_functions;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
164 Lang_function Prolog_functions;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
165 Lang_function Scheme_functions;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
166 Lang_function TeX_functions;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
167 Lang_function just_read_file;
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
168 #else /* so let's write it this way */
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
169 void Asm_labels ();
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
170 void C_entries ();
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
171 void default_C_entries ();
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
172 void plain_C_entries ();
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
173 void Cplusplus_entries ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
174 void Cstar_entries ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
175 void Fortran_functions ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
176 void Yacc_entries ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
177 void Lisp_functions ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
178 void Pascal_functions ();
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
179 void Perl_functions ();
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
180 void Prolog_functions ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
181 void Scheme_functions ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
182 void TeX_functions ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
183 void just_read_file ();
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
184 #endif
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
185
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
186 Lang_function *get_language_from_name ();
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
187 Lang_function *get_language_from_interpreter ();
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
188 Lang_function *get_language_from_suffix ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
189 int total_size_of_entries ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
190 long readline ();
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
191 long readline_internal ();
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
192 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
193 void add_regex ();
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
194 #endif
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
195 void add_node ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
196 void error ();
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
197 void fatal (), pfatal ();
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
198 void find_entries ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
199 void free_tree ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
200 void getit ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
201 void init ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
202 void initbuffer ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 void pfnote ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 void process_file ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
205 void put_entries ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
206 void takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
207
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
208
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
209 char searchar = '/'; /* use /.../ searches */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
210
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
211 int lineno; /* line number of current line */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
212 long charno; /* current character number */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
213
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
214 long linecharno; /* charno of start of line; not used by C,
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
215 but by every other language. */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
216
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
217 char *curfile; /* current input file name */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
218 char *tagfile; /* output file */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
219 char *progname; /* name this program was invoked with */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
220 char *cwd; /* current working directory */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
221 char *tagfiledir; /* directory of tagfile */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
222
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
223 FILE *tagf; /* ioptr for tags file */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
224 NODE *head; /* the head of the binary tree of tags */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 /*
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
227 * A `struct linebuffer' is a structure which holds a line of text.
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
228 * `readline' reads a line from a stream into a linebuffer and works
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
229 * regardless of the length of the line.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230 */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
231 struct linebuffer
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
232 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
233 long size;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
234 char *buffer;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
235 };
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
236
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
237 struct linebuffer lb; /* the current line */
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
238 struct linebuffer token_name; /* used by C_entries as temporary area */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
239 struct
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
240 {
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
241 long linepos;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
242 struct linebuffer lb; /* used by C_entries instead of lb */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
243 } lbs[2];
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
244
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
245 /* boolean "functions" (see init) */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
246 logical _wht[0177], _etk[0177], _itk[0177], _btk[0177];
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
247 char
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
248 *white = " \f\t\n\013", /* white chars */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
249 *endtk = " \t\n\013\"'#()[]{}=-+%*/&|^~!<>;,.:?", /* token ending chars */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
250 /* token starting chars */
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
251 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~",
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
252 /* valid in-token chars */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
253 *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
254
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
255 logical append_to_tagfile; /* -a: append to tags */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
256 /* The following three default to TRUE for etags, but to FALSE for ctags. */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
257 logical typedefs; /* -t: create tags for typedefs */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
258 logical typedefs_and_cplusplus; /* -T: create tags for typedefs, level */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 /* 0 struct/enum/union decls, and C++ */
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
260 /* member functions. */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
261 logical constantypedefs; /* -d: create tags for C #define and enum */
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
262 /* constants. Enum consts not implemented. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 /* -D: opposite of -d. Default under ctags. */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
264 logical update; /* -u: update tags */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
265 logical vgrind_style; /* -v: create vgrind style index output */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
266 logical no_warnings; /* -w: suppress warnings */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
267 logical cxref_style; /* -x: create cxref style output */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
268 logical cplusplus; /* .[hc] means C++, not C */
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
269 logical noindentypedefs; /* -I: ignore indentation in C */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
270
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
271 struct option longopts[] =
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
272 {
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
273 { "append", no_argument, NULL, 'a' },
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
274 { "backward-search", no_argument, NULL, 'B' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
275 { "c++", no_argument, NULL, 'C' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
276 { "cxref", no_argument, NULL, 'x' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
277 { "defines", no_argument, NULL, 'd' },
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
278 { "help", no_argument, NULL, 'h' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
279 { "help", no_argument, NULL, 'H' },
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
280 { "ignore-indentation", no_argument, NULL, 'I' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
281 { "include", required_argument, NULL, 'i' },
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
282 { "language", required_argument, NULL, 'l' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
283 { "no-defines", no_argument, NULL, 'D' },
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
284 { "no-regex", no_argument, NULL, 'R' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
285 { "no-warn", no_argument, NULL, 'w' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
286 { "output", required_argument, NULL, 'o' },
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
287 { "regex", required_argument, NULL, 'r' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
288 { "typedefs", no_argument, NULL, 't' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
289 { "typedefs-and-c++", no_argument, NULL, 'T' },
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
290 { "update", no_argument, NULL, 'u' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
291 { "version", no_argument, NULL, 'V' },
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
292 { "vgrind", no_argument, NULL, 'v' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
293 { 0 }
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
294 };
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
295
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
296 #ifdef ETAGS_REGEXPS
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
297 /* Structure defining a regular expression. Elements are
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
298 the compiled pattern, and the name string. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
299 struct pattern
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
300 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
301 struct re_pattern_buffer *pattern;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
302 struct re_registers regs;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
303 char *name_pattern;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
304 logical error_signaled;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
305 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
306
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
307 /* Number of regexps found. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
308 int num_patterns = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
309
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
310 /* Array of all regexps. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
311 struct pattern *patterns = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
312 #endif /* ETAGS_REGEXPS */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
313
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
314 /*
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
315 * Language stuff.
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
316 */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
317
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
318 /* Non-NULL if language fixed. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
319 Lang_function *lang_func = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
320
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
321 /* Assembly code */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
322 char *Asm_suffixes [] = { "a", /* Unix assembler */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
323 "asm", /* Microcontroller assembly */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
324 "def", /* BSO/Tasking definition includes */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
325 "inc", /* Microcontroller include files */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
326 "ins", /* Microcontroller include files */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
327 "s", "sa", /* Unix assembler */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
328 "src", /* BSO/Tasking C compiler output */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
329 NULL
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
330 };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
331
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
332 /* Note that .c and .h can be considered C++, if the --c++ flag was
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
333 given. That is why default_C_entries is called here. */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
334 char *default_C_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
335 { "c", "h", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
336
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
337 /* C++ file */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
338 char *Cplusplus_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
339 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
340
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
341 /* C* file */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
342 char *Cstar_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
343 { "cs", "hs", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
344
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
345 /* Fortran */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
346 char *Fortran_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
347 { "F", "f", "f90", "for", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
348
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
349 /* Lisp source code */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
350 char *Lisp_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
351 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
352
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
353 /* Pascal file */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
354 char *Pascal_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
355 { "p", "pas", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
356
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
357 /* Perl file */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
358 char *Perl_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
359 { "pl", "pm", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
360 char *Perl_interpreters [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
361 { "perl", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
362
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
363 /* Pro*C file. */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
364 char *plain_C_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
365 { "pc", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
366
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
367 /* Prolog source code */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
368 char *Prolog_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
369 { "prolog", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
370
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
371 /* Scheme source code */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
372 /* FIXME Can't do the `SCM' or `scm' prefix with a version number */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
373 char *Scheme_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
374 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "t", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
375
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
376 /* TeX/LaTeX source code */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
377 char *TeX_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
378 { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
379
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
380 /* Yacc file */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
381 char *Yacc_suffixes [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
382 { "y", NULL };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
383
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
384 /* Table of language names and corresponding functions, file suffixes
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
385 and interpreter names.
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
386 It is ok for a given function to be listed under more than one
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
387 name. I just didn't. */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
388 struct lang_entry
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
389 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
390 char *name;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
391 Lang_function *function;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
392 char **suffixes;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
393 char **interpreters;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
394 };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
395
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
396 struct lang_entry lang_names [] =
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
397 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
398 { "asm", Asm_labels, Asm_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
399 { "c", default_C_entries, default_C_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
400 { "c++", Cplusplus_entries, Cplusplus_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
401 { "c*", Cstar_entries, Cstar_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
402 { "fortran", Fortran_functions, Fortran_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
403 { "lisp", Lisp_functions, Lisp_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
404 { "pascal", Pascal_functions, Pascal_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
405 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
406 { "proc", plain_C_entries, plain_C_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
407 { "prolog", Prolog_functions, Prolog_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
408 { "scheme" , Scheme_functions, Scheme_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
409 { "tex", TeX_functions, TeX_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
410 { "yacc", Yacc_entries, Yacc_suffixes },
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
411 { "auto", NULL }, /* default guessing scheme */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
412 { "none", just_read_file }, /* regexp matching only */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
413 { NULL, NULL } /* end of list */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
414 };
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
415
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
416
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
417 void
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
418 print_language_names ()
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
419 {
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
420 struct lang_entry *lang;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
421 char **ext;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
422
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
423 puts ("\nThese are the currently supported languages, along with the\n\
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
424 default file name suffixes:");
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
425 for (lang = lang_names; lang->name != NULL; lang++)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
426 {
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
427 printf ("\t%s\t", lang->name);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
428 if (lang->suffixes != NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
429 for (ext = lang->suffixes; *ext != NULL; ext++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
430 printf (" .%s", *ext);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
431 puts ("");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
432 }
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
433 puts ("Where `auto' means use default language for files based on file\n\
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
434 name suffix, and `none' means only do regexp processing on files.\n\
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
435 If no language is specified and no matching suffix is found,\n\
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
436 the first line of the file is read for a sharp-bang (#!) sequence\n\
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
437 followed by the name of an interpreter. If no such sequence is found,\n\
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
438 Fortran is tried first; if no tags are found, C is tried next.");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
439 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
440
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
441 #ifndef VERSION
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
442 # define VERSION "19"
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
443 #endif
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
444 void
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
445 print_version ()
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
446 {
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
447 printf ("%s for Emacs version %s\n", (CTAGS) ? "ctags" : "etags", VERSION);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
448
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
449 exit (GOOD);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
450 }
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
451
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
452 void
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
453 print_help ()
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
454 {
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
455 printf ("These are the options accepted by %s. You may use unambiguous\n\
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
456 abbreviations for the long option names. A - as file name means read\n\
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
457 names from stdin.\n\n", progname);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
458
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
459 puts ("-a, --append\n\
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
460 Append tag entries to existing tags file.");
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
461
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
462 if (CTAGS)
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
463 puts ("-B, --backward-search\n\
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
464 Write the search commands for the tag entries using '?', the\n\
6945
63ab519f7057 * etags.c (main, print_help): eliminate the -F option.
Francesco Potortì <pot@gnu.org>
parents: 6944
diff changeset
465 backward-search command instead of '/', the forward-search command.");
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
466
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
467 puts ("-C, --c++\n\
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
468 Treat files whose name suffix defaults to C language as C++ files.");
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
469
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
470 if (CTAGS)
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
471 puts ("-d, --defines\n\
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
472 Create tag entries for constant C #defines, too.");
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
473 else
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
474 puts ("-D, --no-defines\n\
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
475 Don't create tag entries for constant C #defines. This makes\n\
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
476 the tags file smaller.");
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
477
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
478 if (!CTAGS)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
479 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
480 puts ("-i FILE, --include=FILE\n\
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
481 Include a note in tag file indicating that, when searching for\n\
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
482 a tag, one should also consult the tags file FILE after\n\
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
483 checking the current file.");
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
484 puts ("-l LANG, --language=LANG\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
485 Force the following files to be considered as written in the\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
486 named language up to the next --language=LANG option.");
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
487 }
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
488
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
489 #ifdef ETAGS_REGEXPS
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
490 puts ("-r /REGEXP/, --regex=/REGEXP/\n\
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
491 Make a tag for each line matching pattern REGEXP in the\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
492 following files. REGEXP is anchored (as if preceded by ^).\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
493 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
494 named tags can be created with:\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
495 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
496 puts ("-R, --no-regex\n\
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
497 Don't create tags from regexps for the following files.");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
498 #endif /* ETAGS_REGEXPS */
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
499 puts ("-o FILE, --output=FILE\n\
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
500 Write the tags to FILE.");
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
501 puts ("-I, --ignore-indentation\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
502 Don't rely on indentation quite as much as normal. Currently,\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
503 this means not to assume that a closing brace in the first\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
504 column is the final brace of a function or structure\n\
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
505 definition in C and C++.");
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
506
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
507 if (CTAGS)
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
508 {
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
509 puts ("-t, --typedefs\n\
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
510 Generate tag entries for C typedefs.");
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
511 puts ("-T, --typedefs-and-c++\n\
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
512 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
513 and C++ member functions.");
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
514 puts ("-u, --update\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
515 Update the tag entries for the given files, leaving tag\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
516 entries for other files in place. Currently, this is\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
517 implemented by deleting the existing entries for the given\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
518 files and then rewriting the new entries at the end of the\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
519 tags file. It is often faster to simply rebuild the entire\n\
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
520 tag file than to use this.");
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
521 puts ("-v, --vgrind\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
522 Generates an index of items intended for human consumption,\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
523 similar to the output of vgrind. The index is sorted, and\n\
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
524 gives the page number of each item.");
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
525 puts ("-w, --no-warn\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
526 Suppress warning messages about entries defined in multiple\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
527 files.");
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
528 puts ("-x, --cxref\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
529 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
530 The output uses line numbers instead of page numbers, but\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
531 beyond that the differences are cosmetic; try both to see\n\
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
532 which you like.");
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
533 }
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
534
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
535 puts ("-V, --version\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
536 Print the version of the program.\n\
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
537 -h, --help\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
538 Print this help message.");
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
539
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
540 print_language_names ();
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
541
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
542 exit (GOOD);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
543 }
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
544
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
545
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
546 enum argument_type
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
547 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
548 at_language,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
549 at_regexp,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
550 at_filename
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
551 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
552
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
553 /* This structure helps us allow mixing of --lang and filenames. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
554 typedef struct
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
555 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
556 enum argument_type arg_type;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
557 char *what;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
558 Lang_function *function;
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
559 } argument;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
560
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
561 #ifdef VMS /* VMS specific functions */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
562
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
563 #define EOS '\0'
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
564
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
565 /* This is a BUG! ANY arbitrary limit is a BUG!
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
566 Won't someone please fix this? */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
567 #define MAX_FILE_SPEC_LEN 255
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
568 typedef struct {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
569 short curlen;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
570 char body[MAX_FILE_SPEC_LEN + 1];
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
571 } vspec;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
572
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
573 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
574 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
575 returning in each successive call the next filename matching the input
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
576 spec. The function expects that each in_spec passed
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
577 to it will be processed to completion; in particular, up to and
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
578 including the call following that in which the last matching name
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
579 is returned, the function ignores the value of in_spec, and will
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
580 only start processing a new spec with the following call.
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
581 If an error occurs, on return out_spec contains the value
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
582 of in_spec when the error occurred.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
583
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
584 With each successive filename returned in out_spec, the
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
585 function's return value is one. When there are no more matching
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
586 names the function returns zero. If on the first call no file
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
587 matches in_spec, or there is any other error, -1 is returned.
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
588 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
589
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
590 #include <rmsdef.h>
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
591 #include <descrip.h>
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
592 #define OUTSIZE MAX_FILE_SPEC_LEN
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
593 short
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
594 fn_exp (out, in)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
595 vspec *out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
596 char *in;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
597 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
598 static long context = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
599 static struct dsc$descriptor_s o;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
600 static struct dsc$descriptor_s i;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
601 static logical pass1 = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
602 long status;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
603 short retval;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
604
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
605 if (pass1)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
606 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
607 pass1 = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
608 o.dsc$a_pointer = (char *) out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
609 o.dsc$w_length = (short)OUTSIZE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
610 i.dsc$a_pointer = in;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
611 i.dsc$w_length = (short)strlen(in);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
612 i.dsc$b_dtype = DSC$K_DTYPE_T;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
613 i.dsc$b_class = DSC$K_CLASS_S;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
614 o.dsc$b_dtype = DSC$K_DTYPE_VT;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
615 o.dsc$b_class = DSC$K_CLASS_VS;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
616 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
617 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
618 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
619 out->body[out->curlen] = EOS;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
620 return 1;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
621 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
622 else if (status == RMS$_NMF)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
623 retval = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
624 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
625 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
626 strcpy(out->body, in);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
627 retval = -1;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
628 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
629 lib$find_file_end(&context);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
630 pass1 = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
631 return retval;
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
632 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
633
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
634 /*
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
635 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
636 name of each file specified by the provided arg expanding wildcards.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
637 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
638 char *
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
639 gfnames (arg, p_error)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
640 char *arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
641 logical *p_error;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
642 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
643 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
644
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
645 switch (fn_exp (&filename, arg))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
646 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
647 case 1:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
648 *p_error = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
649 return filename.body;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
650 case 0:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
651 *p_error = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
652 return NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
653 default:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
654 *p_error = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
655 return filename.body;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
656 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
657 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
658
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
659 #ifndef OLD /* Newer versions of VMS do provide `system'. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
660 system (cmd)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
661 char *cmd;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
662 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
663 fprintf (stderr, "system() function not implemented under VMS\n");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
664 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
665 #endif
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
666
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
667 #define VERSION_DELIM ';'
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
668 char *massage_name (s)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
669 char *s;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
670 {
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
671 char *start = s;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
672
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
673 for ( ; *s; s++)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
674 if (*s == VERSION_DELIM)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
675 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
676 *s = EOS;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
677 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
678 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
679 else
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
680 *s = lowcase (*s);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
681 return start;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
682 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
683 #endif /* VMS */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
684
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
685
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
686 void
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
687 main (argc, argv)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
688 int argc;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
689 char *argv[];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
690 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
691 int i;
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
692 unsigned int nincluded_files = 0;
4052
9535e8ffb209 * etags.c (alloca): removed all references to it.
Jim Blandy <jimb@redhat.com>
parents: 4051
diff changeset
693 char **included_files = xnew (argc, char *);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
694 char *this_file;
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
695 argument *argbuffer;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
696 int current_arg = 0, file_count = 0;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
697 struct linebuffer filename_lb;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
698 #ifdef VMS
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
699 logical got_err;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
700 #endif
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
701
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
702 #ifdef DOS_NT
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
703 _fmode = O_BINARY; /* all of files are treated as binary files */
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
704 #endif /* DOS_NT */
5448
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
705
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
706 progname = argv[0];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
707
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
708 /* Allocate enough no matter what happens. Overkill, but each one
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
709 is small. */
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
710 argbuffer = xnew (argc, argument);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
711
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
712 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
713 /* Set syntax for regular expression routines. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
714 re_set_syntax (RE_SYNTAX_EMACS);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
715 #endif /* ETAGS_REGEXPS */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
716
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
717 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
718 * If etags, always find typedefs and structure tags. Why not?
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
719 * Also default is to find macro constants.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
720 */
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
721 if (!CTAGS)
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
722 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
723
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
724 while (1)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
725 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
726 int opt = getopt_long (argc, argv,
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
727 "-aCdDf:Il:o:r:RStTi:BuvxwVhH", longopts, 0);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
728
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
729 if (opt == EOF)
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
730 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
731
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
732 switch (opt)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
733 {
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
734 case 0:
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
735 /* If getopt returns 0, then it has already processed a
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
736 long-named option. We should do nothing. */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
737 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
739 case 1:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
740 /* This means that a filename has been seen. Record it. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
741 argbuffer[current_arg].arg_type = at_filename;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
742 argbuffer[current_arg].what = optarg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
743 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
744 ++file_count;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
745 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
746
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
747 /* Common options. */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
748 case 'a':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
749 append_to_tagfile = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
750 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
751 case 'C':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
752 cplusplus = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
753 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
754 case 'd':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
755 constantypedefs = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
756 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
757 case 'D':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
758 constantypedefs = FALSE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
759 break;
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
760 case 'f': /* for compatibility with old makefiles */
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
761 case 'o':
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
762 if (tagfile)
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
763 {
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
764 fprintf (stderr, "%s: -%c option may only be given once.\n",
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
765 progname, opt);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 goto usage;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
768 tagfile = optarg;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
769 break;
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
770 case 'I':
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
771 case 'S': /* for backward compatibility */
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
772 noindentypedefs = TRUE;
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
773 break;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
774 case 'l':
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
775 argbuffer[current_arg].function = get_language_from_name (optarg);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
776 if (argbuffer[current_arg].function == NULL)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
777 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
778 fprintf (stderr, "%s: language \"%s\" not recognized.\n",
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
779 progname, optarg);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
780 goto usage;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
781 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
782 argbuffer[current_arg].arg_type = at_language;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
783 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
784 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
785 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
786 case 'r':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
787 argbuffer[current_arg].arg_type = at_regexp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
788 argbuffer[current_arg].what = optarg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
789 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
790 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
791 case 'R':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
792 argbuffer[current_arg].arg_type = at_regexp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
793 argbuffer[current_arg].what = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
794 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
795 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
796 #endif /* ETAGS_REGEXPS */
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
797 case 'V':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
798 print_version ();
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
799 break;
10047
9b284d98b102 * etags.c (print_help): print --regex usage for ctags also.
Francesco Potortì <pot@gnu.org>
parents: 9976
diff changeset
800 case 'h':
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
801 case 'H':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
802 print_help ();
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
803 break;
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
804 case 't':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
805 typedefs = TRUE;
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
806 break;
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
807 case 'T':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
808 typedefs = typedefs_and_cplusplus = TRUE;
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
809 break;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
810 #if (!CTAGS)
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
811 /* Etags options */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
812 case 'i':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
813 included_files[nincluded_files++] = optarg;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
814 break;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
815 #else /* CTAGS */
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
816 /* Ctags options. */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
817 case 'B':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
818 searchar = '?';
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
819 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
820 case 'u':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
821 update = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
822 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
823 case 'v':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
824 vgrind_style = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
825 /*FALLTHRU*/
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
826 case 'x':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
827 cxref_style = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
828 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
829 case 'w':
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
830 no_warnings = TRUE;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
831 break;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
832 #endif /* CTAGS */
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
833 default:
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
834 goto usage;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
835 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
836 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
837
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
838 for (; optind < argc; ++optind)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
839 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
840 argbuffer[current_arg].arg_type = at_filename;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
841 argbuffer[current_arg].what = argv[optind];
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
842 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
843 ++file_count;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
844 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
845
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
846 if (nincluded_files == 0 && file_count == 0)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
847 {
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
848 fprintf (stderr, "%s: No input files specified.\n", progname);
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
849
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
850 usage:
10449
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
851 fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n",
2266157d9bcc * etags.c (longopts, print_help, main): Use -I as abbreviation
Francesco Potortì <pot@gnu.org>
parents: 10404
diff changeset
852 progname);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
853 exit (BAD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
854 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
855
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
856 if (tagfile == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
857 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
858 tagfile = CTAGS ? "tags" : "TAGS";
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
859 }
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
860 cwd = etags_getcwd (); /* the current working directory */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
861 strcat (cwd, "/");
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
862 if (streq (tagfile, "-"))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
863 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
864 tagfiledir = cwd;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
865 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
866 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
867 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
868 tagfiledir = absolute_dirname (tagfile, cwd);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
869 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
870
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
871 init (); /* set up boolean "functions" */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
872
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
873 initbuffer (&lb);
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
874 initbuffer (&token_name);
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
875 initbuffer (&lbs[0].lb);
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
876 initbuffer (&lbs[1].lb);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
877 initbuffer (&filename_lb);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
878
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
879 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
880 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
881 if (streq (tagfile, "-"))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
882 tagf = stdout;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
883 else
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
884 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
885 if (tagf == NULL)
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
886 pfatal (tagfile);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
887 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
889 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
890 * Loop through files finding functions.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
891 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
892 for (i = 0; i < current_arg; ++i)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
893 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
894 switch (argbuffer[i].arg_type)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
895 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
896 case at_language:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
897 lang_func = argbuffer[i].function;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
898 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
899 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
900 case at_regexp:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
901 add_regex (argbuffer[i].what);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
902 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 #endif
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
904 case at_filename:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
905 #ifdef VMS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
906 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
907 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
908 if (got_err)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
909 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
910 error ("Can't find file %s\n", this_file);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
911 argc--, argv++;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
912 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
913 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
914 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
915 this_file = massage_name (this_file);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
916 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
917 #else
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
918 this_file = argbuffer[i].what;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
919 #endif
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
920 /* Input file named "-" means read file names from stdin
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
921 and use them. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
922 if (streq (this_file, "-"))
10761
7aa80669e697 * etags.c (C_entries): Bug corrected in xrealloc of token_str.
Francesco Potortì <pot@gnu.org>
parents: 10754
diff changeset
923 while (readline_internal (&filename_lb, stdin) > 0)
7aa80669e697 * etags.c (C_entries): Bug corrected in xrealloc of token_str.
Francesco Potortì <pot@gnu.org>
parents: 10754
diff changeset
924 process_file (filename_lb.buffer);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
925 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
926 process_file (this_file);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
927 #ifdef VMS
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
928 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
929 #endif
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
930 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
931 }
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
932 }
10761
7aa80669e697 * etags.c (C_entries): Bug corrected in xrealloc of token_str.
Francesco Potortì <pot@gnu.org>
parents: 10754
diff changeset
933
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
934 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 {
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
936 while (nincluded_files-- > 0)
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
937 fprintf (tagf, "\f\n%s,include\n", *included_files++);
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
938
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
939 fclose (tagf);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
940 exit (GOOD);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
941 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
942
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
943 /* If CTAGS, we are here. process_file did not write the tags yet,
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
944 because we want them ordered. Let's do it now. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
945 if (cxref_style)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
946 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
947 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
948 if (tagf == NULL)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
949 pfatal (tagfile);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 put_entries (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
951 exit (GOOD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
952 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
953
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
954 if (update)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
955 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
956 char cmd[BUFSIZ];
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
957 for (i = 0; i < current_arg; ++i)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
959 if (argbuffer[i].arg_type != at_filename)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
960 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
961 sprintf (cmd,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
962 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
963 tagfile, argbuffer[i].what, tagfile);
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
964 if (system (cmd) != GOOD)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
965 fatal ("failed to execute shell command");
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
966 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
967 append_to_tagfile = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
968 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
969
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
970 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
971 if (tagf == NULL)
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
972 pfatal (tagfile);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
973 put_entries (head);
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
974 fclose (tagf);
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
975
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
976 if (update)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
977 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
978 char cmd[BUFSIZ];
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
979 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
980 exit (system (cmd));
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
981 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
982 exit (GOOD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
983 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
984
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
985
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
986 /*
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
987 * Return a Lang_function given the name.
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
988 */
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
989 Lang_function *
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
990 get_language_from_name (name)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
991 char *name;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
992 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
993 struct lang_entry *lang;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
994
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
995 if (name == NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
996 return NULL;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
997 for (lang = lang_names; lang->name != NULL; lang++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
998 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
999 if (streq (name, lang->name))
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1000 return lang->function;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1001 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1002
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1003 return NULL;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1004 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1005
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1006
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1007 /*
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1008 * Return a Lang_function given the interpreter name.
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1009 */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1010 Lang_function *
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1011 get_language_from_interpreter (interpreter)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1012 char *interpreter;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1013 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1014 struct lang_entry *lang;
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1015 char **iname;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1016
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1017 if (interpreter == NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1018 return NULL;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1019 for (lang = lang_names; lang->name != NULL; lang++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1020 if (lang->interpreters != NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1021 for (iname = lang->interpreters; *iname != NULL; iname++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1022 if (streq (*iname, interpreter))
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1023 return lang->function;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1024
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1025 return NULL;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1026 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1027
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1028
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1029
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1030 /*
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1031 * Return a Lang_function given the file suffix.
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1032 */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1033 Lang_function *
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1034 get_language_from_suffix (suffix)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1035 char *suffix;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1036 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1037 struct lang_entry *lang;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1038 char **ext;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1039
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1040 if (suffix == NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1041 return NULL;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1042 for (lang = lang_names; lang->name != NULL; lang++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1043 if (lang->suffixes != NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1044 for (ext = lang->suffixes; *ext != NULL; ext++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1045 if (streq (*ext, suffix))
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1046 return lang->function;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1047
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1048 return NULL;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1049 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1050
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1051
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1052 /*
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1053 * This routine is called on each file argument.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1054 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1055 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1056 process_file (file)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1057 char *file;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1058 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1059 struct stat stat_buf;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1060 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1061
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1062 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1063 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1064 fprintf (stderr, "Skipping %s: it is not a regular file.\n", file);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1067 if (streq (file, tagfile) && !streq (tagfile, "-"))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 fprintf (stderr, "Skipping inclusion of %s in self.\n", file);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1072 inf = fopen (file, "r");
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1073 if (inf == NULL)
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1074 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1075 perror (file);
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1076 return;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1077 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1078
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1079 find_entries (file, inf);
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1080
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1081 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1082 {
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1083 char *filename;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1084
12344
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
1085 if (absolutefn (file))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1086 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1087 /* file is an absolute filename. Canonicalise it. */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1088 filename = absolute_filename (file, cwd);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1089 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1090 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1091 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1092 /* file is a filename relative to cwd. Make it relative
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1093 to the directory of the tags file. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1094 filename = relative_filename (file, tagfiledir);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1095 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1096 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
10990
c0ceaa45ded7 * etags.c (process_file): free (filename) after using it.
Francesco Potortì <pot@gnu.org>
parents: 10801
diff changeset
1097 free (filename);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1098 put_entries (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1099 free_tree (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1100 head = NULL;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1101 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1102 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1103
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104 /*
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3569
diff changeset
1105 * This routine sets up the boolean pseudo-functions which work
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1106 * by setting boolean flags dependent upon the corresponding character
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1107 * Every char which is NOT in that string is not a white char. Therefore,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1108 * all of the array "_wht" is set to FALSE, and then the elements
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1109 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1110 * of a char is TRUE if it is the string "white", else FALSE.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1111 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1112 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1113 init ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1114 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1115 register char *sp;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1116 register int i;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1117
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1118 for (i = 0; i < 0177; i++)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1119 _wht[i] = _etk[i] = _itk[i] = _btk[i] = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1120 for (sp = white; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1121 _wht[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1122 for (sp = endtk; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1123 _etk[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1124 for (sp = intk; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1125 _itk[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1126 for (sp = begtk; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1127 _btk[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1128 _wht[0] = _wht['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1129 _etk[0] = _etk['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1130 _btk[0] = _btk['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1131 _itk[0] = _itk['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1132 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1133
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1134 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1135 * This routine opens the specified file and calls the function
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1136 * which finds the function and type definitions.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1137 */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1138 void
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1139 find_entries (file, inf)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1140 char *file;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1141 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1142 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1143 char *cp;
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1144 Lang_function *function;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1145 NODE *old_last_node;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1146 extern NODE *last_node;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1147
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1148 /* Memory leakage here: the memory block pointed by curfile is never
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1149 released. The amount of memory leaked here is the sum of the
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1150 lengths of the input file names. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1151 curfile = savestr (file);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1152
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1153 /* If user specified a language, use it. */
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1154 function = lang_func;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1155 if (function != NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1156 {
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1157 function (inf);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1158 fclose (inf);
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1159 return;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1160 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1161
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1162 cp = etags_strrchr (file, '.');
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1163 if (cp != NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1164 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1165 cp += 1;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1166 function = get_language_from_suffix (cp);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1167 if (function != NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1168 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1169 function (inf);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1170 fclose (inf);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1171 return;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1172 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1173 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1174
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1175 /* Look for sharp-bang as the first two characters. */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1176 if (readline_internal (&lb, inf) > 2
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1177 && lb.buffer[0] == '#'
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1178 && lb.buffer[1] == '!')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1179 {
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1180 char *lp;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1181
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1182 /* Set lp to point at the first char after the last slash in the
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1183 line or, if no slashes, at the first nonblank. Then set cp to
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1184 the first successive blank and terminate the string. */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1185 lp = etags_strrchr (lb.buffer+2, '/');
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1186 if (lp != NULL)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1187 lp += 1;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1188 else
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1189 for (lp = lb.buffer+2; *lp != '\0' && isspace (*lp); lp++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1190 continue;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1191 for (cp = lp; *cp != '\0' && !isspace (*cp); cp++)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1192 continue;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1193 *cp = '\0';
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1194
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1195 if (strlen (lp) > 0)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1196 {
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1197 function = get_language_from_interpreter (lp);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1198 if (function != NULL)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1199 {
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1200 function (inf);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1201 fclose (inf);
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1202 return;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1203 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1204 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1205 }
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1206 rewind (inf);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1207
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1208 /* Try Fortran. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1209 old_last_node = last_node;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1210 Fortran_functions (inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1211
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1212 /* No Fortran entries found. Try C. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1213 if (old_last_node == last_node)
12344
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
1214 {
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
1215 rewind (inf);
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
1216 default_C_entries (inf);
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
1217 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1218 fclose (inf);
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
1219 return;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1220 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1221
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1222 /* Record a tag. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1223 void
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1224 pfnote (name, is_func, linestart, linelen, lno, cno)
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1225 char *name; /* tag name, if different from definition */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1226 logical is_func; /* tag is a function */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1227 char *linestart; /* start of the line where tag is */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1228 int linelen; /* length of the line where tag is */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1229 int lno; /* line number */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1230 long cno; /* character number */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1231 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1232 register NODE *np = xnew (1, NODE);
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1233
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 /* If ctags mode, change name "main" to M<thisfilename>. */
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1235 if (CTAGS && !cxref_style && streq (name, "main"))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1236 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1237 register char *fp = etags_strrchr (curfile, '/');
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1238 np->name = concat ("M", fp == 0 ? curfile : fp + 1, "");
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1239 fp = etags_strrchr (np->name, '.');
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240 if (fp && fp[1] != '\0' && fp[2] == '\0')
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1241 fp[0] = 0;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1242 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1243 else
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1244 np->name = name;
10623
8a73e71a55e3 * etags.c (pfnote): Initialise been_warned in the node.
Francesco Potortì <pot@gnu.org>
parents: 10449
diff changeset
1245 np->been_warned = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1246 np->file = curfile;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247 np->is_func = is_func;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 np->lno = lno;
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
1249 /* Our char numbers are 0-base, because of C language tradition?
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
1250 ctags compatibility? old versions compatibility? I don't know.
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
1251 Anyway, since emacs's are 1-base we espect etags.el to take care
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
1252 of the difference. If we wanted to have 1-based numbers, we would
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
1253 uncomment the +1 below. */
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
1254 np->cno = cno /* + 1 */ ;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1255 np->left = np->right = NULL;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1256 np->pat = savenstr (linestart, ((CTAGS && !cxref_style) ? 50 : linelen));
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1257
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258 add_node (np, &head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1260
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1261 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1262 * free_tree ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1263 * recurse on left children, iterate on right children.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1265 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1266 free_tree (node)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1267 register NODE *node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1268 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1269 while (node)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1270 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1271 register NODE *node_right = node->right;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1272 free_tree (node->left);
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1273 if (node->name != NULL)
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1274 free (node->name);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1275 free (node->pat);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1276 free ((char *) node);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1277 node = node_right;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1278 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1279 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1280
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1282 * add_node ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1283 * Adds a node to the tree of nodes. In etags mode, we don't keep
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1284 * it sorted; we just keep a linear list. In ctags mode, maintain
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1285 * an ordered tree, with no attempt at balancing.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1286 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1287 * add_node is the only function allowed to add nodes, so it can
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1288 * maintain state.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1289 */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1290 NODE *last_node = NULL;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1291 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292 add_node (node, cur_node_p)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1293 NODE *node, **cur_node_p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1294 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1295 register int dif;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1296 register NODE *cur_node = *cur_node_p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1298 if (cur_node == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1299 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1300 *cur_node_p = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301 last_node = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1303 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1304
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1305 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1306 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1307 /* Etags Mode */
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1308 if (last_node == NULL)
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1309 fatal ("internal error in add_node", 0);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310 last_node->right = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1311 last_node = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1312 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1314 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1315 /* Ctags Mode */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316 dif = strcmp (node->name, cur_node->name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1317
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319 * If this tag name matches an existing one, then
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320 * do not add the node, but maybe print a warning.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 if (!dif)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1324 if (streq (node->file, cur_node->file))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 if (!no_warnings)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1327 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329 node->file, lineno, node->name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 fprintf (stderr, "Second entry ignored\n");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 }
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1333 else if (!cur_node->been_warned && !no_warnings)
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1334 {
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1335 fprintf
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1336 (stderr,
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1337 "Duplicate entry in files %s and %s: %s (Warning only)\n",
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1338 node->file, cur_node->file, node->name);
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1339 cur_node->been_warned = TRUE;
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1340 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 /* Actually add the node */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 add_node (node, dif < 0 ? &cur_node->left : &cur_node->right);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 put_entries (node)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1351 register NODE *node;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1353 register char *sp;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1354
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 if (node == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358 /* Output subentries that precede this one */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359 put_entries (node->left);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 /* Output this entry */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1363 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1365 if (node->name != NULL)
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1366 fprintf (tagf, "%s\177%s\001%d,%d\n",
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1367 node->pat, node->name, node->lno, node->cno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368 else
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1369 fprintf (tagf, "%s\177%d,%d\n",
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1370 node->pat, node->lno, node->cno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 else if (!cxref_style)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1374 fprintf (tagf, "%s\t%s\t",
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1375 node->name, node->file);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1376
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1377 if (node->is_func)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378 { /* a function */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1379 putc (searchar, tagf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1380 putc ('^', tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1381
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1382 for (sp = node->pat; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1383 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 if (*sp == '\\' || *sp == searchar)
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1385 putc ('\\', tagf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1386 putc (*sp, tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1387 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1388 putc (searchar, tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1389 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 { /* a typedef; text pattern inadequate */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1392 fprintf (tagf, "%d", node->lno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1393 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1394 putc ('\n', tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1396 else if (vgrind_style)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1397 fprintf (stdout, "%s %s %d\n",
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 node->name, node->file, (node->lno + 63) / 64);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1399 else
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 621
diff changeset
1400 fprintf (stdout, "%-16s %3d %-16s %s\n",
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1401 node->name, node->lno, node->file, node->pat);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 /* Output subentries that follow this one */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 put_entries (node->right);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1405 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1406
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 /* Length of a number's decimal representation. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1408 int
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 number_len (num)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 long num;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1412 int len = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 if (!num)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1414 return 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 for (; num; num /= 10)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 ++len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 return len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1420 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421 * Return total number of characters that put_entries will output for
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1422 * the nodes in the subtree of the specified node. Works only if
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1423 * we are not ctags, but called only in that case. This count
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1424 * is irrelevant with the new tags.el, but is still supplied for
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1425 * backward compatibility.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 int
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1428 total_size_of_entries (node)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1429 register NODE *node;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1431 register int total;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 if (node == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434 return 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436 total = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1437 for (; node; node = node->right)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1438 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1439 /* Count left subentries. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1440 total += total_size_of_entries (node->left);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1442 /* Count this entry */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1443 total += strlen (node->pat) + 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1444 total += number_len ((long) node->lno) + 1 + number_len (node->cno) + 1;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1445 if (node->name != NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 total += 1 + strlen (node->name); /* \001name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1449 return total;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1451
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1453 * The C symbol tables.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1454 */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1455 enum sym_type
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1456 {
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1457 st_none, st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1458 };
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1460 /* Feed stuff between (but not including) %[ and %] lines to:
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1461 gperf -c -k1,3 -o -p -r -t
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1462 %[
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1463 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1464 %%
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1465 class, C_PLPL, st_C_struct
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1466 domain, C_STAR, st_C_struct
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1467 union, 0, st_C_struct
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1468 struct, 0, st_C_struct
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1469 enum, 0, st_C_enum
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1470 typedef, 0, st_C_typedef
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1471 define, 0, st_C_define
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1472 long, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1473 short, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1474 int, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1475 char, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1476 float, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1477 double, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1478 signed, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1479 unsigned, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1480 auto, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1481 void, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1482 extern, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1483 static, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1484 const, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1485 volatile, 0, st_C_typespec
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1486 %]
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1487 and replace lines between %< and %> with its output. */
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1488 /*%<*/
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1489 /* C code produced by gperf version 1.8.1 (K&R C version) */
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1490 /* Command-line: gperf -c -k1,3 -o -p -r -t */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1491
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1492
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1493 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1494
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1495 #define MIN_WORD_LENGTH 3
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1496 #define MAX_WORD_LENGTH 8
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1497 #define MIN_HASH_VALUE 10
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1498 #define MAX_HASH_VALUE 62
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1499 /*
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1500 21 keywords
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1501 53 is the maximum key range
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1502 */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1503
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1504 static int
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1505 hash (str, len)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1506 register char *str;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1507 register int len;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1508 {
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1509 static unsigned char hash_table[] =
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1510 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1511 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1512 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1513 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1514 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1515 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1516 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1517 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1518 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1519 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1520 62, 62, 62, 62, 62, 62, 62, 2, 62, 7,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1521 6, 9, 15, 30, 62, 24, 62, 62, 1, 24,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1522 7, 27, 13, 62, 19, 26, 18, 27, 1, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1523 62, 62, 62, 62, 62, 62, 62, 62,
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1524 };
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1525 return len + hash_table[str[2]] + hash_table[str[0]];
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1526 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1527
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1528 struct C_stab_entry *
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1529 in_word_set (str, len)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1530 register char *str;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1531 register int len;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1532 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1533
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1534 static struct C_stab_entry wordlist[] =
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1535 {
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1536 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1537 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1538 {"volatile", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1539 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1540 {"long", 0, st_C_typespec},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1541 {"char", 0, st_C_typespec},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1542 {"class", C_PLPL, st_C_struct},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1543 {"",}, {"",}, {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1544 {"const", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1545 {"",}, {"",}, {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1546 {"auto", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1547 {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1548 {"define", 0, st_C_define},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1549 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1550 {"void", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1551 {"",}, {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1552 {"extern", 0, st_C_typespec},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1553 {"static", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1554 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1555 {"domain", C_STAR, st_C_struct},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1556 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1557 {"typedef", 0, st_C_typedef},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1558 {"double", 0, st_C_typespec},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1559 {"enum", 0, st_C_enum},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1560 {"",}, {"",}, {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1561 {"int", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1562 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1563 {"float", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1564 {"",}, {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1565 {"struct", 0, st_C_struct},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1566 {"",}, {"",}, {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1567 {"union", 0, st_C_struct},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1568 {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1569 {"short", 0, st_C_typespec},
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1570 {"",}, {"",},
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1571 {"unsigned", 0, st_C_typespec},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1572 {"signed", 0, st_C_typespec},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1573 };
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1574
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1575 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1576 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1577 register int key = hash (str, len);
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1578
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1579 if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1580 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1581 register char *s = wordlist[key].name;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1582
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1583 if (*s == *str && strneq (str + 1, s + 1, len - 1))
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1584 return &wordlist[key];
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1585 }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1586 }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1587 return 0;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1588 }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1589 /*%>*/
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1590
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1591 enum sym_type
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1592 C_symtype(str, len, c_ext)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1593 char *str;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1594 int len;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1595 int c_ext;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1596 {
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1597 register struct C_stab_entry *se = in_word_set(str, len);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1598
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1599 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1600 return st_none;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1601 return se->type;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1602 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1603
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1604 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1605 * C functions are recognized using a simple finite automaton.
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1606 * funcdef is its state variable.
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1607 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1608 typedef enum
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1609 {
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1610 fnone, /* nothing seen */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1611 ftagseen, /* function-like tag seen */
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
1612 fstartlist, /* just after open parenthesis */
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1613 finlist, /* in parameter list */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1614 flistseen, /* after parameter list */
5044
d3bd7baee39f (FUNCST, TYPEDST, STRUCTST, DEFINEST): Delete excess commas.
Richard M. Stallman <rms@gnu.org>
parents: 4937
diff changeset
1615 fignore /* before open brace */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1616 } FUNCST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1617 FUNCST funcdef;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1618
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1619
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1620 /*
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1621 * typedefs are recognized using a simple finite automaton.
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1622 * typeddef is its state variable.
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1623 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1624 typedef enum
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1625 {
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1626 tnone, /* nothing seen */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1627 ttypedseen, /* typedef keyword seen */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1628 tinbody, /* inside typedef body */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1629 tend, /* just before typedef tag */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1630 tignore /* junk after typedef tag */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1631 } TYPEDST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1632 TYPEDST typdef;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1633
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1634
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1635 /*
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1636 * struct-like structures (enum, struct and union) are recognized
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1637 * using another simple finite automaton. `structdef' is its state
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1638 * variable.
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1639 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1640 typedef enum
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1641 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1642 snone, /* nothing seen yet */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1643 skeyseen, /* struct-like keyword seen */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1644 stagseen, /* struct-like tag seen */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1645 scolonseen, /* colon seen after struct-like tag */
5044
d3bd7baee39f (FUNCST, TYPEDST, STRUCTST, DEFINEST): Delete excess commas.
Richard M. Stallman <rms@gnu.org>
parents: 4937
diff changeset
1646 sinbody /* in struct body: recognize member func defs*/
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1647 } STRUCTST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1648 STRUCTST structdef;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1649
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1650 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1651 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1652 * struct tag, and structtype is the type of the preceding struct-like
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1653 * keyword.
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1654 */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1655 char *structtag = "<uninited>";
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1656 enum sym_type structtype;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1657
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1658 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1659 * Yet another little state machine to deal with preprocessor lines.
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1660 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1661 typedef enum
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1662 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1663 dnone, /* nothing seen */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1664 dsharpseen, /* '#' seen as first char on line */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1665 ddefineseen, /* '#' and 'define' seen */
5044
d3bd7baee39f (FUNCST, TYPEDST, STRUCTST, DEFINEST): Delete excess commas.
Richard M. Stallman <rms@gnu.org>
parents: 4937
diff changeset
1666 dignorerest /* ignore rest of line */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1667 } DEFINEST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1668 DEFINEST definedef;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1669
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1670 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1671 * Set this to TRUE, and the next token considered is called a function.
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
1672 * Used only for GNU emacs's function-defining macros.
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1673 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1674 logical next_token_is_func;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1675
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1676 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1677 * TRUE in the rules part of a yacc file, FALSE outside (parse as C).
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1678 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1679 logical yacc_rules;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1680
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1681 /*
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1682 * consider_token ()
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1683 * checks to see if the current token is at the start of a
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1684 * function, or corresponds to a typedef, or is a struct/union/enum
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1685 * tag.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1686 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1687 * *IS_FUNC gets TRUE iff the token is a function or macro with args.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1688 * C_EXT is which language we are looking at.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1689 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1690 * In the future we will need some way to adjust where the end of
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1691 * the token is; for instance, implementing the C++ keyword
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1692 * `operator' properly will adjust the end of the token to be after
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1693 * whatever follows `operator'.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1694 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1695 * Globals
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1696 * funcdef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1697 * structdef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1698 * definedef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1699 * typdef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1700 * next_token_is_func IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1701 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1702
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1703 logical
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1704 consider_token (str, len, c, c_ext, cblev, is_func)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1705 register char *str; /* IN: token pointer */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1706 register int len; /* IN: token length */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1707 register char c; /* IN: first char after the token */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1708 int c_ext; /* IN: C extensions mask */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1709 int cblev; /* IN: curly brace level */
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1710 logical *is_func; /* OUT: function found */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1711 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1712 enum sym_type toktype = C_symtype (str, len, c_ext);
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1713
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1714 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1715 * Advance the definedef state machine.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1716 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1717 switch (definedef)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1718 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1719 case dnone:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1720 /* We're not on a preprocessor line. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1721 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1722 case dsharpseen:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1723 if (toktype == st_C_define)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1724 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1725 definedef = ddefineseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1726 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1727 else
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1728 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1729 definedef = dignorerest;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1730 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1731 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1732 case ddefineseen:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1733 /*
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
1734 * Make a tag for any macro, unless it is a constant
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
1735 * and constantypedefs is FALSE.
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1736 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1737 definedef = dignorerest;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1738 *is_func = (c == '(');
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1739 if (!*is_func && !constantypedefs)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1740 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1741 else
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1742 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1743 case dignorerest:
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1744 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1745 default:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1746 error ("internal error: definedef value.", 0);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1747 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1748
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1749 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1750 * Now typedefs
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1751 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1752 switch (typdef)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1753 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1754 case tnone:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1755 if (toktype == st_C_typedef)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1756 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1757 if (typedefs)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1758 typdef = ttypedseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1759 funcdef = fnone;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1760 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1761 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1762 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1763 case ttypedseen:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1764 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1765 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1766 case st_none:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1767 case st_C_typespec:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1768 typdef = tend;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1769 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1770 case st_C_struct:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1771 case st_C_enum:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1772 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1773 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1774 /* Do not return here, so the structdef stuff has a chance. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1775 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1776 case tend:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1777 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1778 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1779 case st_C_typespec:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1780 case st_C_struct:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1781 case st_C_enum:
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1782 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1783 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1784 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1785 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1786
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1787 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1788 * This structdef business is currently only invoked when cblev==0.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1789 * It should be recursively invoked whatever the curly brace level,
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1790 * and a stack of states kept, to allow for definitions of structs
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1791 * within structs.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1792 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1793 * This structdef business is NOT invoked when we are ctags and the
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1794 * file is plain C. This is because a struct tag may have the same
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1795 * name as another tag, and this loses with ctags.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1796 *
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1797 * This if statement deals with the typdef state machine as
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1798 * follows: if typdef==ttypedseen and token is struct/union/class/enum,
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1799 * return FALSE. All the other code here is for the structdef
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1800 * state machine.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1801 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1802 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1803 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1804 case st_C_struct:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1805 case st_C_enum:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1806 if (typdef == ttypedseen
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1807 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1808 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1809 structdef = skeyseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1810 structtype = toktype;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1811 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1812 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1813 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1814 if (structdef == skeyseen)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1815 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1816 /* Save the tag for struct/union/class, for functions that may be
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1817 defined inside. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1818 if (structtype == st_C_struct)
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1819 structtag = savenstr (str, len);
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1820 else
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1821 structtag = "<enum>";
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1822 structdef = stagseen;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1823 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1824 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1825
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1826 /* Avoid entering funcdef stuff if typdef is going on. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1827 if (typdef != tnone)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1828 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1829 definedef = dnone;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1830 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1831 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1832
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1833 /* Detect GNU macros. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1834 if (definedef == dnone)
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
1835 if (strneq (str, "DEFUN", len) /* Used in emacs */
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
1836 #if FALSE
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1837 These are defined inside C functions, so currently they
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1838 are not met anyway.
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
1839 || strneq (str, "EXFUN", len) /* Used in glibc */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1840 || strneq (str, "DEFVAR_", 7) /* Used in emacs */
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1841 #endif
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
1842 || strneq (str, "SYSCALL", len) /* Used in glibc (mach) */
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
1843 || strneq (str, "ENTRY", len) /* Used in glibc */
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
1844 || strneq (str, "PSEUDO", len)) /* Used in glibc */
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1845
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1846 {
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1847 next_token_is_func = TRUE;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1848 return FALSE;
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1849 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1850 if (next_token_is_func)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1851 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1852 next_token_is_func = FALSE;
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1853 funcdef = fignore;
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1854 *is_func = TRUE;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1855 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1856 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1857
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1858 /* A function? */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1859 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1860 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1861 case st_C_typespec:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1862 if (funcdef != finlist && funcdef != fignore)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1863 funcdef = fnone; /* should be useless */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1864 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1865 default:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1866 if (funcdef == fnone)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1867 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1868 funcdef = ftagseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1869 *is_func = TRUE;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1870 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1871 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1872 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1873
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1874 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1875 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1876
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1877 /*
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1878 * C_entries ()
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1879 * This routine finds functions, typedefs, #define's and
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1880 * struct/union/enum definitions in C syntax and adds them
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1881 * to the list.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1882 */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1883 typedef struct
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1884 {
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1885 logical valid;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1886 char *str;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1887 logical named;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1888 int linelen;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1889 int lineno;
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
1890 long linepos;
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
1891 char *buffer;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1892 } TOKEN;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1893
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1894 #define current_lb_is_new (newndx == curndx)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1895 #define switch_line_buffers() (curndx = 1 - curndx)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1896
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1897 #define curlb (lbs[curndx].lb)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1898 #define othlb (lbs[1-curndx].lb)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1899 #define newlb (lbs[newndx].lb)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1900 #define curlinepos (lbs[curndx].linepos)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1901 #define othlinepos (lbs[1-curndx].linepos)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1902 #define newlinepos (lbs[newndx].linepos)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1903
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1904 #define CNL_SAVE_DEFINEDEF \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1905 do { \
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1906 curlinepos = charno; \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1907 lineno++; \
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1908 charno += readline (&curlb, inf); \
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1909 lp = curlb.buffer; \
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1910 quotednl = FALSE; \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1911 newndx = curndx; \
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1912 } while (0)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1913
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1914 #define CNL \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1915 do { \
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1916 CNL_SAVE_DEFINEDEF; \
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1917 if (savetok.valid) \
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1918 { \
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1919 tok = savetok; \
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1920 savetok.valid = FALSE; \
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1921 } \
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1922 definedef = dnone; \
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1923 } while (0)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1924
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1925 #define make_tag(isfun) do \
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1926 { \
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1927 if (tok.valid) \
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1928 { \
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1929 char *name = NULL; \
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1930 if (tok.named) \
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1931 name = savestr (token_name.buffer); \
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1932 pfnote (name, isfun, tok.buffer, tok.linelen, tok.lineno, tok.linepos); \
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
1933 } \
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1934 else if (DEBUG) abort (); \
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1935 tok.valid = FALSE; \
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1936 } while (0)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1937
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1938 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1939 C_entries (c_ext, inf)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1940 int c_ext; /* extension of C */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1941 FILE *inf; /* input file */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1942 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1943 register char c; /* latest char read; '\0' for end of line */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1944 register char *lp; /* pointer one beyond the character `c' */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1945 int curndx, newndx; /* indices for current and new lb */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1946 TOKEN tok; /* latest token read */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1947 register int tokoff; /* offset in line of start of current token */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1948 register int toklen; /* length of current token */
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
1949 int cblev; /* current curly brace level */
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
1950 int parlev; /* current parenthesis level */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1951 logical incomm, inquote, inchar, quotednl, midtoken;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1952 logical cplpl;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1953 TOKEN savetok; /* token saved during preprocessor handling */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
1954
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1955
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1956 curndx = newndx = 0;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1957 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1958 charno = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1959 lp = curlb.buffer;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1960 *lp = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1961
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1962 definedef = dnone; funcdef = fnone; typdef = tnone; structdef = snone;
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1963 next_token_is_func = yacc_rules = FALSE;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1964 midtoken = inquote = inchar = incomm = quotednl = FALSE;
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
1965 tok.valid = savetok.valid = FALSE;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
1966 cblev = 0;
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
1967 parlev = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1968 cplpl = c_ext & C_PLPL;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1969
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1970 while (!feof (inf))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1971 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1972 c = *lp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973 if (c == '\\')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 {
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
1975 /* If we're at the end of the line, the next character is a
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
1976 '\0'; don't skip it, because it's the thing that tells us
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
1977 to read the next line. */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1978 if (*lp == '\0')
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1979 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1980 quotednl = TRUE;
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1981 continue;
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1982 }
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
1983 lp++;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1984 c = ' ';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1985 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1986 else if (incomm)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1987 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1988 switch (c)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1990 case '*':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1991 if (*lp == '/')
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1992 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1993 c = *lp++;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1994 incomm = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1995 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1996 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1997 case '\0':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1998 /* Newlines inside comments do not end macro definitions in
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1999 traditional cpp. */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2000 CNL_SAVE_DEFINEDEF;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2001 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2002 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2003 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2004 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2005 else if (inquote)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2006 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2007 switch (c)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2008 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2009 case '"':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2010 inquote = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2011 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2012 case '\0':
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2013 /* Newlines inside strings do not end macro definitions
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2014 in traditional cpp, even though compilers don't
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2015 usually accept them. */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2016 CNL_SAVE_DEFINEDEF;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2017 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2018 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2019 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2020 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2021 else if (inchar)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2022 {
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2023 switch (c)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2024 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2025 case '\0':
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2026 /* Hmmm, something went wrong. */
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2027 CNL;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2028 /* FALLTHRU */
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2029 case '\'':
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2030 inchar = FALSE;
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2031 break;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2032 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2033 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2034 }
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2035 else
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2036 switch (c)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038 case '"':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2039 inquote = TRUE;
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2040 if (funcdef != finlist && funcdef != fignore)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2041 funcdef = fnone;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043 case '\'':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2044 inchar = TRUE;
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2045 if (funcdef != finlist && funcdef != fignore)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2046 funcdef = fnone;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2048 case '/':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2049 if (*lp == '*')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2050 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 lp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052 incomm = TRUE;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2053 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2054 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2055 else if (cplpl && *lp == '/')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 {
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 621
diff changeset
2057 c = 0;
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 621
diff changeset
2058 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2059 }
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2060 else
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2061 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2062 case '%':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2063 if ((c_ext & YACC) && *lp == '%')
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2064 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2065 /* entering or exiting rules section in yacc file */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2066 lp++;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2067 definedef = dnone; funcdef = fnone;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2068 typdef = tnone; structdef = snone;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2069 next_token_is_func = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2070 midtoken = inquote = inchar = incomm = quotednl = FALSE;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2071 cblev = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2072 yacc_rules = !yacc_rules;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2073 continue;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2074 }
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2075 else
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2076 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2077 case '#':
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2078 if (definedef == dnone)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2079 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2080 char *cp;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2081 logical cpptoken = TRUE;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2082
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2083 /* Look back on this line. If all blanks, or nonblanks
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2084 followed by an end of comment, this is a preprocessor
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2085 token. */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2086 for (cp = newlb.buffer; cp < lp-1; cp++)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2087 if (!iswhite (*cp))
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2088 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2089 if (*cp == '*' && *(cp+1) == '/')
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2090 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2091 cp++;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2092 cpptoken = TRUE;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2093 }
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2094 else
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2095 cpptoken = FALSE;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2096 }
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2097 if (cpptoken)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2098 definedef = dsharpseen;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2099 } /* if (definedef == dnone) */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2100
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2101 continue;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2102 } /* switch (c) */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2103
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2104
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2105 /* Consider token only if some complicated conditions are satisfied. */
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2106 if ((definedef != dnone
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2107 || (cblev == 0 && structdef != scolonseen)
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2108 || (cblev == 1 && cplpl && structdef == sinbody))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2109 && typdef != tignore
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2110 && definedef != dignorerest
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2111 && funcdef != finlist)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2112 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2113 if (midtoken)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2114 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2115 if (endtoken (c))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2116 {
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2117 if (cplpl && c == ':' && *lp == ':' && begtoken(*(lp + 1)))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2118 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2119 /*
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2120 * This handles :: in the middle, but not at the
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2121 * beginning of an identifier.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2122 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2123 lp += 2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2124 toklen += 3;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2125 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2126 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2127 {
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2128 logical is_func = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2129
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2130 if (yacc_rules
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2131 || consider_token (newlb.buffer + tokoff, toklen,
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2132 c, c_ext, cblev, &is_func))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2133 {
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
2134 if (structdef == sinbody
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2135 && definedef == dnone
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2136 && is_func)
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2137 /* function defined in C++ class body */
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2138 {
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2139 int strsize = strlen(structtag) + 2 + toklen + 1;
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2140 while (token_name.size < strsize)
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2141 {
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2142 token_name.size *= 2;
11673
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
2143 token_name.buffer
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
2144 = (char *) xrealloc (token_name.buffer,
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
2145 token_name.size);
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2146 }
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2147 strcpy (token_name.buffer, structtag);
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2148 strcat (token_name.buffer, "::");
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2149 strncat (token_name.buffer,
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2150 newlb.buffer+tokoff, toklen);
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2151 tok.named = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2152 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2153 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2154 {
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2155 while (token_name.size < toklen + 1)
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2156 {
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2157 token_name.size *= 2;
11673
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
2158 token_name.buffer
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
2159 = (char *) xrealloc (token_name.buffer,
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
2160 token_name.size);
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2161 }
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2162 strncpy (token_name.buffer,
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2163 newlb.buffer+tokoff, toklen);
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2164 token_name.buffer[toklen] = '\0';
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2165 if (structdef == stagseen
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2166 || typdef == tend
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2167 || (is_func
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2168 && definedef == dignorerest)) /* macro */
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2169 tok.named = TRUE;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2170 else
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2171 tok.named = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2172 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2173 tok.lineno = lineno;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2174 tok.linelen = tokoff + toklen + 1;
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2175 tok.buffer = newlb.buffer;
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2176 tok.linepos = newlinepos;
10801
32f98b512dd9 * etags.c (C_entries): token_saved removed. Initialise tok.valid and
Francesco Potortì <pot@gnu.org>
parents: 10761
diff changeset
2177 tok.valid = TRUE;
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2178
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2179 if (definedef == dnone
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2180 && (funcdef == ftagseen
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2181 || structdef == stagseen
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2182 || typdef == tend))
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2183 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2184 if (current_lb_is_new)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2185 switch_line_buffers ();
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2186 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2187 else
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2188 make_tag (is_func);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2189 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2190 midtoken = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2191 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2192 } /* if (endtoken (c)) */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2193 else if (intoken (c))
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2194 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2195 toklen++;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2196 continue;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2197 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2198 } /* if (midtoken) */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2199 else if (begtoken (c))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2200 {
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2201 switch (definedef)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2202 {
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2203 case dnone:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2204 switch (funcdef)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2205 {
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2206 case fstartlist:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2207 funcdef = finlist;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2208 continue;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2209 case flistseen:
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2210 make_tag (TRUE);
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2211 funcdef = fignore;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2212 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2213 case ftagseen:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2214 funcdef = fnone;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2215 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2216 }
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2217 if (structdef == stagseen)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2218 structdef = snone;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2219 break;
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2220 case dsharpseen:
10623
8a73e71a55e3 * etags.c (pfnote): Initialise been_warned in the node.
Francesco Potortì <pot@gnu.org>
parents: 10449
diff changeset
2221 savetok = tok;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2222 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2223 if (!yacc_rules || lp == newlb.buffer + 1)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2224 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2225 tokoff = lp - 1 - newlb.buffer;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2226 toklen = 1;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2227 midtoken = TRUE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2228 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2229 continue;
10623
8a73e71a55e3 * etags.c (pfnote): Initialise been_warned in the node.
Francesco Potortì <pot@gnu.org>
parents: 10449
diff changeset
2230 } /* if (begtoken) */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2231 } /* if must look at token */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2232
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2233
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2234 /* Detect end of line, colon, comma, semicolon and various braces
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2235 after having handled a token.*/
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2236 switch (c)
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
2237 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2238 case ':':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2239 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2240 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2241 if (structdef == stagseen)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2242 structdef = scolonseen;
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2243 else
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2244 switch (funcdef)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2245 {
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2246 case ftagseen:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2247 if (yacc_rules)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2248 {
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2249 make_tag (FALSE);
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2250 funcdef = fignore;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2251 }
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2252 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2253 case fstartlist:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2254 funcdef = fnone;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2255 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2256 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2257 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2258 case ';':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2259 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2260 break;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2261 if (cblev == 0)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2262 switch (typdef)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2263 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2264 case tend:
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2265 make_tag (FALSE);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2266 /* FALLTHRU */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2267 default:
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2268 typdef = tnone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2269 }
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2270 if (funcdef != fignore)
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2271 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2272 funcdef = fnone;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2273 /* The following instruction invalidates the token.
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2274 Probably the token should be invalidated in all
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2275 other cases where some state machine is reset. */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2276 tok.valid = FALSE;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2277 }
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2278 if (structdef == stagseen)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2279 structdef = snone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2280 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2281 case ',':
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2282 if (definedef != dnone)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2283 break;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2284 if (funcdef != finlist && funcdef != fignore)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2285 funcdef = fnone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2286 if (structdef == stagseen)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2287 structdef = snone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2288 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2289 case '[':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2290 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2291 break;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2292 if (cblev == 0 && typdef == tend)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2293 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2294 typdef = tignore;
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2295 make_tag (FALSE);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2296 break;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2297 }
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2298 if (funcdef != finlist && funcdef != fignore)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2299 funcdef = fnone;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2300 if (structdef == stagseen)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2301 structdef = snone;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2302 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2303 case '(':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2304 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2305 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2306 switch (funcdef)
1938
1045deef809f (C_entries): Don't reset definedef when a newline inside a comment is met.
Richard M. Stallman <rms@gnu.org>
parents: 1796
diff changeset
2307 {
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2308 case fnone:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2309 switch (typdef)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2310 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2311 case ttypedseen:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2312 case tend:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2313 /* Make sure that the next char is not a '*'.
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2314 This handles constructs like:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2315 typedef void OperatorFun (int fun); */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2316 if (*lp != '*')
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2317 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2318 typdef = tignore;
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2319 make_tag (FALSE);
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2320 }
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2321 break;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2322 } /* switch (typdef) */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2323 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2324 case ftagseen:
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2325 funcdef = fstartlist;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2326 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2327 case flistseen:
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2328 funcdef = finlist;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2329 break;
1938
1045deef809f (C_entries): Don't reset definedef when a newline inside a comment is met.
Richard M. Stallman <rms@gnu.org>
parents: 1796
diff changeset
2330 }
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2331 parlev++;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2332 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2333 case ')':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2334 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2335 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2336 if (--parlev == 0)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2337 {
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2338 switch (funcdef)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2339 {
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2340 case fstartlist:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2341 case finlist:
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2342 funcdef = flistseen;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2343 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2344 }
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2345 if (cblev == 0 && typdef == tend)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2346 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2347 typdef = tignore;
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2348 make_tag (FALSE);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2349 }
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2350 }
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2351 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2352 parlev = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2353 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2354 case '{':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2355 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2356 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2357 if (typdef == ttypedseen)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2358 typdef = tinbody;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2359 switch (structdef)
1938
1045deef809f (C_entries): Don't reset definedef when a newline inside a comment is met.
Richard M. Stallman <rms@gnu.org>
parents: 1796
diff changeset
2360 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2361 case skeyseen: /* unnamed struct */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2362 structtag = "_anonymous_";
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2363 structdef = sinbody;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2364 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2365 case stagseen:
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2366 case scolonseen: /* named struct */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2367 structdef = sinbody;
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2368 make_tag (FALSE);
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2369 break;
1938
1045deef809f (C_entries): Don't reset definedef when a newline inside a comment is met.
Richard M. Stallman <rms@gnu.org>
parents: 1796
diff changeset
2370 }
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2371 switch (funcdef)
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2372 {
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2373 case flistseen:
10754
cd1c0b5e8634 * etags.c (C_entries): Initialise the new members of TOKEN.
Francesco Potortì <pot@gnu.org>
parents: 10623
diff changeset
2374 make_tag (TRUE);
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2375 /* FALLTHRU */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2376 case fignore:
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2377 funcdef = fnone;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2378 break;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2379 case fnone:
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2380 /* Neutralize `extern "C" {' grot and look inside structs. */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2381 if (cblev == 0 && structdef == snone && typdef == tnone)
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2382 cblev = -1;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2383 }
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2384 cblev++;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2385 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2386 case '*':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2387 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2388 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2389 if (funcdef == fstartlist)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2390 funcdef = fnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2391 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2392 case '}':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2393 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2394 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2395 if (!noindentypedefs && lp == newlb.buffer + 1)
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2396 {
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2397 cblev = 0; /* reset curly brace level if first column */
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2398 parlev = 0; /* also reset paren level, just in case... */
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2399 }
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2400 else if (cblev > 0)
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2401 cblev--;
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2402 if (cblev == 0)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2403 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2404 if (typdef == tinbody)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2405 typdef = tend;
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2406 /* Memory leakage here: the string pointed by structtag is
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2407 never released, because I fear to miss something and
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2408 break things while freeing the area. The amount of
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2409 memory leaked here is the sum of the lenghts of the
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2410 struct tags.
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2411 if (structdef == sinbody)
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2412 free (structtag); */
10761
7aa80669e697 * etags.c (C_entries): Bug corrected in xrealloc of token_str.
Francesco Potortì <pot@gnu.org>
parents: 10754
diff changeset
2413
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2414 structdef = snone;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2415 structtag = "<error>";
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2416 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2417 break;
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2418 case '=':
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2419 case '#': case '+': case '-': case '~': case '&': case '%': case '/':
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2420 case '|': case '^': case '!': case '<': case '>': case '.': case '?':
4937
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2421 if (definedef != dnone)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2422 break;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2423 /* These surely cannot follow a function tag. */
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2424 if (funcdef != finlist && funcdef != fignore)
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2425 funcdef = fnone;
50db67ef8d64 Mon Nov 8 19:56:20 MET 1993 Tom Hageman (tom@basil.icce.rug.nl)
Francesco Potortì <pot@gnu.org>
parents: 4905
diff changeset
2426 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2427 case '\0':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2428 /* If a macro spans multiple lines don't reset its state. */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2429 if (quotednl)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2430 CNL_SAVE_DEFINEDEF;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2431 else
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2432 CNL;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2433 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2434 } /* switch (c) */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2435
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2436 } /* while not eof */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2437 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2438
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2439 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2440 * Process either a C++ file or a C file depending on the setting
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2441 * of a global flag.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2442 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2443 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2444 default_C_entries (inf)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2445 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2446 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2447 C_entries (cplusplus ? C_PLPL : 0, inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2448 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2449
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2450 /* Always do plain ANSI C. */
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2451 void
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2452 plain_C_entries (inf)
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2453 FILE *inf;
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2454 {
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2455 C_entries (0, inf);
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2456 }
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2457
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2458 /* Always do C++. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2459 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2460 Cplusplus_entries (inf)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2461 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2462 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2463 C_entries (C_PLPL, inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2464 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2465
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2466 /* Always do C*. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2467 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2468 Cstar_entries (inf)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2469 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2470 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2471 C_entries (C_STAR, inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2472 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2473
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2474 /* Always do Yacc. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2475 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2476 Yacc_entries (inf)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2477 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2478 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2479 C_entries (YACC, inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2480 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2481
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2482 /* Fortran parsing */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2483
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2484 char *dbp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2485
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2486 logical
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2487 tail (cp)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2488 char *cp;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2489 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2490 register int len = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2491
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2492 while (*cp && lowcase(*cp) == lowcase(dbp[len]))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2493 cp++, len++;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2494 if (*cp == '\0' && !intoken(dbp[len]))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2495 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2496 dbp += len;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2497 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2498 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2499 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2500 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2501
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2502 void
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2503 takeprec ()
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2504 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2505 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2506 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2507 if (*dbp != '*')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2508 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2509 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2510 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2511 dbp++;
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2512 if (strneq (dbp, "(*)", 3))
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2513 {
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2514 dbp += 3;
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2515 return;
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2516 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2517 if (!isdigit (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2518 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2519 --dbp; /* force failure */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2520 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2521 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2522 do
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2523 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2524 while (isdigit (*dbp));
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2525 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2526
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2527 void
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2528 getit (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2529 FILE *inf;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2530 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2531 register char *cp;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2532
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2533 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2534 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2535 if (*dbp == '\0')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2536 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2537 lineno++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2538 linecharno = charno;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2539 charno += readline (&lb, inf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2540 dbp = lb.buffer;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2541 if (dbp[5] != '&')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2542 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2543 dbp += 6;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2544 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2545 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2546 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2547 if (!isalpha (*dbp)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2548 && *dbp != '_'
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2549 && *dbp != '$')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2550 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2551 for (cp = dbp + 1;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2552 (*cp
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2553 && (isalpha (*cp) || isdigit (*cp) || (*cp == '_') || (*cp == '$')));
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2554 cp++)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2555 continue;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2556 pfnote (NULL, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2557 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2558
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2559 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2560 Fortran_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2561 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2562 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2563 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2564 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2565
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2566 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2567 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2568 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2569 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2570 charno += readline (&lb, inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2571 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2572 if (*dbp == '%')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2573 dbp++; /* Ratfor escape to fortran */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2574 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2575 dbp++;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2576 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2577 continue;
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2578 switch (lowcase (*dbp))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2579 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2580 case 'i':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2581 if (tail ("integer"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2583 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2584 case 'r':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2585 if (tail ("real"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2586 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2587 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2588 case 'l':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2589 if (tail ("logical"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2590 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2591 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2592 case 'c':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2593 if (tail ("complex") || tail ("character"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2594 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2595 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2596 case 'd':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2597 if (tail ("double"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2598 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2599 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2600 dbp++;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2601 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2602 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2603 if (tail ("precision"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2604 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2605 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2606 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2607 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2608 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2609 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2610 dbp++;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2611 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2612 continue;
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2613 switch (lowcase (*dbp))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2614 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2615 case 'f':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2616 if (tail ("function"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2617 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2618 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2619 case 's':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2620 if (tail ("subroutine"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2621 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2622 continue;
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
2623 case 'e':
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
2624 if (tail ("entry"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2625 getit (inf);
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
2626 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2627 case 'p':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2628 if (tail ("program"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2629 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2630 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2631 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2632 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2633 if (tail ("procedure"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2634 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2635 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2636 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2637 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2638 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2639
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2640 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2641 * Bob Weiner, Motorola Inc., 4/3/94
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2642 * Unix and microcontroller assembly tag handling
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2643 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2644 */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2645 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2646 Asm_labels (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2647 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2648 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2649 register char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2650
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2651 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2652 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2653
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2654 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2655 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2656 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2657 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2658 charno += readline (&lb, inf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2659 cp = lb.buffer;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2660
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2661 /* If first char is alphabetic or one of [_.$], test for colon
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2662 following identifier. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2663 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2664 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2665 /* Read past label. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2666 cp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2667 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2668 cp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2669 if (*cp == ':' || isspace (*cp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2670 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2671 /* Found end of label, so copy it and add it to the table. */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2672 pfnote (NULL, TRUE,
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2673 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2674 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2675 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2676 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2677 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2678
13404
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2679 /*
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2680 * Perl support by Bart Robinson <lomew@cs.utah.edu>
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2681 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2682 */
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2683 void
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2684 Perl_functions (inf)
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2685 FILE *inf;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2686 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2687 register char *cp;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2688
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2689 lineno = 0;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2690 charno = 0;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2691
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2692 while (!feof (inf))
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2693 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2694 lineno++;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2695 linecharno = charno;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2696 charno += readline (&lb, inf);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2697 cp = lb.buffer;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2698
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2699 if (*cp++ == 's' && *cp++ == 'u' && *cp++ == 'b' && isspace(*cp++))
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2700 {
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2701 while (*cp && isspace(*cp))
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2702 cp++;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2703 while (*cp && ! isspace(*cp) && *cp != '{')
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2704 cp++;
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2705 pfnote (NULL, TRUE,
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2706 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2707 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2708 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2709 }
9d6c77b66cfb * etags.c (get_lang_from_name, get_lang_from_interpreter,
Francesco Potortì <pot@gnu.org>
parents: 13380
diff changeset
2710
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2711 /* Added by Mosur Mohan, 4/22/88 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2712 /* Pascal parsing */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2713
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2714 #define GET_NEW_LINE \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715 { \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716 linecharno = charno; lineno++; \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2717 charno += 1 + readline (&lb, inf); \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2718 dbp = lb.buffer; \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2719 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2720
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
2721 /*
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
2722 * Locates tags for procedures & functions. Doesn't do any type- or
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
2723 * var-definitions. It does look for the keyword "extern" or
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
2724 * "forward" immediately following the procedure statement; if found,
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
2725 * the tag is skipped.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2728 Pascal_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2729 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2730 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2731 struct linebuffer tline; /* mostly copied from C_entries */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2732 long save_lcno;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2733 int save_lineno, save_len;
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2734 char c;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2735
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2736 logical /* each of these flags is TRUE iff: */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2737 incomment, /* point is inside a comment */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2738 inquote, /* point is inside '..' string */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2739 get_tagname, /* point is after PROCEDURE/FUNCTION
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2740 keyword, so next item = potential tag */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2741 found_tag, /* point is after a potential tag */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2742 inparms, /* point is within parameter-list */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2743 verify_tag; /* point has passed the parm-list, so the
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2744 next token will determine whether this
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2745 is a FORWARD/EXTERN to be ignored, or
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2746 whether it is a real tag */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2747
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2748 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2749 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2750 dbp = lb.buffer;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2751 *dbp = '\0';
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2752 save_len = 0;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2753 initbuffer (&tline);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2754
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2755 incomment = inquote = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2756 found_tag = FALSE; /* have a proc name; check if extern */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2757 get_tagname = FALSE; /* have found "procedure" keyword */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2758 inparms = FALSE; /* found '(' after "proc" */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2759 verify_tag = FALSE; /* check if "extern" is ahead */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2760
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2761 /* long main loop to get next char */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2762 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2763 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2764 c = *dbp++;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2765 if (c == '\0') /* if end of line */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2766 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2767 GET_NEW_LINE;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2768 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2769 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2770 if (!((found_tag && verify_tag) ||
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2771 get_tagname))
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2772 c = *dbp++; /* only if don't need *dbp pointing
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2773 to the beginning of the name of
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2774 the procedure or function */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2775 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2776 if (incomment)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2777 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2778 if (c == '}') /* within { } comments */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2779 incomment = FALSE;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2780 else if (c == '*' && *dbp == ')') /* within (* *) comments */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2781 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2782 dbp++;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2783 incomment = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2784 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2785 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2786 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2787 else if (inquote)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2789 if (c == '\'')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790 inquote = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2791 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2792 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2793 else
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2794 switch (c)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2795 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2796 case '\'':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2797 inquote = TRUE; /* found first quote */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2798 continue;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2799 case '{': /* found open { comment */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2800 incomment = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2802 case '(':
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2803 if (*dbp == '*') /* found open (* comment */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2805 incomment = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808 else if (found_tag) /* found '(' after tag, i.e., parm-list */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 inparms = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2811 case ')': /* end of parms list */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2812 if (inparms)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2813 inparms = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2814 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2815 case ';':
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2816 if (found_tag && !inparms) /* end of proc or fn stmt */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2817 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818 verify_tag = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2819 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2820 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2821 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2822 }
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2823 if (found_tag && verify_tag && (*dbp != ' '))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2824 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2825 /* check if this is an "extern" declaration */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2826 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2827 continue;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2828 if (lowcase (*dbp == 'e'))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2829 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2830 if (tail ("extern")) /* superfluous, really! */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2831 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2832 found_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2833 verify_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2834 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2835 }
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2836 else if (lowcase (*dbp) == 'f')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2837 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2838 if (tail ("forward")) /* check for forward reference */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2839 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2840 found_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2841 verify_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2842 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2843 }
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2844 if (found_tag && verify_tag) /* not external proc, so make tag */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2845 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846 found_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2847 verify_tag = FALSE;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2848 pfnote (NULL, TRUE,
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2849 tline.buffer, save_len, save_lineno, save_lcno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2851 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2852 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2853 if (get_tagname) /* grab name of proc or fn */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2854 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2855 int size;
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2856
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2857 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2858 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2859
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2860 /* save all values for later tagging */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2861 size = strlen (lb.buffer) + 1;
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2862 while (size > tline.size)
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2863 {
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2864 tline.size *= 2;
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2865 tline.buffer = (char *) xrealloc (tline.buffer, tline.size);
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2866 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2867 strcpy (tline.buffer, lb.buffer);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2868 save_lineno = lineno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2869 save_lcno = linecharno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2870
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2871 /* grab block name */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2872 for (dbp++; *dbp && (!endtoken (*dbp)); dbp++)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2873 continue;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2874 save_len = dbp - lb.buffer + 1;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2875 get_tagname = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2876 found_tag = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2877 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2878
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2879 /* and proceed to check for "extern" */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2880 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2881 else if (!incomment && !inquote && !found_tag)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2882 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2883 /* check for proc/fn keywords */
12398
ccfd646cfad9 * etags.c (plain_C_entries): new function.
Francesco Potortì <pot@gnu.org>
parents: 12344
diff changeset
2884 switch (lowcase (c))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2885 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2886 case 'p':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2887 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2888 get_tagname = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2889 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2890 case 'f':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2891 if (tail ("unction"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2892 get_tagname = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2893 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2894 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2895 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2896 } /* while not eof */
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2897
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2898 free (tline.buffer);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2899 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2900
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2901 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2902 * lisp tag functions
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2903 * look for (def or (DEF, quote or QUOTE
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2904 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2905 int
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2906 L_isdef (strp)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2907 register char *strp;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2908 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2909 return ((strp[1] == 'd' || strp[1] == 'D')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2910 && (strp[2] == 'e' || strp[2] == 'E')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2911 && (strp[3] == 'f' || strp[3] == 'F'));
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2912 }
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2913
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2914 int
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2915 L_isquote (strp)
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2916 register char *strp;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2917 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2918 return ((*(++strp) == 'q' || *strp == 'Q')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2919 && (*(++strp) == 'u' || *strp == 'U')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2920 && (*(++strp) == 'o' || *strp == 'O')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2921 && (*(++strp) == 't' || *strp == 'T')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2922 && (*(++strp) == 'e' || *strp == 'E')
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2923 && isspace(*(++strp)));
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2924 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2925
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2926 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2927 L_getit ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2928 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2929 register char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2930
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2931 if (*dbp == '\'') /* Skip prefix quote */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2932 dbp++;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2933 else if (*dbp == '(' && L_isquote (dbp)) /* Skip "(quote " */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2934 {
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2935 dbp += 7;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2936 while (isspace(*dbp))
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2937 dbp++;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2938 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2939 for (cp = dbp /*+1*/;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2940 *cp && *cp != '(' && *cp != ' ' && *cp != ')';
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
2941 cp++)
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2942 continue;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2943 if (cp == dbp)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2944 return;
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
2945
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
2946 pfnote (NULL, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2947 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2948
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2949 void
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2950 Lisp_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2951 FILE *inf;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2952 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2953 lineno = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2954 charno = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2955
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2956 while (!feof (inf))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2957 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2958 lineno++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2959 linecharno = charno;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2960 charno += readline (&lb, inf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2961 dbp = lb.buffer;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2962 if (dbp[0] == '(')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2963 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2964 if (L_isdef (dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2965 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2966 while (!isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2967 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2968 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2969 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2970 L_getit ();
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2971 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2972 else
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2973 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2974 /* Check for (foo::defmumble name-defined ... */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2975 do
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2976 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2977 while (*dbp && !isspace (*dbp)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2978 && *dbp != ':' && *dbp != '(' && *dbp != ')');
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2979 if (*dbp == ':')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2980 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2981 do
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2982 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2983 while (*dbp == ':');
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2984
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2985 if (L_isdef (dbp - 1))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2986 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2987 while (!isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2988 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2989 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2990 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2991 L_getit ();
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2992 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2993 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2994 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2995 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2996 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2997 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2998
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2999 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3000 * Scheme tag functions
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3001 * look for (def... xyzzy
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3002 * look for (def... (xyzzy
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3003 * look for (def ... ((...(xyzzy ....
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3004 * look for (set! xyzzy
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3005 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3006
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3007 void get_scheme ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3008
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3009 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3010 Scheme_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3011 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3012 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3013 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3014 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3015
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3016 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3017 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3018 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3019 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3020 charno += readline (&lb, inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3021 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3022 if (dbp[0] == '(' &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3023 (dbp[1] == 'D' || dbp[1] == 'd') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3024 (dbp[2] == 'E' || dbp[2] == 'e') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3025 (dbp[3] == 'F' || dbp[3] == 'f'))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3026 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3027 while (!isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3028 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3029 /* Skip over open parens and white space */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3030 while (*dbp && (isspace (*dbp) || *dbp == '('))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3031 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3032 get_scheme ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3033 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3034 if (dbp[0] == '(' &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3035 (dbp[1] == 'S' || dbp[1] == 's') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3036 (dbp[2] == 'E' || dbp[2] == 'e') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3037 (dbp[3] == 'T' || dbp[3] == 't') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3038 (dbp[4] == '!' || dbp[4] == '!') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3039 (isspace (dbp[5])))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3040 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3041 while (!isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3042 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3043 /* Skip over white space */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3044 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3045 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3046 get_scheme ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3047 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3048 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3049 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3050
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3051 void
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3052 get_scheme ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3053 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3054 register char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3055
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3056 if (*dbp == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3057 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3058 /* Go till you get to white space or a syntactic break */
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3059 for (cp = dbp + 1;
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3060 *cp && *cp != '(' && *cp != ')' && !isspace (*cp);
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3061 cp++)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3062 continue;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3063 pfnote (NULL, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3064 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3065
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3066 /* Find tags in TeX and LaTeX input files. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3067
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3068 /* TEX_toktab is a table of TeX control sequences that define tags.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3069 Each TEX_tabent records one such control sequence.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3070 CONVERT THIS TO USE THE Stab TYPE!! */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3071 struct TEX_tabent
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3072 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3073 char *name;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3074 int len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3075 };
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3076
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3077 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3078
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3079 /* Default set of control sequences to put into TEX_toktab.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3080 The value of environment var TEXTAGS is prepended to this. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3081
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3082 char *TEX_defenv = "\
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
3083 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
3084 :part:appendix:entry:index";
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3085
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3086 void TEX_mode ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3087 struct TEX_tabent *TEX_decode_env ();
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3088 int TEX_Token ();
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3089 #if TeX_named_tokens
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3090 void TEX_getit ();
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3091 #endif
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3092
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3093 char TEX_esc = '\\';
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3094 char TEX_opgrp = '{';
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3095 char TEX_clgrp = '}';
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3096
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3097 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3098 * TeX/LaTeX scanning loop.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3099 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3100 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3101 TeX_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3102 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3103 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3104 char *lasthit;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3105
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3106 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3107 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3108
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3109 /* Select either \ or ! as escape character. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3110 TEX_mode (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3111
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3112 /* Initialize token table once from environment. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3113 if (!TEX_toktab)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3114 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3115
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3116 while (!feof (inf))
1040
eb7ebe86e885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1026
diff changeset
3117 { /* Scan each line in file */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3118 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3119 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3120 charno += readline (&lb, inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3121 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3122 lasthit = dbp;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3123 while (dbp = etags_strchr (dbp, TEX_esc)) /* Look at each esc in line */
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3124 {
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3125 register int i;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3126
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3127 if (!*(++dbp))
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3128 break;
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3129 linecharno += dbp - lasthit;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3130 lasthit = dbp;
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3131 i = TEX_Token (lasthit);
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3132 if (0 <= i)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3133 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3134 pfnote (NULL, TRUE,
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3135 lb.buffer, strlen (lb.buffer), lineno, linecharno);
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3136 #if TeX_named_tokens
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3137 TEX_getit (lasthit, TEX_toktab[i].len);
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3138 #endif
1040
eb7ebe86e885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1026
diff changeset
3139 break; /* We only save a line once */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3140 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3141 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3142 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3143 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3144
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3145 #define TEX_LESC '\\'
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3146 #define TEX_SESC '!'
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3147 #define TEX_cmt '%'
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3148
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3149 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3150 chars accordingly. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3151 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3152 TEX_mode (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3153 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3154 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3155 int c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3156
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3157 while ((c = getc (inf)) != EOF)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3158 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3159 /* Skip to next line if we hit the TeX comment char. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3160 if (c == TEX_cmt)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3161 while (c != '\n')
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3162 c = getc (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3163 else if (c == TEX_LESC || c == TEX_SESC )
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3164 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3165 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3166
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3167 if (c == TEX_LESC)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3168 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3169 TEX_esc = TEX_LESC;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3170 TEX_opgrp = '{';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3171 TEX_clgrp = '}';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3172 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3173 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3174 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3175 TEX_esc = TEX_SESC;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3176 TEX_opgrp = '<';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3177 TEX_clgrp = '>';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3178 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3179 rewind (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3180 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3181
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3182 /* Read environment and prepend it to the default string.
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3183 Build token table. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3184 struct TEX_tabent *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3185 TEX_decode_env (evarname, defenv)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3186 char *evarname;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3187 char *defenv;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3188 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3189 register char *env, *p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3190
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3191 struct TEX_tabent *tab;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3192 int size, i;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3193
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3194 /* Append default string to environment. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3195 env = getenv (evarname);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3196 if (!env)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3197 env = defenv;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3198 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3199 env = concat (env, defenv, "");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3200
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3201 /* Allocate a token table */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3202 for (size = 1, p = env; p;)
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3203 if ((p = etags_strchr (p, ':')) && *(++p))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3204 size++;
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3205 /* Add 1 to leave room for null terminator. */
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3206 tab = xnew (size + 1, struct TEX_tabent);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3207
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3208 /* Unpack environment string into token table. Be careful about */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3209 /* zero-length strings (leading ':', "::" and trailing ':') */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3210 for (i = 0; *env;)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3211 {
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3212 p = etags_strchr (env, ':');
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3213 if (!p) /* End of environment string. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3214 p = env + strlen (env);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3215 if (p - env > 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3216 { /* Only non-zero strings. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3217 tab[i].name = savenstr (env, p - env);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3218 tab[i].len = strlen (tab[i].name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3219 i++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3220 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3221 if (*p)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3222 env = p + 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3223 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3224 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3225 tab[i].name = NULL; /* Mark end of table. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3226 tab[i].len = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3227 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3228 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3229 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3230 return tab;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3231 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3232
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3233 #if TeX_named_tokens
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3234 /* Record a tag defined by a TeX command of length LEN and starting at NAME.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3235 The name being defined actually starts at (NAME + LEN + 1).
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3236 But we seem to include the TeX command in the tag name. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3237 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3238 TEX_getit (name, len)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3239 char *name;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3240 int len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3241 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3242 char *p = name + len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3243
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3244 if (*name == '\0')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3245 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3246
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3247 /* Let tag name extend to next group close (or end of line) */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3248 while (*p && *p != TEX_clgrp)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3249 p++;
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3250 pfnote (savenstr (name, p-name), TRUE,
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3251 lb.buffer, strlen (lb.buffer), lineno, linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3252 }
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3253 #endif
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3254
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3255 /* If the text at CP matches one of the tag-defining TeX command names,
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3256 return the pointer to the first occurrence of that command in TEX_toktab.
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3257 Otherwise return -1.
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3258 Keep the capital `T' in `Token' for dumb truncating compilers
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3259 (this distinguishes it from `TEX_toktab' */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3260 int
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3261 TEX_Token (cp)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3262 char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3263 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3264 int i;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3265
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3266 for (i = 0; TEX_toktab[i].len > 0; i++)
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3267 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3268 return i;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3269 return -1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3270 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3271
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3272 /* Support for Prolog. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3273
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3274 /* Whole head (not only functor, but also arguments)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3275 is gotten in compound term. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3276 void
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3277 prolog_getit (s)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3278 char *s;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3279 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3280 char *save_s;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3281 int insquote, npar;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3282
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3283 save_s = s;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3284 insquote = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3285 npar = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3286 while (1)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3287 {
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3288 if (s[0] == '\0') /* syntax error. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3289 return;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3290 else if (insquote && s[0] == '\'' && s[1] == '\'')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3291 s += 2;
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3292 else if (s[0] == '\'')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3293 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3294 insquote = !insquote;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3295 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3296 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3297 else if (!insquote && s[0] == '(')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3298 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3299 npar++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3300 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3301 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3302 else if (!insquote && s[0] == ')')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3303 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3304 npar--;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3305 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3306 if (npar == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3307 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3308 else if (npar < 0) /* syntax error. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3309 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3310 }
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3311 else if (!insquote && s[0] == '.'
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3312 && (isspace (s[1]) || s[1] == '\0'))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3313 { /* fullstop. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3314 if (npar != 0) /* syntax error. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3315 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3316 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3317 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3318 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3319 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3320 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3321 }
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3322 pfnote (NULL, TRUE, save_s, s-save_s, lineno, linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3323 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3324
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3325 /* It is assumed that prolog predicate starts from column 0. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3326 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3327 Prolog_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3328 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3329 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3330 void skip_comment (), prolog_getit ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3331
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3332 lineno = linecharno = charno = 0;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3333 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3334 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3335 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3336 linecharno += charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3337 charno = readline (&lb, inf) + 1; /* 1 for newline. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3338 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3339 if (isspace (dbp[0])) /* not predicate header. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3340 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3341 else if (dbp[0] == '%') /* comment. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3342 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3343 else if (dbp[0] == '/' && dbp[1] == '*') /* comment. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3344 skip_comment (&lb, inf, &lineno, &linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3345 else /* found. */
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3346 prolog_getit (dbp);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3347 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3348 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3349
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3350 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3351 skip_comment (plb, inf, plineno, plinecharno)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3352 struct linebuffer *plb;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3353 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3354 int *plineno; /* result */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3355 long *plinecharno; /* result */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3356 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3357 char *cp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3358
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3359 do
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3360 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3361 for (cp = plb->buffer; *cp != '\0'; cp++)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3362 if (cp[0] == '*' && cp[1] == '/')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3363 return;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3364 (*plineno)++;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3365 *plinecharno += readline (plb, inf) + 1; /* 1 for newline. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3366 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3367 while (!feof(inf));
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3368 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3369
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3370 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3371 /* Take a string like "/blah/" and turn it into "blah", making sure
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3372 that the first and last characters are the same, and handling
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3373 quoted separator characters. Actually, stops on the occurence of
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3374 an unquoted separator. Also turns "\t" into a Tab character.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3375 Returns pointer to terminating separator. Works in place. Null
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3376 terminates name string. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3377 char *
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3378 scan_separators (name)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3379 char *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3380 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3381 char sep = name[0];
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3382 char *copyto = name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3383 logical quoted = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3384
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3385 for (++name; *name != '\0'; ++name)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3386 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3387 if (quoted)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3388 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3389 if (*name == 't')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3390 *copyto++ = '\t';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3391 else if (*name == sep)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3392 *copyto++ = sep;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3393 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3394 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3395 /* Something else is quoted, so preserve the quote. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3396 *copyto++ = '\\';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3397 *copyto++ = *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3398 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3399 quoted = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3400 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3401 else if (*name == '\\')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3402 quoted = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3403 else if (*name == sep)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3404 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3405 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3406 *copyto++ = *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3407 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3408
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3409 /* Terminate copied string. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3410 *copyto = '\0';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3411 return name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3412 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3413
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3414 /* Turn a name, which is an ed-style (but Emacs syntax) regular
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3415 expression, into a real regular expression by compiling it. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3416 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3417 add_regex (regexp_pattern)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3418 char *regexp_pattern;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3419 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3420 char *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3421 const char *err;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3422 struct re_pattern_buffer *patbuf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3423
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3424 if (regexp_pattern == NULL)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3425 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3426 /* Remove existing regexps. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3427 num_patterns = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3428 patterns = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3429 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3430 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3431
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3432 if (regexp_pattern[0] == '\0')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3433 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3434 error ("missing regexp", 0);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3435 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3436 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3437 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3438 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3439 error ("%s: unterminated regexp", regexp_pattern);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3440 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3441 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3442 name = scan_separators (regexp_pattern);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3443 if (regexp_pattern[0] == '\0')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3444 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3445 error ("null regexp", 0);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3446 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3447 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3448 (void) scan_separators (name);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3449
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3450 patbuf = xnew (1, struct re_pattern_buffer);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3451 patbuf->translate = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3452 patbuf->fastmap = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3453 patbuf->buffer = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3454 patbuf->allocated = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3455
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3456 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3457 if (err != NULL)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3458 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3459 error ("%s while compiling pattern", err);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3460 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3461 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3462
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3463 num_patterns += 1;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3464 if (num_patterns == 1)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3465 patterns = xnew (1, struct pattern);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3466 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3467 patterns = ((struct pattern *)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3468 xrealloc (patterns,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3469 (num_patterns * sizeof (struct pattern))));
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3470 patterns[num_patterns - 1].pattern = patbuf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3471 patterns[num_patterns - 1].name_pattern = savestr (name);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3472 patterns[num_patterns - 1].error_signaled = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3473 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3474
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3475 /*
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
3476 * Do the substitutions indicated by the regular expression and
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3477 * arguments.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3478 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3479 char *
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3480 substitute (in, out, regs)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3481 char *in, *out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3482 struct re_registers *regs;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3483 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3484 char *result = NULL, *t;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3485 int size = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3486
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3487 /* Pass 1: figure out how much size to allocate. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3488 for (t = out; *t; ++t)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3489 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3490 if (*t == '\\')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3491 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3492 ++t;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3493 if (!*t)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3494 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3495 fprintf (stderr, "%s: pattern subtitution ends prematurely\n",
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3496 progname);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3497 return NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3498 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3499 if (isdigit (*t))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3500 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3501 int dig = *t - '0';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3502 size += regs->end[dig] - regs->start[dig];
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3503 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3504 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3505 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3506
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3507 /* Allocate space and do the substitutions. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3508 result = xnew (size + 1, char);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3509 size = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3510 for (; *out; ++out)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3511 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3512 if (*out == '\\')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3513 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3514 ++out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3515 if (isdigit (*out))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3516 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3517 /* Using "dig2" satisfies my debugger. Bleah. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3518 int dig2 = *out - '0';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3519 strncpy (result + size, in + regs->start[dig2],
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3520 regs->end[dig2] - regs->start[dig2]);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3521 size += regs->end[dig2] - regs->start[dig2];
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3522 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3523 else
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
3524 result[size++] = *out;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3525 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3526 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3527 result[size++] = *out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3528 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3529 result[size] = '\0';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3530
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3531 return result;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3532 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3533
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3534 #endif /* ETAGS_REGEXPS */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3535 /* Initialize a linebuffer for use */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3536 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3537 initbuffer (linebuffer)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3538 struct linebuffer *linebuffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3539 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3540 linebuffer->size = 200;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3541 linebuffer->buffer = xnew (200, char);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3542 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3543
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3544 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3545 * Read a line of text from `stream' into `linebuffer'.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3546 * Return the number of characters read from `stream',
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3547 * which is the length of the line including the newline, if any.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3548 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3549 long
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3550 readline_internal (linebuffer, stream)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3551 struct linebuffer *linebuffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3552 register FILE *stream;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3553 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3554 char *buffer = linebuffer->buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3555 register char *p = linebuffer->buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3556 register char *pend;
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3557 int chars_deleted;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3558
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3569
diff changeset
3559 pend = p + linebuffer->size; /* Separate to avoid 386/IX compiler bug. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3560
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3561 while (1)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3562 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3563 register int c = getc (stream);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3564 if (p == pend)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3565 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3566 linebuffer->size *= 2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3567 buffer = (char *) xrealloc (buffer, linebuffer->size);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3568 p += buffer - linebuffer->buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3569 pend = buffer + linebuffer->size;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3570 linebuffer->buffer = buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3571 }
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3572 if (c == EOF)
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3573 {
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3574 chars_deleted = 0;
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3575 break;
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3576 }
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3577 if (c == '\n')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3578 {
10990
c0ceaa45ded7 * etags.c (process_file): free (filename) after using it.
Francesco Potortì <pot@gnu.org>
parents: 10801
diff changeset
3579 if (p > buffer && p[-1] == '\r')
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3580 {
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3581 *--p = '\0';
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3582 chars_deleted = 2;
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3583 }
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3584 else
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3585 {
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3586 *p = '\0';
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3587 chars_deleted = 1;
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3588 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3589 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3590 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3591 *p++ = c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3592 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3593
10376
b1c4515958b6 * etags.c (Lang_function): Use void instead to declare the
Francesco Potortì <pot@gnu.org>
parents: 10355
diff changeset
3594 return p - buffer + chars_deleted;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3595 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3596
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3597 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3598 * Like readline_internal, above, but try to match the input
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3599 * line against any existing regular expressions.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3600 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3601 long
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3602 readline (linebuffer, stream)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3603 struct linebuffer *linebuffer;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3604 FILE *stream;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3605 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3606 /* Read new line. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3607 int i;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3608 long result = readline_internal (linebuffer, stream);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3609
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3610 #ifdef ETAGS_REGEXPS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3611 /* Match against all listed patterns. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3612 for (i = 0; i < num_patterns; ++i)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3613 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3614 int match = re_match (patterns[i].pattern, linebuffer->buffer,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3615 (int)result, 0, &patterns[i].regs);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3616 switch (match)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3617 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3618 case -2:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3619 /* Some error. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3620 if (!patterns[i].error_signaled)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3621 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3622 error ("error while matching pattern %d", i);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3623 patterns[i].error_signaled = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3624 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3625 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3626 case -1:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3627 /* No match. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3628 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3629 default:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3630 /* Match occurred. Construct a tag. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3631 if (patterns[i].name_pattern[0] != '\0')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3632 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3633 /* Make a named tag. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3634 char *name = substitute (linebuffer->buffer,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3635 patterns[i].name_pattern,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3636 &patterns[i].regs);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3637 if (name != NULL)
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3638 pfnote (name, TRUE,
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3639 linebuffer->buffer, match, lineno, linecharno);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3640 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3641 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3642 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3643 /* Make an unnamed tag. */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3644 pfnote (NULL, TRUE,
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3645 linebuffer->buffer, match, lineno, linecharno);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3646 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3647 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3648 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3649 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3650 #endif /* ETAGS_REGEXPS */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3651
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3652 return result;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3653 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3654
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3655 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3656 * Read a file, but do no processing. This is used to do regexp
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3657 * matching on files that have no language defined.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3658 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3659 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3660 just_read_file (inf)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3661 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3662 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3663 while (!feof (inf))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3664 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3665 ++lineno;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3666 linecharno = charno;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3667 charno += readline (&lb, inf) + 1;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3668 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3669 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3670
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3671
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3672 /*
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3673 * Return a pointer to a space of size strlen(cp)+1 allocated
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3674 * with xnew where the string CP has been copied.
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3675 */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3676 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3677 savestr (cp)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3678 char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3679 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3680 return savenstr (cp, strlen (cp));
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3681 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3682
10404
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3683 /*
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3684 * Return a pointer to a space of size LEN+1 allocated with xnew where
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3685 * the string CP has been copied for at most the first LEN characters.
631f1dac6f7a Global polishing, some bugs corrected, dynamic allocation used instead
Francesco Potortì <pot@gnu.org>
parents: 10378
diff changeset
3686 */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3687 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3688 savenstr (cp, len)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3689 char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3690 int len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3691 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3692 register char *dp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3693
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3694 dp = xnew (len + 1, char);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3695 strncpy (dp, cp, len);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3696 dp[len] = '\0';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3697 return dp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3698 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3699
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3700 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3701 * Return the ptr in sp at which the character c last
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3702 * appears; NULL if not found
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3703 *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3704 * Identical to System V strrchr, included for portability.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3705 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3706 char *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3707 etags_strrchr (sp, c)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3708 register char *sp, c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3709 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3710 register char *r;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3711
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3712 r = NULL;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3713 do
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3714 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3715 if (*sp == c)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3716 r = sp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3717 } while (*sp++);
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3718 return r;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3719 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3720
774
11867ad5bab4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3721
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3722 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3723 * Return the ptr in sp at which the character c first
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3724 * appears; NULL if not found
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3725 *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3726 * Identical to System V strchr, included for portability.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3727 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3728 char *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3729 etags_strchr (sp, c)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3730 register char *sp, c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3731 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3732 do
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3733 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3734 if (*sp == c)
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3735 return sp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3736 } while (*sp++);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3737 return NULL;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3738 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3739
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3740 /* Print error message and exit. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3741 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3742 fatal (s1, s2)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3743 char *s1, *s2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3744 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3745 error (s1, s2);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3746 exit (BAD);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3747 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3748
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3749 void
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3750 pfatal (s1)
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3751 char *s1;
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3752 {
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3753 perror (s1);
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3754 exit (BAD);
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3755 }
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3756
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3757 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3758 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3759 error (s1, s2)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3760 char *s1, *s2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3761 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3762 fprintf (stderr, "%s: ", progname);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3763 fprintf (stderr, s1, s2);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3764 fprintf (stderr, "\n");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3765 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3766
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3767 /* Return a newly-allocated string whose contents
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3768 concatenate those of s1, s2, s3. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3769 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3770 concat (s1, s2, s3)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3771 char *s1, *s2, *s3;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3772 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3773 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3774 char *result = xnew (len1 + len2 + len3 + 1, char);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3775
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3776 strcpy (result, s1);
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3777 strcpy (result + len1, s2);
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3778 strcpy (result + len1 + len2, s3);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3779 result[len1 + len2 + len3] = '\0';
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3780
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3781 return result;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3782 }
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3783
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3784 /* Does the same work as the system V getcwd, but does not need to
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
3785 guess the buffer size in advance. */
7227
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3786 char *
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3787 etags_getcwd ()
11992
e550e0d13e83 * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11990
diff changeset
3788 {
11990
1e5d25c997ca * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11957
diff changeset
3789 #ifdef DOS_NT
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3790 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3791
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3792 getwd (path);
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3793 p = path;
7227
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3794 while (*p)
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3795 if (*p == '\\')
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3796 *p++ = '/';
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3797 else
13380
12bfc1ecec61 * etags.c (lowcase): Use the standard tolower function.
Francesco Potortì <pot@gnu.org>
parents: 12879
diff changeset
3798 *p++ = lowcase (*p);
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3799
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3800 return strdup (path);
11992
e550e0d13e83 * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11990
diff changeset
3801 #else /* not DOS_NT */
e550e0d13e83 * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11990
diff changeset
3802 #if HAVE_GETCWD
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3803 int bufsize = 200;
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3804 char *path = xnew (bufsize, char);
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3805
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3806 while (getcwd (path, bufsize) == NULL)
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3807 {
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3808 if (errno != ERANGE)
11886
c5db1295f7df * etags.c (etags_getcwd): Use /bin/pwd instead of pwd because the
Francesco Potortì <pot@gnu.org>
parents: 11673
diff changeset
3809 pfatal ("getcwd");
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3810 bufsize *= 2;
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3811 path = xnew (bufsize, char);
8789
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3812 }
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3813
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3814 return path;
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3815 #else /* not DOS_NT and not HAVE_GETCWD */
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3816 struct linebuffer path;
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3817 FILE *pipe;
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3818
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3819 initbuffer (&path);
11990
1e5d25c997ca * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11957
diff changeset
3820 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3821 if (pipe == NULL || readline_internal (&path, pipe) == 0)
11990
1e5d25c997ca * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11957
diff changeset
3822 pfatal ("pwd");
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3823 pclose (pipe);
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3824
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3825 return path.buffer;
11992
e550e0d13e83 * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11990
diff changeset
3826 #endif /* not HAVE_GETCWD */
e550e0d13e83 * etags.c (etags_getcwd): Undo the /bin/pwd change. It may raise
Francesco Potortì <pot@gnu.org>
parents: 11990
diff changeset
3827 #endif /* not DOS_NT */
10378
fb23ac6e6199 * etags.c (pfatal): New function.
Francesco Potortì <pot@gnu.org>
parents: 10376
diff changeset
3828 }
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3829
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3830 /* Return a newly allocated string containing the filename
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3831 of FILE relative to the absolute directory DIR (which
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3832 should end with a slash). */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3833 char *
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3834 relative_filename (file, dir)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3835 char *file, *dir;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3836 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3837 char *fp, *dp, *abs, *res;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3838
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3839 /* Find the common root of file and dir. */
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3840 abs = absolute_filename (file, cwd);
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3841 fp = abs;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3842 dp = dir;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3843 while (*fp++ == *dp++)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3844 continue;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3845 do
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3846 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3847 fp--;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3848 dp--;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3849 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3850 while (*fp != '/');
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3851
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3852 /* Build a sequence of "../" strings for the resulting relative filename. */
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3853 for (dp = etags_strchr (dp + 1, '/'), res = "";
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3854 dp != NULL;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3855 dp = etags_strchr (dp + 1, '/'))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3856 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3857 res = concat (res, "../", "");
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3858 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3859
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3860 /* Add the filename relative to the common root of file and dir. */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3861 res = concat (res, fp + 1, "");
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3862 free (abs);
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3863
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3864 return res;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3865 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3866
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3867 /* Return a newly allocated string containing the
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3868 absolute filename of FILE given CWD (which should
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3869 end with a slash). */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3870 char *
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3871 absolute_filename (file, cwd)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3872 char *file, *cwd;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3873 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3874 char *slashp, *cp, *res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3875
12344
7e7941d8cceb * etags.c (find_entries): rewind before rereading the input file.
Francesco Potortì <pot@gnu.org>
parents: 12242
diff changeset
3876 if (absolutefn (file))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3877 res = concat (file, "", "");
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3878 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3879 res = concat (cwd, file, "");
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3880
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3881 /* Delete the "/dirname/.." and "/." substrings. */
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3882 slashp = etags_strchr (res, '/');
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3883 while (slashp != NULL && slashp[0] != '\0')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3884 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3885 if (slashp[1] == '.')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3886 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3887 if (slashp[2] == '.'
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3888 && (slashp[3] == '/' || slashp[3] == '\0'))
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3889 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3890 cp = slashp;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3891 do
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3892 cp--;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3893 while (cp >= res && *cp != '/');
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3894 if (*cp == '/')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3895 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3896 strcpy (cp, slashp + 3);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3897 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3898 else /* else (cp == res) */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3899 {
6944
daa29eabfc65 * etags.c (absolute_filename): compare against '\0' instead of NULL.
Francesco Potortì <pot@gnu.org>
parents: 6831
diff changeset
3900 if (slashp[3] != '\0')
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3901 strcpy (cp, slashp + 4);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3902 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3903 return ".";
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3904 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3905 slashp = cp;
7776
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3906 continue;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3907 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3908 else if (slashp[2] == '/' || slashp[2] == '\0')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3909 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3910 strcpy (slashp, slashp + 2);
7776
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3911 continue;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3912 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3913 }
7776
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3914
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3915 slashp = etags_strchr (slashp + 1, '/');
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3916 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3917
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3918 return res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3919 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3920
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3921 /* Return a newly allocated string containing the absolute
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3922 filename of dir where FILE resides given CWD (which should
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3923 end with a slash). */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3924 char *
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3925 absolute_dirname (file, cwd)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3926 char *file, *cwd;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3927 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3928 char *slashp, *res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3929 char save;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3930
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3931 slashp = etags_strrchr (file, '/');
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3932 if (slashp == NULL)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3933 return cwd;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3934 save = slashp[1];
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3935 slashp[1] = '\0';
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3936 res = absolute_filename (file, cwd);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3937 slashp[1] = save;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3938
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3939 return res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3940 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3941
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3942 /* Like malloc but get fatal error if memory is exhausted. */
11673
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
3943 long *
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3944 xmalloc (size)
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
3945 unsigned int size;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3946 {
11673
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
3947 long *result = (long *) malloc (size);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3948 if (result == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3949 fatal ("virtual memory exhausted", 0);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3950 return result;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3951 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3952
11673
46d2178719ad (C_entries): Cast result of xrealloc.
Richard M. Stallman <rms@gnu.org>
parents: 11231
diff changeset
3953 long *
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3954 xrealloc (ptr, size)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3955 char *ptr;
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
3956 unsigned int size;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3957 {
12879
3b90cbba7dad * etags.c (Pascal_functions): Close comment bug corrected.
Francesco Potortì <pot@gnu.org>
parents: 12398
diff changeset
3958 long *result = (long *) realloc (ptr, size);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3959 if (result == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3960 fatal ("virtual memory exhausted");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3961 return result;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3962 }