annotate lib-src/etags.c @ 10029:fdc1155b891c

(sort_args): New function. (main): Call sort_args. Check for -d/-display after -nw, -batch, -help. Accept --display, with arg attached or separate.
author Richard M. Stallman <rms@gnu.org>
date Sat, 19 Nov 1994 20:45:17 +0000
parents 2869e501c2de
children 9b284d98b102
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
7307
cd81dba38a49 Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 7232
diff changeset
2 Copyright (C) 1984,87,88,89,93,94 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
3 This file is not considered part of GNU Emacs.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
4
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
5 This program is free software; you can redistribute it and/or modify
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
6 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
7 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
8 (at your option) any later version.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
9
2932
b68f975d505a Change permission notice (not "part of Emacs").
Richard M. Stallman <rms@gnu.org>
parents: 2911
diff changeset
10 This program is distributed in the hope that it will be useful,
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
13 GNU General Public License for more details.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
14
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
15 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
16 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
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
18
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
19 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
20 * Authors:
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
21 * Ctags originally by Ken Arnold.
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
22 * Fortran added by Jim Kleckner.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
23 * Ed Pelegri-Llopart added C typedefs.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
24 * Gnu Emacs TAGS format and modifications by RMS?
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
25 * 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
26 * 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
27 #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
28 * 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
29 #endif
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
30 *
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
31 * Francesco Potorti` (pot@cnuce.cnr.it) is the current maintainer.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
32 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
33
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
34 char pot_etags_version[] = "@(#) pot revision number is 11.8";
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
35
5448
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
36 #ifdef MSDOS
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
37 #include <fcntl.h>
7227
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
38 #include <sys/param.h>
5448
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
39 #endif /* MSDOS */
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
40
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
41 #ifdef WINDOWSNT
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
42 #include <stdlib.h>
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
43 #include <fcntl.h>
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
44 #include <string.h>
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
45 #define MAXPATHLEN _MAX_PATH
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
46 #endif
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
47
4052
9535e8ffb209 * etags.c (alloca): removed all references to it.
Jim Blandy <jimb@redhat.com>
parents: 4051
diff changeset
48 #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
49 #include <config.h>
6831
dbfdd66854c9 #undef static.
Richard M. Stallman <rms@gnu.org>
parents: 6756
diff changeset
50 /* On some systems, Emacs defines static as nothing
dbfdd66854c9 #undef static.
Richard M. Stallman <rms@gnu.org>
parents: 6756
diff changeset
51 for the sake of unexec. We don't want that here
dbfdd66854c9 #undef static.
Richard M. Stallman <rms@gnu.org>
parents: 6756
diff changeset
52 since we don't use unexec. */
dbfdd66854c9 #undef static.
Richard M. Stallman <rms@gnu.org>
parents: 6756
diff changeset
53 #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
54 #endif
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
55
3921
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
56 #include <stdio.h>
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
57 #include <ctype.h>
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
58 #include <errno.h>
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
59 #ifndef errno
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
60 extern int errno;
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
61 #endif
3921
e5e5b3634dd0 * etags.c: #include "config.h" and the alloca CPP tangle before
Jim Blandy <jimb@redhat.com>
parents: 3838
diff changeset
62 #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
63 #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
64
4804
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
65 #if !defined (S_ISREG) && defined (S_IFREG)
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
66 # 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
67 #endif
810826b6e19a * etags.c (process_file): dead code removed.
Francesco Potortì <pot@gnu.org>
parents: 4750
diff changeset
68
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
69 #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
70
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
71 #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
72 #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
73 #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
74
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
75 extern char *getenv ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
76
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
77 /* 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
78 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
79 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
80 #ifdef CTAGS
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
81 # undef CTAGS
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
82 # define CTAGS TRUE
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
83 #else
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
84 # define CTAGS FALSE
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
85 #endif
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
86
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
87 /* Exit codes for success and failure. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
88 #ifdef VMS
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
89 #define GOOD 1
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
90 #define BAD 0
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
91 #else
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
92 #define GOOD 0
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
93 #define BAD 1
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
94 #endif
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
95
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
96 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
97 * The FILEPOS abstract type, which represents a position in a file,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
98 * plus the following accessor functions:
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
99 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
100 * long GET_CHARNO (pos)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
101 * returns absolute char number.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
102 * void SET_FILEPOS (pos, fp, charno)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
103 * FILE *fp; long charno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
104 * sets `pos' from the current file
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
105 * position of `fp' and from `charno',
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
106 * which must be the absolute character
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
107 * number corresponding to the current
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
108 * position of `fp'.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
109 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
110 * The `pos' parameter is an lvalue expression of type FILEPOS.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
111 * Parameters to the accessor functions are evaluated 0 or more times,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
112 * and so must have no side effects.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
113 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
114 * FILEPOS objects can also be assigned and passed to and from
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
115 * functions in the normal C manner.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
116 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
117 * Implementation notes: the `+ 0' is to enforce rvalue-ness.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
118 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
119
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
120 #ifndef DEBUG
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
121 #define DEBUG FALSE
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
122
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
123 /* real implementation */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
124 typedef long FILEPOS;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
125 #define GET_CHARNO(pos) ((pos) + 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
126 #define SET_FILEPOS(pos, fp, cno) ((void) ((pos) = (cno)))
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
127
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
128 #else
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
129 #undef DEBUG
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
130 #define DEBUG TRUE
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
131
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
132 /* debugging implementation */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
133 typedef struct
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
134 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
135 long charno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
136 } FILEPOS;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
137
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
138 #define GET_CHARNO(pos) ((pos).charno + 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
139 #define SET_FILEPOS(pos, fp, cno) \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
140 ((void) ((pos).charno = (cno), \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
141 (cno) != ftell (fp) ? (error ("SET_FILEPOS inconsistency"), 0) \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
142 : 0))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
143 #endif
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
144
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
145 #define streq(s, t) (strcmp (s, t) == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
146 #define strneq(s, t, n) (strncmp (s, t, n) == 0)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
147 #define logical int
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
148
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
149 #define TRUE 1
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
150 #define FALSE 0
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
151
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
152 #define iswhite(arg) (_wht[arg]) /* T if char is white */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
153 #define begtoken(arg) (_btk[arg]) /* T if char can start token */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
154 #define intoken(arg) (_itk[arg]) /* T if char can be in token */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
155 #define endtoken(arg) (_etk[arg]) /* T if char ends tokens */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
156
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
157 #define max(I1,I2) ((I1) > (I2) ? (I1) : (I2))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
158
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
159 struct nd_st
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
160 { /* sorting structure */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
161 char *name; /* function or type name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
162 char *file; /* file name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
163 logical is_func; /* use pattern or line no */
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
164 logical named; /* list name separately */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
165 logical been_warned; /* set if noticed dup */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
166 int lno; /* line number tag is on */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
167 long cno; /* character number line starts on */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
168 char *pat; /* search pattern */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
169 struct nd_st *left, *right; /* left and right sons */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
170 };
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
171
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
172 typedef struct nd_st NODE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
173
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
174 /* boolean "functions" (see init) */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
175 logical _wht[0177], _etk[0177], _itk[0177], _btk[0177];
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
176
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
177 char *cwd; /* current working directory */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
178 char *tagfiledir; /* directory of tagfile */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
179
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
180 char *concat ();
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
181 char *savenstr (), *savestr ();
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
182 char *etags_strchr (), *etags_strrchr ();
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
183 char *etags_getcwd ();
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
184 char *relative_filename (), *absolute_filename (), *absolute_dirname ();
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
185 char *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
186
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
187 typedef void Lang_function ();
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 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
196 Lang_function Pascal_functions;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
197 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
198 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
199 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
200 Lang_function just_read_file;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
201
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
202 logical get_language ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
203 int total_size_of_entries ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
204 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
205 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
206 #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
207 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
208 #endif
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
209 void add_node ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
210 void error ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
211 void fatal ();
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
212 logical find_entries ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
213 void free_tree ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
214 void getit ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
215 void init ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
216 void initbuffer ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
217 void pfnote ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
218 void process_file ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
219 void put_entries ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
220 void takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
221
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
222 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
223 * MACRO
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
224 * xnew -- allocate storage
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
225 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
226 * SYNOPSIS
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
227 * Type *xnew (int n, Type);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
228 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
229 #define xnew(n, Type) ((Type *) xmalloc ((n) * sizeof (Type)))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
230
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
231 /*
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
232 * Symbol table types.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
233 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
234 enum sym_type
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
235 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
236 st_none, st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
237 };
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
238
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
239
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
241 typedef int LINENO;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
242
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
243 typedef struct
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
244 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
245 char *p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
246 int len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
247 LINENO lineno;
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
248 logical named;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
249 } TOKEN;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
250
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
251 /* C extensions.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
252 */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
253 #define C_PLPL 0x00001 /* C++ */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
254 #define C_STAR 0x00003 /* C* */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
255 #define YACC 0x10000 /* yacc file */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
256
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
257 char searchar = '/'; /* use /.../ searches */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
258
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
259 LINENO lineno; /* line number of current line */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
260 long charno; /* current character number */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
261
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
262 long linecharno; /* charno of start of line; not used by C, but
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
263 * by every other language.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
264 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
265
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
266 char *curfile, /* current input file name */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
267 *tagfile, /* output file */
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
268 *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
269 *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
270 /* 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
271 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~",
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
272 /* valid in-token chars */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
273 *intk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
274
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
275 int append_to_tagfile; /* -a: append to tags */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
276 /* The following three default to 1 for etags, but to 0 for ctags. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
277 int typedefs; /* -t: create tags for typedefs */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
278 int typedefs_and_cplusplus; /* -T: create tags for typedefs, level */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
279 /* 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
280 /* member functions. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
281 int 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
282 /* constants. Enum consts not implemented. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
283 /* -D: opposite of -d. Default under ctags. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
284 int update; /* -u: update tags */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
285 int vgrind_style; /* -v: create vgrind style index output */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
286 int no_warnings; /* -w: suppress warnings */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
287 int cxref_style; /* -x: create cxref style output */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
288 int cplusplus; /* .[hc] means C++, not C */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
289 int noindentypedefs; /* -S: ignore indentation in C */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
290
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
291 /* Name this program was invoked with. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
292 char *progname;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
293
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
294 struct option longopts[] = {
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
295 { "append", no_argument, NULL, 'a' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
296 { "backward-search", no_argument, NULL, 'B' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
297 { "c++", no_argument, NULL, 'C' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
298 { "cxref", no_argument, NULL, 'x' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
299 { "defines", no_argument, NULL, 'd' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
300 { "help", no_argument, NULL, 'H' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
301 { "ignore-indentation", no_argument, NULL, 'S' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
302 { "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
303 { "language", required_argument, NULL, 'l' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
304 { "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
305 { "no-regex", no_argument, NULL, 'R' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
306 { "no-warn", no_argument, NULL, 'w' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
307 { "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
308 { "regex", required_argument, NULL, 'r' },
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
309 { "typedefs", no_argument, NULL, 't' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
310 { "typedefs-and-c++", no_argument, NULL, 'T' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
311 { "update", no_argument, NULL, 'u' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
312 { "version", no_argument, NULL, 'V' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
313 { "vgrind", no_argument, NULL, 'v' },
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
314 { 0 }
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
315 };
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
316
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
317 FILE *tagf; /* ioptr for tags file */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
318 NODE *head; /* the head of the binary tree of tags */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
319 logical permit_duplicates = TRUE; /* allow duplicate tags */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
320
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
321 /* A `struct linebuffer' is a structure which holds a line of text.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
322 `readline' reads a line from a stream into a linebuffer
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
323 and works regardless of the length of the line. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
324
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
325 struct linebuffer
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
326 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
327 long size;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
328 char *buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
329 };
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
330
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
331 struct linebuffer lb; /* the current line */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
332 struct linebuffer filename_lb; /* used to read in filenames */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
333 struct
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
334 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
335 FILEPOS linepos;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
336 struct linebuffer lb; /* used by C_entries instead of lb */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
337 } lbs[2];
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
338
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
339 #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
340 /* Structure defining a regular expression. Elements are
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
341 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
342 struct pattern
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
343 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
344 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
345 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
346 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
347 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
348 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
349
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
350 /* 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
351 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
352
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
353 /* 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
354 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
355 #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
356
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
357 /* Language stuff. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
358 struct lang_entry
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
359 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
360 char *extension;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
361 Lang_function *function;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
362 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
363
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
364 /* Table of language names and corresponding functions. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
365 /* It is ok for a given function to be listed under more than one
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
366 name. I just didn't. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
367 /* "auto" language reverts to default behavior. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
368 struct lang_entry lang_names[] =
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
369 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
370 { "asm", Asm_labels },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
371 { "c", 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
372 { "c++", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
373 { "c*", Cstar_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
374 { "fortran", Fortran_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
375 { "lisp", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
376 { "none", just_read_file },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
377 { "pascal", Pascal_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
378 { "scheme" , Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
379 { "tex", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
380 { "auto", NULL },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
381 { NULL, NULL }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
382 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
383
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
384 /* Table of file extensions and corresponding language functions. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
385 struct lang_entry lang_extensions[] =
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
386 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
387 /* Assume that ".s" or ".a" is assembly code. -wolfgang.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
388 Or even ".sa". */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
389 { "a", Asm_labels }, /* Unix assembler */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
390 { "asm", Asm_labels }, /* Microcontroller assembly */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
391 { "def", Asm_labels }, /* BSO/Tasking definition includes */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
392 { "inc", Asm_labels }, /* Microcontroller include files */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
393 { "ins", Asm_labels }, /* Microcontroller include files */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
394 { "s", Asm_labels },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
395 { "sa", Asm_labels }, /* Unix assembler */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
396 { "src", Asm_labels }, /* BSO/Tasking C compiler output */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
397
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
398 /* .aux, .bbl, .clo, .cls, .dtx or .tex implies LaTeX source code. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
399 { "aux", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
400 { "bbl", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
401 { "clo", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
402 { "cls", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
403 { "dtx", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
404 { "sty", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
405 { "tex", TeX_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
406
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
407 /* .l or .el or .lisp (or .cl or .clisp or ...) implies lisp source code */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
408 { "cl", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
409 { "clisp", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
410 { "el", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
411 { "l", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
412 { "lisp", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
413 { "lsp", Lisp_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
414
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
415 /* .scm or .sm or .scheme implies scheme source code */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
416 { "SCM", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
417 { "SM", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
418 { "oak", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
419 { "sch", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
420 { "scheme", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
421 { "scm", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
422 { "sm", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
423 { "t", Scheme_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
424 /* FIXME Can't do the `SCM' or `scm' prefix with a version number */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
425
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
426 /* Note that ".c" and ".h" can be considered C++, if the --c++
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
427 flag was given. That is why default_C_entries is called here. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
428 { "c", 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
429 { "h", 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
430
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
431 /* .C or .H or .cpp or .cxx or .hxx or .hh or .cc or .cpp: a C++ file */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
432 { "C", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
433 { "H", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
434 { "cc", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
435 { "cpp", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
436 { "cxx", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
437 { "hh", Cplusplus_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
438 { "hxx", Cplusplus_entries },
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 /* .y: a yacc file */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
441 { "y", Yacc_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
442
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
443 /* .cs or .hs: a C* file */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
444 { "cs", Cstar_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
445 { "hs", Cstar_entries },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
446
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
447 /* .f and .for are FORTRAN. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
448 { "F", Fortran_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
449 { "f", Fortran_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
450 { "for", Fortran_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
451
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
452 /* .pl implies prolog source code */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
453 { "pl", Prolog_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
454
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
455 /* .p or .pas: a Pascal file */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
456 { "p", Pascal_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
457 { "pas", Pascal_functions },
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
458
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
459 { NULL, NULL }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
460 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
461
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
462 /* 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
463 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
464
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
465
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
466 void
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
467 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
468 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
469 struct lang_entry *name, *ext;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
470
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
471 puts ("\nThese are the currently supported languages, along with the\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
472 default extensions for files:");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
473 for (name = lang_names; name->extension; ++name)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
474 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
475 printf ("\t%s\t", name->extension);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
476 for (ext = lang_extensions; ext->extension; ++ext)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
477 if (name->function == ext->function)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
478 printf (" .%s", ext->extension);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
479 puts ("");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
480 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
481 puts ("Where `auto' means use default language for files based on filename\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
482 extension, and `none' means only do regexp processing on files.\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
483 If no language is specified and no extension is found for some file,\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
484 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
485 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
486
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
487 void
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
488 print_version ()
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
489 {
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
490 #ifdef VERSION
7049
47965b6c2195 (print_version): Print VERSION as a string.
Richard M. Stallman <rms@gnu.org>
parents: 6945
diff changeset
491 printf ("%s for Emacs version %s.\n", (CTAGS) ? "CTAGS" : "ETAGS", VERSION);
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
492 #else
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
493 printf ("%s for Emacs version 19.\n", (CTAGS) ? "CTAGS" : "ETAGS");
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
494 #endif
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
495
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
496 exit (GOOD);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
497 }
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
498
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
499 void
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
500 print_help ()
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
501 {
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
502 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
503 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
504 names from stdin.\n\n", progname);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
505
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
506 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
507 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
508
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
509 if (CTAGS)
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
510 puts ("-B, --backward-search\n\
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
511 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
512 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
513
4126
9a906e5f9b28 * etags.c (print_help): Break up the very long strings containing
Jim Blandy <jimb@redhat.com>
parents: 4052
diff changeset
514 puts ("-C, --c++\n\
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
515 Treat files whose extension defaults to C language as C++ files.");
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
516
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
517 if (CTAGS)
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
518 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
519 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
520 else
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
521 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
522 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
523 the tags file smaller.");
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
524
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
525 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
526 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
527 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
528 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
529 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
530 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
531 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
532 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
533 named language up to the next --language=LANG option.");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
534 #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
535 puts ("-r /REGEXP/, --regex=/REGEXP/\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
536 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
537 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
538 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
539 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
540 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
541 puts ("-R, --no-regex\n\
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
542 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
543 #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
544 }
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
545
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
546 puts ("-o FILE, --output=FILE\n\
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
547 Write the tags to FILE.");
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
548 puts ("-S, --ignore-indentation\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
549 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
550 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
551 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
552 definition in C and C++.");
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
553
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
554 if (CTAGS)
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
555 {
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
556 puts ("-t, --typedefs\n\
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
557 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
558 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
559 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
560 and C++ member functions.");
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
561 puts ("-u, --update\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
562 Update the tag entries for the given files, leaving tag\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
563 entries for other files in place. Currently, this is\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
564 implemented by deleting the existing entries for the given\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
565 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
566 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
567 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
568 puts ("-v, --vgrind\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
569 Generates an index of items intended for human consumption,\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
570 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
571 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
572 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
573 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
574 files.");
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
575 puts ("-x, --cxref\n\
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
576 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
577 The output uses line numbers instead of page numbers, but\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
578 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
579 which you like.");
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
580 }
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
581
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
582 puts ("-V, --version\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
583 Print the version of the program.\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
584 -H, --help\n\
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
585 Print this help message.");
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
586
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
587 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
588
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
589 exit (GOOD);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
590 }
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
591
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
592
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
593 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
594 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
595 at_language,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
596 at_regexp,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
597 at_filename
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
598 };
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
599
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
600 /* 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
601 typedef struct
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
602 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
603 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
604 char *what;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
605 Lang_function *function;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
606 } ARGUMENT;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
607
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
608 #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
609
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
610 #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
611
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
612 /* 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
613 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
614 #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
615 typedef struct {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
616 short curlen;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
617 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
618 } vspec;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
619
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
620 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
621 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
622 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
623 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
624 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
625 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
626 is returned, the function ignores the value of in_spec, and will
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
627 only start processing a new spec with the following call.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
628 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
629 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
630
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
631 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
632 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
633 names the function returns zero. If on the first call no file
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
634 matches in_spec, or there is any other error, -1 is returned.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
635 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
636
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
637 #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
638 #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
639 #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
640 short
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
641 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
642 vspec *out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
643 char *in;
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 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
646 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
647 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
648 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
649 long status;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
650 short retval;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
651
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
652 if (pass1)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
653 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
654 pass1 = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
655 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
656 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
657 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
658 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
659 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
660 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
661 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
662 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
663 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
664 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
665 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
666 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
667 return 1;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
668 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
669 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
670 retval = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
671 else
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 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
674 retval = -1;
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 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
677 pass1 = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
678 return retval;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
679 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
680
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
681 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
682 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
683 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
684 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
685 char *
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
686 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
687 char *arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
688 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
689 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
690 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
691
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
692 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
693 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
694 case 1:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
695 *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
696 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
697 case 0:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
698 *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
699 return NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
700 default:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
701 *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
702 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
703 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
704 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
705
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
706 #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
707 system (cmd)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
708 char *cmd;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
709 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
710 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
711 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
712 #endif
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
713
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
714 #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
715 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
716 char *s;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
717 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
718 char *start = s;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
719
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
720 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
721 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
722 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
723 *s = EOS;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
724 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
725 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
726 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
727 *s = tolower(*s);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
728 return start;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
729 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
730 #endif /* VMS */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
731
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
732
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
733 void
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
734 main (argc, argv)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
735 int argc;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
736 char *argv[];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
737 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
738 char cmd[100];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
739 int i;
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
740 unsigned int nincluded_files = 0;
4052
9535e8ffb209 * etags.c (alloca): removed all references to it.
Jim Blandy <jimb@redhat.com>
parents: 4051
diff changeset
741 char **included_files = xnew (argc, char *);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
742 char *this_file;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
743 ARGUMENT *argbuffer;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
744 int current_arg = 0, file_count = 0;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
745 #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
746 logical got_err;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
747 #endif
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
748
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
749 #ifdef DOS_NT
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
750 _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
751 #endif /* DOS_NT */
5448
18de002e47dd (main) [MSDOS]: Open all files as binary.
Richard M. Stallman <rms@gnu.org>
parents: 5044
diff changeset
752
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
753 progname = argv[0];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
754
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
755 /* 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
756 is small. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
757 argbuffer = xnew (argc, ARGUMENT);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
758
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
759 #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
760 /* 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
761 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
762 #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
763
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
764 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
765 * If etags, always find typedefs and structure tags. Why not?
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
766 * Also default is to find macro constants.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
767 */
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
768 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
769 typedefs = typedefs_and_cplusplus = constantypedefs = 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
770
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
771 while (1)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
772 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
773 int opt = getopt_long (argc, argv,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
774 "-aCdDf:l:o:r:RStTi:BuvxwVH", longopts, 0);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
775
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
776 if (opt == EOF)
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
777 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
778
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
779 switch (opt)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
780 {
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
781 case 0:
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
782 /* If getopt returns 0, then it has already processed a
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
783 long-named option. We should do nothing. */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
784 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
785
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
786 case 1:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
787 /* 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
788 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
789 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
790 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
791 ++file_count;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
792 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
793
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
794 /* Common options. */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
795 case 'a':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
796 append_to_tagfile++;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
797 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
798 case 'C':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
799 cplusplus = 1;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
800 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
801 case 'd':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
802 constantypedefs = 1;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
803 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
804 case 'D':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
805 constantypedefs = 0;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
806 break;
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
807 case 'f': /* for compatibility with old makefiles */
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
808 case 'o':
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
809 if (tagfile)
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
810 {
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
811 fprintf(stderr,
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
812 "%s: -%c flag may only be given once.\n", progname, opt);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
813 goto usage;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
814 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
815 tagfile = optarg;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
816 break;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
817 case 'l':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
818 if (!get_language (optarg, &argbuffer[current_arg].function))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
819 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
820 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
821 progname, optarg);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
822 goto usage;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
823 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
824 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
825 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
826 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
827 #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
828 case 'r':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
829 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
830 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
831 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
832 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
833 case 'R':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
834 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
835 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
836 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
837 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
838 #endif /* ETAGS_REGEXPS */
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
839 case 'S':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
840 noindentypedefs++;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
841 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
842 case 'V':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
843 print_version ();
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
844 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
845 case 'H':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
846 print_help ();
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
847 break;
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
848 case 't':
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
849 typedefs++;
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
850 break;
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
851 case 'T':
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
852 typedefs++;
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
853 typedefs_and_cplusplus++;
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
854 break;
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
855
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
856 #if (!CTAGS)
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
857
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
858 /* Etags options */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
859 case 'i':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
860 included_files[nincluded_files++] = optarg;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
861 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
862
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
863 #else /* CTAGS */
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
864
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
865 /* Ctags options. */
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
866 case 'B':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
867 searchar = '?';
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
868 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
869 case 'u':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
870 update++;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
871 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
872 case 'v':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
873 vgrind_style++;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
874 /*FALLTHRU*/
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
875 case 'x':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
876 cxref_style++;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
877 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
878 case 'w':
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
879 no_warnings++;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
880 break;
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
881
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
882 #endif /* CTAGS */
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
883
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
884 default:
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
885 fprintf (stderr,
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
886 "%s: -%c flag not recognised.\n", progname, opt);
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
887 goto usage;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
888 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
889 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
890
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
891 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
892 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
893 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
894 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
895 ++current_arg;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
896 ++file_count;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
897 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
898
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
899 if (nincluded_files == 0 && file_count == 0)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
900 {
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
901 fprintf (stderr, "%s: No input files specified.\n", progname);
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
902
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
903 usage:
2759
1c7b7ed1a12a (main): Don't require that there be input files if -i switches were given.
Roland McGrath <roland@gnu.org>
parents: 2323
diff changeset
904 fprintf (stderr, "%s: Try `%s --help' for a complete list of options.\n",
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
905 progname, progname);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
906 exit (BAD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
907 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
908
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
909 if (tagfile == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
910 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
911 tagfile = CTAGS ? "tags" : "TAGS";
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
912 }
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
913 cwd = etags_getcwd (); /* the current working directory */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
914 strcat (cwd, "/");
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
915 if (streq (tagfile, "-"))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
916 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
917 tagfiledir = cwd;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
918 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
919 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
920 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
921 tagfiledir = absolute_dirname (tagfile, cwd);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
922 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
923
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
924 init (); /* set up boolean "functions" */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
925
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
926 initbuffer (&lb);
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
927 initbuffer (&lbs[0].lb);
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
928 initbuffer (&lbs[1].lb);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
929 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
930
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
931 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
932 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
933 if (streq (tagfile, "-"))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
934 tagf = stdout;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
935 else
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
936 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
937 if (tagf == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
938 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
939 perror (tagfile);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
940 exit (BAD);
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 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
943
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
944 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
945 * 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
946 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
947 for (i = 0; i < current_arg; ++i)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
948 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
949 switch (argbuffer[i].arg_type)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
950 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
951 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
952 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
953 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
954 #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
955 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
956 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
957 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
958 #endif
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
959 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
960 #ifdef VMS
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
961 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
962 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
963 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
964 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
965 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
966 argc--, argv++;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
967 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
968 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
969 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
970 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
971 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
972 #else
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
973 this_file = argbuffer[i].what;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
974 #endif
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
975 /* 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
976 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
977 if (streq (this_file, "-"))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
978 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
979 while (!feof (stdin))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
980 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
981 /* Use readline_internal so that regexp matching */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
982 /* is not done on filenames. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
983 (void) readline_internal (&filename_lb, stdin);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
984 if (strlen (filename_lb.buffer) > 0)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
985 process_file (filename_lb.buffer);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
986 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
987 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
988 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
989 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
990 #ifdef VMS
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
991 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
992 #endif
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
993 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
994 }
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
995 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
996
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
997 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
998 {
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
999 while (nincluded_files-- > 0)
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1000 fprintf (tagf, "\f\n%s,include\n", *included_files++);
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
1001
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1002 (void) fclose (tagf);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1003 exit (GOOD);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1004 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1005
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1006 if (cxref_style)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1007 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1008 put_entries (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1009 exit (GOOD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1010 }
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
1011 if (update)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1012 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1013 for (i = 0; i < current_arg; ++i)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1014 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1015 if (argbuffer[i].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
1016 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1017 sprintf (cmd,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1018 "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
1019 tagfile, argbuffer[i].what, tagfile);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1020 (void) system (cmd);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1021 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1022 append_to_tagfile++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1023 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1024 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
1025 if (tagf == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1026 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1027 perror (tagfile);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1028 exit (GOOD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1029 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1030 put_entries (head);
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1031 (void) fclose (tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1032 if (update)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1033 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1034 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1035 (void) system (cmd);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1036 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1037 exit (GOOD);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1038 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1039
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1040
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1041 /*
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1042 * Set the language, given the name.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1043 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1044 logical
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1045 get_language (language, func)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1046 char *language;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1047 Lang_function **func;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1048 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1049 struct lang_entry *lang;
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 for (lang = lang_names; lang->extension; ++lang)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1052 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1053 if (streq (language, lang->extension))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1054 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1055 *func = lang->function;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1056 return TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1057 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1058 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1059
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1060 return FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1061 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1062
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1063
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1064 /*
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1065 * This routine is called on each file argument.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1066 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1067 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1068 process_file (file)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1069 char *file;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1070 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1071 struct stat stat_buf;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1072
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1073 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1074 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1075 fprintf (stderr, "Skipping %s: it is not a regular file.\n", file);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1076 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1077 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1078 if (streq (file, tagfile) && !streq (tagfile, "-"))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1079 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1080 fprintf (stderr, "Skipping inclusion of %s in self.\n", file);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1081 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1082 }
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1083 if (!find_entries (file))
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1084 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1085 return;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1086 }
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1087 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1088 {
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1089 char *filename;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1090
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1091 if (file[0] == '/')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1092 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1093 /* file is an absolute filename. Canonicalise it. */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1094 filename = absolute_filename (file, cwd);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1095 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1096 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1097 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1098 /* 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
1099 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
1100 filename = relative_filename (file, tagfiledir);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1101 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1102 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1103 put_entries (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1104 free_tree (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1105 head = NULL;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1106 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1107 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1108
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1109 /*
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3569
diff changeset
1110 * 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
1111 * by setting boolean flags dependent upon the corresponding character
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1112 * 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
1113 * all of the array "_wht" is set to FALSE, and then the elements
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1114 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1115 * of a char is TRUE if it is the string "white", else FALSE.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1116 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1117 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1118 init ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1119 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1120 register char *sp;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1121 register int i;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1122
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1123 for (i = 0; i < 0177; i++)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1124 _wht[i] = _etk[i] = _itk[i] = _btk[i] = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1125 for (sp = white; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1126 _wht[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1127 for (sp = endtk; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1128 _etk[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1129 for (sp = intk; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1130 _itk[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1131 for (sp = begtk; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1132 _btk[*sp] = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1133 _wht[0] = _wht['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1134 _etk[0] = _etk['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1135 _btk[0] = _btk['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1136 _itk[0] = _itk['\n'];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1137 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1138
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1139 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1140 * This routine opens the specified file and calls the function
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1141 * which finds the function and type definitions.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1142 */
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1143 logical
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1144 find_entries (file)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1145 char *file;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1146 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1147 FILE *inf;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1148 char *cp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1149 struct lang_entry *lang;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1150 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
1151 extern NODE *last_node;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1152
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1153 inf = fopen (file, "r");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1154 if (inf == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1155 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1156 perror (file);
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1157 return FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1158 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1159 curfile = savestr (file);
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
1160 cp = etags_strrchr (file, '.');
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1161
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1162 /* If user specified a language, use it. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1163 if (lang_func != NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1164 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1165 lang_func (inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1166 fclose (inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1167 return TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1168 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1169
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1170 if (cp)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1171 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1172 ++cp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1173 for (lang = lang_extensions; lang->extension; ++lang)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1174 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1175 if (streq (cp, lang->extension))
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1176 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1177 lang->function (inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1178 fclose (inf);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1179 return TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1180 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1181 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1182 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1183
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1184 /* Try Fortran. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1185 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
1186 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
1187
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1188 /* 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
1189 if (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
1190 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
1191 fclose (inf);
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1192 return TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1193 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1194
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1195 /* Record a tag. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1196 /* Should take a TOKEN* instead!! */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1197 void
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1198 pfnote (name, is_func, named, linestart, linelen, lno, cno)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1199 char *name; /* tag name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1200 logical is_func; /* function or type name? */
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1201 logical named; /* tag different from text of definition? */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1202 char *linestart;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1203 int linelen;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1204 int lno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1205 long cno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1206 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1207 register char *fp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1208 register NODE *np;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1209 char tem[51];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1210 char c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1211
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1212 np = xnew (1, NODE);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1213 if (np == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1214 {
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1215 if (CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1216 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1217 /* It's okay to output early in etags -- it only disrupts the
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1218 * character count of the tag entries, which is no longer used
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1219 * by tags.el anyway.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1220 */
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1221 error ("too many entries to sort", 0);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1222 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1223 put_entries (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1224 free_tree (head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1225 head = NULL;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1226 np = xnew (1, NODE);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1227 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1228 /* 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
1229 if (CTAGS && !cxref_style && streq (name, "main"))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1230 {
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
1231 fp = etags_strrchr (curfile, '/');
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1232 name = concat ("M", fp == 0 ? curfile : fp + 1, "");
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
1233 fp = etags_strrchr (name, '.');
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1234 if (fp && fp[1] != '\0' && fp[2] == '\0')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1235 *fp = 0;
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1236 named = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1237 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1238 np->name = savestr (name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1239 np->file = curfile;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1240 np->is_func = is_func;
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1241 np->named = named;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1242 np->lno = lno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1243 /* UNCOMMENT THE +1 HERE: */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1244 np->cno = cno /* + 1 */ ; /* our char numbers are 0-base; emacs's are 1-base */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1245 np->left = np->right = 0;
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1246 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1247 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1248 c = linestart[linelen];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1249 linestart[linelen] = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1250 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1251 else if (cxref_style == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1252 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1253 sprintf (tem, strlen (linestart) < 50 ? "%s$" : "%.50s", linestart);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1254 linestart = tem;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1255 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1256 np->pat = savestr (linestart);
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1257 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1258 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1259 linestart[linelen] = c;
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 add_node (np, &head);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1263 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1264
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1265 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1266 * free_tree ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1267 * recurse on left children, iterate on right children.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1268 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1269 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1270 free_tree (node)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1271 register NODE *node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1272 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1273 while (node)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1274 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1275 register NODE *node_right = node->right;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1276 free_tree (node->left);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1277 free (node->name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1278 free (node->pat);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1279 free ((char *) node);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1280 node = node_right;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1281 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1282 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1283
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1284 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1285 * add_node ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1286 * 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
1287 * it sorted; we just keep a linear list. In ctags mode, maintain
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1288 * an ordered tree, with no attempt at balancing.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1289 *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1290 * add_node is the only function allowed to add nodes, so it can
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1291 * maintain state.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1292 */
3838
6d8422d99000 (add_node): Move var last_node to file scope.
Richard M. Stallman <rms@gnu.org>
parents: 3662
diff changeset
1293 /* Must avoid static vars within functions since some systems
6d8422d99000 (add_node): Move var last_node to file scope.
Richard M. Stallman <rms@gnu.org>
parents: 3662
diff changeset
1294 #define static as nothing. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1295 NODE *last_node = NULL;
3838
6d8422d99000 (add_node): Move var last_node to file scope.
Richard M. Stallman <rms@gnu.org>
parents: 3662
diff changeset
1296
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1297 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1298 add_node (node, cur_node_p)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1299 NODE *node, **cur_node_p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1300 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1301 register int dif;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1302 register NODE *cur_node = *cur_node_p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1303
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1304 if (cur_node == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1305 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1306 *cur_node_p = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1307 last_node = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1308 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1309 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1310
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1311 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1312 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1313 /* Etags Mode */
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1314 if (last_node == NULL)
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1315 fatal ("internal error in add_node", 0);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1316 last_node->right = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1317 last_node = node;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1318 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1319 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1320 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1321 /* Ctags Mode */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1322 dif = strcmp (node->name, cur_node->name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1323
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1324 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1325 * If this tag name matches an existing one, then
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1326 * do not add the node, but maybe print a warning.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1327 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1328 if (!dif)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1329 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1330 if (node->file == cur_node->file)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1331 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1332 if (!no_warnings)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1333 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1334 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1335 node->file, lineno, node->name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1336 fprintf (stderr, "Second entry ignored\n");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1337 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1338 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1339 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1340 if (!cur_node->been_warned && !no_warnings)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1341 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1342 fprintf (stderr,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1343 "Duplicate entry in files %s and %s: %s (Warning only)\n",
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1344 node->file, cur_node->file, node->name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1345 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1346 cur_node->been_warned = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1347 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1348 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1349
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1350 /* Maybe refuse to add duplicate nodes. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1351 if (!permit_duplicates)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1352 {
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1353 if (streq (node->name, cur_node->name)
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1354 && streq (node->file, cur_node->file))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1355 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1356 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1357
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1358 /* Actually add the node */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1359 add_node (node, dif < 0 ? &cur_node->left : &cur_node->right);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1360 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1361 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1362
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1363 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1364 put_entries (node)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1365 register NODE *node;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1366 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1367 register char *sp;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1368
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1369 if (node == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1370 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1371
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1372 /* Output subentries that precede this one */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1373 put_entries (node->left);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1374
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1375 /* Output this entry */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1376
6530
12e47da67bb5 * etags.c (emacs_tags_format, ETAGS): removed. Use CTAGS instead.
Francesco Potortì <pot@gnu.org>
parents: 6482
diff changeset
1377 if (!CTAGS)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1378 {
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1379 if (node->named)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1380 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1381 fprintf (tagf, "%s\177%s\001%d,%d\n",
4406
ad13aac8bb60 (put_entries): For NODE->rewritten, put pattern before \177 and name after,
Roland McGrath <roland@gnu.org>
parents: 4126
diff changeset
1382 node->pat, node->name,
ad13aac8bb60 (put_entries): For NODE->rewritten, put pattern before \177 and name after,
Roland McGrath <roland@gnu.org>
parents: 4126
diff changeset
1383 node->lno, node->cno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1384 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1385 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1386 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1387 fprintf (tagf, "%s\177%d,%d\n",
4406
ad13aac8bb60 (put_entries): For NODE->rewritten, put pattern before \177 and name after,
Roland McGrath <roland@gnu.org>
parents: 4126
diff changeset
1388 node->pat,
ad13aac8bb60 (put_entries): For NODE->rewritten, put pattern before \177 and name after,
Roland McGrath <roland@gnu.org>
parents: 4126
diff changeset
1389 node->lno, node->cno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1390 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1391 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1392 else if (!cxref_style)
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 fprintf (tagf, "%s\t%s\t",
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1395 node->name, node->file);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1396
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1397 if (node->is_func)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1398 { /* a function */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1399 putc (searchar, tagf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1400 putc ('^', tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1401
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1402 for (sp = node->pat; *sp; sp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1403 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1404 if (*sp == '\\' || *sp == searchar)
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1405 putc ('\\', tagf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1406 putc (*sp, tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1407 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1408 putc (searchar, tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1409 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1410 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1411 { /* a typedef; text pattern inadequate */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1412 fprintf (tagf, "%d", node->lno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1413 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1414 putc ('\n', tagf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1415 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1416 else if (vgrind_style)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1417 fprintf (stdout, "%s %s %d\n",
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1418 node->name, node->file, (node->lno + 63) / 64);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1419 else
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 621
diff changeset
1420 fprintf (stdout, "%-16s %3d %-16s %s\n",
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1421 node->name, node->lno, node->file, node->pat);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1422
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1423 /* Output subentries that follow this one */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1424 put_entries (node->right);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1425 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1426
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1427 /* Length of a number's decimal representation. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1428 int
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1429 number_len (num)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1430 long num;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1431 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1432 int len = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1433 if (!num)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1434 return 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1435 for (; num; num /= 10)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1436 ++len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1437 return len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1438 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1439
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1440 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1441 * 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
1442 * 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
1443 * 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
1444 * 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
1445 * backward compatibility.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1446 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1447 int
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1448 total_size_of_entries (node)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1449 register NODE *node;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1450 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1451 register int total;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1452
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1453 if (node == NULL)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1454 return 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1455
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1456 total = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1457 for (; node; node = node->right)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1458 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1459 /* Count left subentries. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1460 total += total_size_of_entries (node->left);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1461
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1462 /* Count this entry */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1463 total += strlen (node->pat) + 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1464 total += number_len ((long) node->lno) + 1 + number_len (node->cno) + 1;
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1465 if (node->named)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1466 total += 1 + strlen (node->name); /* \001name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1467 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1468
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1469 return total;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1470 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1471
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1472 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1473 * The C symbol tables.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1474 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1475
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1476 /* 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
1477 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
1478 %[
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1479 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
1480 %%
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1481 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
1482 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
1483 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
1484 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
1485 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
1486 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
1487 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
1488 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
1489 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
1490 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
1491 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
1492 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
1493 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
1494 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
1495 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
1496 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
1497 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
1498 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
1499 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
1500 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
1501 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
1502 %]
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1503 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
1504 /*%<*/
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1505 /* 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
1506 /* Command-line: gperf -c -k1,3 -o -p -r -t */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1507
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1508
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1509 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
1510
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1511 #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
1512 #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
1513 #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
1514 #define MAX_HASH_VALUE 62
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1515 /*
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1516 21 keywords
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1517 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
1518 */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1519
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1520 static int
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1521 hash (str, len)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1522 register char *str;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1523 register int len;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1524 {
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1525 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
1526 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1527 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
1528 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
1529 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
1530 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
1531 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
1532 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
1533 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
1534 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
1535 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
1536 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
1537 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
1538 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
1539 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
1540 };
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1541 return len + hash_table[str[2]] + hash_table[str[0]];
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1542 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
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 struct C_stab_entry *
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1545 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
1546 register char *str;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1547 register int len;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1548 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1549
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1550 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
1551 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1552 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1553 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1554 {"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
1555 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1556 {"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
1557 {"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
1558 {"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
1559 {"",}, {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1560 {"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
1561 {"",}, {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1562 {"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
1563 {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1564 {"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
1565 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1566 {"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
1567 {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1568 {"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
1569 {"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
1570 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1571 {"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
1572 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1573 {"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
1574 {"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
1575 {"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
1576 {"",}, {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1577 {"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
1578 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1579 {"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
1580 {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1581 {"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
1582 {"",}, {"",}, {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1583 {"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
1584 {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1585 {"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
1586 {"",}, {"",},
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1587 {"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
1588 {"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
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 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
1592 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1593 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
1594
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1595 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
1596 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1597 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
1598
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
1599 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
1600 return &wordlist[key];
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1601 }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1602 }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1603 return 0;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1604 }
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1605 /*%>*/
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1606
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1607 enum sym_type
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1608 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
1609 char *str;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1610 int len;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1611 int c_ext;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1612 {
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1613 register struct C_stab_entry *se = in_word_set(str, len);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1614
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1615 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
1616 return st_none;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1617 return se->type;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1618 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1619
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1620 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1621 * 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
1622 * funcdef 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 fnone, /* nothing seen */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1627 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
1628 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
1629 finlist, /* in parameter list */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1630 flistseen, /* after parameter list */
5044
d3bd7baee39f (FUNCST, TYPEDST, STRUCTST, DEFINEST): Delete excess commas.
Richard M. Stallman <rms@gnu.org>
parents: 4937
diff changeset
1631 fignore /* before open brace */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1632 } FUNCST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1633 FUNCST funcdef;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1634
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1635
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1636 /*
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1637 * 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
1638 * typeddef is its state variable.
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 {
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1642 tnone, /* nothing seen */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1643 ttypedseen, /* typedef keyword seen */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
1644 tinbody, /* inside typedef body */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1645 tend, /* just before typedef tag */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1646 tignore /* junk after typedef tag */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1647 } TYPEDST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1648 TYPEDST typdef;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1649
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1650
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1651 /*
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1652 * 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
1653 * 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
1654 * variable.
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1655 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1656 typedef enum
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 snone, /* nothing seen yet */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1659 skeyseen, /* struct-like keyword seen */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1660 stagseen, /* struct-like tag seen */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1661 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
1662 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
1663 } STRUCTST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1664 STRUCTST structdef;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1665
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1666 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1667 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1668 * struct tag, and structtype is the type of the preceding struct-like
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1669 * keyword.
2323
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 char structtag[BUFSIZ];
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
1672 enum sym_type structtype;
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 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1675 * 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
1676 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1677 typedef enum
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 dnone, /* nothing seen */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1680 dsharpseen, /* '#' seen as first char on line */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1681 ddefineseen, /* '#' and 'define' seen */
5044
d3bd7baee39f (FUNCST, TYPEDST, STRUCTST, DEFINEST): Delete excess commas.
Richard M. Stallman <rms@gnu.org>
parents: 4937
diff changeset
1682 dignorerest /* ignore rest of line */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1683 } DEFINEST;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1684 DEFINEST definedef;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1685
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1686 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1687 * Set this to TRUE, and the next token considered is called a function.
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1688 * Used only for GNUmacs's function-defining macros.
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1689 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1690 logical next_token_is_func;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1691
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1692 /*
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1693 * 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
1694 */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1695 logical yacc_rules;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1696
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1697 /*
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1698 * consider_token ()
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1699 * 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
1700 * 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
1701 * tag.
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 * *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
1704 * 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
1705 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1706 * 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
1707 * 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
1708 * `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
1709 * whatever follows `operator'.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1710 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1711 * Globals
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1712 * funcdef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1713 * structdef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1714 * definedef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1715 * typdef IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1716 * next_token_is_func IN OUT
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1717 */
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 logical
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1720 consider_token (c, tokp, c_ext, cblev, is_func)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1721 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
1722 register TOKEN *tokp; /* IN: token pointer */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1723 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
1724 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
1725 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
1726 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1727 enum sym_type toktype = C_symtype(tokp->p, tokp->len, c_ext);
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 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1730 * Advance the definedef state machine.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1731 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1732 switch (definedef)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1733 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1734 case dnone:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1735 /* 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
1736 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1737 case dsharpseen:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1738 if (toktype == st_C_define)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1739 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1740 definedef = ddefineseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1741 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1742 else
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1743 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1744 definedef = dignorerest;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1745 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1746 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1747 case ddefineseen:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1748 /*
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
1749 * 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
1750 * and constantypedefs is FALSE.
6756
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 definedef = dignorerest;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1753 *is_func = (c == '(');
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1754 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
1755 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1756 else
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1757 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1758 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
1759 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1760 default:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1761 error ("internal error: definedef value.", 0);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1762 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1763
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1764 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1765 * Now typedefs
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1766 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1767 switch (typdef)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1768 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1769 case tnone:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1770 if (toktype == st_C_typedef)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1771 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1772 if (typedefs)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1773 typdef = ttypedseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1774 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
1775 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1776 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1777 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1778 case ttypedseen:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1779 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1780 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1781 case st_none:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1782 case st_C_typespec:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1783 typdef = tend;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1784 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1785 case st_C_struct:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1786 case st_C_enum:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1787 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1788 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1789 /* 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
1790 break;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1791 case tend:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1792 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1793 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1794 case st_C_typespec:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1795 case st_C_struct:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1796 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
1797 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1798 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1799 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1800 }
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 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1803 * 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
1804 * 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
1805 * 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
1806 * within structs.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1807 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1808 * 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
1809 * 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
1810 * 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
1811 *
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1812 * This if statement deals with the typdef state machine as
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1813 * follows: if typdef==ttypedseen and token is struct/union/class/enum,
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1814 * 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
1815 * state machine.
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1816 */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1817 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1818 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1819 case st_C_struct:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1820 case st_C_enum:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1821 if (typdef == ttypedseen
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1822 || (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
1823 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1824 structdef = skeyseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1825 structtype = toktype;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1826 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1827 return FALSE;
6756
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 if (structdef == skeyseen)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1830 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1831 if (structtype == st_C_struct)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1832 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1833 strncpy (structtag, tokp->p, tokp->len);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1834 structtag[tokp->len] = '\0'; /* for struct/union/class */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1835 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1836 else
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1837 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1838 structtag[0] = '\0'; /* for enum (why is it treated differently?) */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1839 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1840 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
1841 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1842 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1843
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1844 /* 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
1845 if (typdef != tnone)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1846 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1847 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
1848 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1849 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1850
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1851 /* Detect GNU macros. */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1852 if (definedef == dnone)
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1853 if (strneq (tokp->p, "DEFUN", 5) /* Used in emacs */
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1854 #if FALSE
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1855 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
1856 are not met anyway.
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1857 || strneq (tokp->p, "EXFUN", 5) /* Used in glibc */
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1858 || strneq (tokp->p, "DEFVAR_", 7) /* Used in emacs */
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1859 #endif
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1860 || strneq (tokp->p, "SYSCALL", 7) /* Used in glibc (mach) */
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1861 || strneq (tokp->p, "ENTRY", 5) /* Used in glibc */
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1862 || strneq (tokp->p, "PSEUDO", 6)) /* Used in glibc */
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1863
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1864 {
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1865 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
1866 return FALSE;
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1867 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1868 if (next_token_is_func)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1869 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1870 next_token_is_func = FALSE;
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1871 funcdef = fignore;
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
1872 *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
1873 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1874 }
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 /* A function? */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1877 switch (toktype)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1878 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1879 case st_C_typespec:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1880 if (funcdef != finlist && funcdef != fignore)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1881 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
1882 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1883 default:
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1884 if (funcdef == fnone)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1885 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1886 funcdef = ftagseen;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1887 *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
1888 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1889 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1890 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1891
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
1892 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1893 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1894
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1895 /*
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1896 * C_entries ()
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1897 * 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
1898 * struct/union/enum definitions in C syntax and adds them
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1899 * to the list.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1900 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1901
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1902 #define curlb (lbs[curndx].lb)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1903 #define othlb (lbs[1-curndx].lb)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1904 #define newlb (lbs[newndx].lb)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1905 #define curlinepos (lbs[curndx].linepos)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1906 #define othlinepos (lbs[1-curndx].linepos)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1907 #define newlinepos (lbs[newndx].linepos)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1908
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
1909 /* Save and restore token state. This is used when preprocessor defines
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
1910 are handled, to avoid disturbing active function/typedef/struct states. */
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
1911 #define TOKEN_SAVED_P (savetok.lineno > 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
1912 #define SAVE_TOKEN (savetok = tok, savetok.p = (char *) tokoff, \
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
1913 savetok.len = toklen, strcpy(savenameb, nameb))
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
1914 #define RESTORE_TOKEN (tok = savetok, tokoff = (int) tok.p, \
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
1915 toklen = tok.len, strcpy(nameb, savenameb), \
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
1916 savetok.lineno = 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
1917
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1918 #define CNL_SAVE_DEFINEDEF \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1919 do { \
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1920 SET_FILEPOS (curlinepos, inf, charno); \
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1921 lineno++; \
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1922 charno += readline (&curlb, inf); \
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1923 lp = curlb.buffer; \
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1924 quotednl = FALSE; \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1925 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
1926 } while (0)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1927
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1928 #define CNL \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1929 do { \
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1930 CNL_SAVE_DEFINEDEF; \
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
1931 if (TOKEN_SAVED_P) \
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
1932 RESTORE_TOKEN; \
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1933 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
1934 } while (0)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1935
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1936 #define MAKE_TAG_FROM_NEW_LB(isfun) pfnote (nameb, isfun, tok.named, \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1937 newlb.buffer, tokoff + toklen + 1, tok.lineno, GET_CHARNO (newlinepos))
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1938 #define MAKE_TAG_FROM_OTH_LB(isfun) pfnote (nameb, isfun, tok.named, \
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1939 othlb.buffer, tokoff + toklen + 1, tok.lineno, GET_CHARNO (othlinepos))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1940
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1941 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
1942 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
1943 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
1944 FILE *inf; /* input file */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1945 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1946 register char c; /* latest char read; '\0' for end of line */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1947 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
1948 int curndx, newndx; /* indices for current and new lb */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1949 TOKEN tok; /* latest token read for funcdef & structdef */
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
1950 char nameb[BUFSIZ]; /* latest token name for funcdef & structdef */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1951 register int tokoff; /* offset in line of start of latest token */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1952 register int toklen; /* length of latest token */
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
1953 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
1954 int parlev; /* current parenthesis level */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1955 logical incomm, inquote, inchar, quotednl, midtoken;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1956 logical cplpl;
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
1957 TOKEN savetok; /* saved token during preprocessor handling */
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
1958 char savenameb[BUFSIZ]; /* ouch! */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1959
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
1960 savetok.lineno = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1961 curndx = newndx = 0;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1962 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1963 charno = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1964 lp = curlb.buffer;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1965 *lp = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1966
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
1967 definedef = dnone; funcdef = fnone; typdef = tnone; structdef = snone;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1968 next_token_is_func = yacc_rules = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1969 midtoken = inquote = inchar = incomm = quotednl = FALSE;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
1970 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
1971 parlev = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1972 cplpl = c_ext & C_PLPL;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1973
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1974 while (!feof (inf))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1975 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1976 c = *lp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1977 if (c == '\\')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1978 {
621
eca8812e61cd *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 462
diff changeset
1979 /* 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
1980 '\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
1981 to read the next line. */
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1982 if (*lp == '\0')
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1983 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1984 quotednl = TRUE;
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1985 continue;
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
1986 }
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
1987 lp++;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1988 c = ' ';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1989 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1990 else if (incomm)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1991 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1992 switch (c)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
1993 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1994 case '*':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1995 if (*lp == '/')
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1996 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1997 c = *lp++;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1998 incomm = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
1999 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2000 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2001 case '\0':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2002 /* 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
2003 traditional cpp. */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2004 CNL_SAVE_DEFINEDEF;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2005 break;
240
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 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2008 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2009 else if (inquote)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2010 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2011 switch (c)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2012 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2013 case '"':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2014 inquote = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2015 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2016 case '\0':
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2017 /* 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
2018 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
2019 usually accept them. */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2020 CNL_SAVE_DEFINEDEF;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2021 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2022 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2023 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2024 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2025 else if (inchar)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2026 {
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2027 switch (c)
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2028 {
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2029 case '\0':
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2030 /* Hmmm, something went wrong. */
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2031 CNL;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2032 /* FALLTHRU */
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2033 case '\'':
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2034 inchar = FALSE;
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2035 break;
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2036 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2037 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2038 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2039 else
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2040 switch (c)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2041 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2042 case '"':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2043 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
2044 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
2045 funcdef = fnone;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2046 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2047 case '\'':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2048 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
2049 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
2050 funcdef = fnone;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2051 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2052 case '/':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2053 if (*lp == '*')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2054 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2055 lp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2056 incomm = TRUE;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2057 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2058 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2059 else if (cplpl && *lp == '/')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2060 {
727
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 621
diff changeset
2061 c = 0;
540b047ece4d *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 621
diff changeset
2062 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2063 }
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
2064 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
2065 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2066 case '%':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2067 if ((c_ext & YACC) && *lp == '%')
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2068 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2069 /* 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
2070 lp++;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2071 definedef = dnone; funcdef = fnone;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2072 typdef = tnone; structdef = snone;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2073 next_token_is_func = FALSE;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2074 midtoken = inquote = inchar = incomm = quotednl = FALSE;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2075 cblev = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2076 yacc_rules = !yacc_rules;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2077 continue;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2078 }
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
2079 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
2080 break;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2081 case '#':
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2082 if (definedef == dnone)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2083 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2084 char *cp;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2085 logical cpptoken = TRUE;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2086
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2087 /* 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
2088 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
2089 token. */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2090 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
2091 if (!iswhite (*cp))
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2092 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2093 if (*cp == '*' && *(cp+1) == '/')
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2094 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2095 cp++;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2096 cpptoken = TRUE;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2097 }
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2098 else
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2099 cpptoken = FALSE;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2100 }
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2101 if (cpptoken)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2102 definedef = dsharpseen;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2103 } /* if (definedef == dnone) */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2104
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2105 continue;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2106 } /* switch (c) */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2107
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2108
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2109 /* 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
2110 if ((definedef != dnone
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2111 || (cblev == 0 && structdef != scolonseen)
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2112 || (cblev == 1 && cplpl && structdef == sinbody))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2113 && typdef != tignore
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2114 && definedef != dignorerest
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2115 && funcdef != finlist)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2116 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2117 if (midtoken)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2118 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2119 if (endtoken (c))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2120 {
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
2121 if (cplpl && c == ':' && *lp == ':' && begtoken(*(lp + 1)))
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 /*
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2124 * 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
2125 * beginning of an identifier.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2126 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2127 lp += 2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2128 toklen += 3;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2129 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2130 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2131 {
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2132 logical is_func = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2133
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2134 tok.lineno = lineno;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2135 tok.p = newlb.buffer + tokoff;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2136 tok.len = toklen;
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2137 tok.named = FALSE;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2138 if (yacc_rules
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2139 || consider_token (c, &tok, c_ext, cblev, &is_func))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2140 {
2004
6469a137fea6 (C_entries): New local variable quotednl. Used for
Richard M. Stallman <rms@gnu.org>
parents: 1938
diff changeset
2141 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
2142 && definedef == dnone
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2143 && is_func)
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2144 /* 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
2145 {
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2146 sprintf (nameb, "%s::%.*s",
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2147 ((structtag[0] == '\0')
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2148 ? "_anonymous_" : structtag),
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2149 tok.len, tok.p);
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2150 tok.named = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2151 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2152 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2153 {
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2154 sprintf (nameb, "%.*s", tok.len, tok.p);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2155 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2156
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2157 if (structdef == stagseen
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2158 || typdef == tend
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2159 || (is_func
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2160 && definedef == dignorerest)) /* macro */
4750
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2161 tok.named = TRUE;
cdefe4f21650 Mon Sep 20 18:06:12 1993 Francesco Potorti` (pot at fly)
Francesco Potortì <pot@gnu.org>
parents: 4696
diff changeset
2162
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
2163 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
2164 && (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
2165 || 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
2166 || typdef == tend))
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2167 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2168 if (newndx == curndx)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2169 curndx = 1 - curndx; /* switch line buffers */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2170 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2171 else
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2172 MAKE_TAG_FROM_NEW_LB (is_func);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2173 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2174 midtoken = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2175 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2176 } /* if (endtoken (c)) */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2177 else if (intoken (c))
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2178 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2179 toklen++;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2180 continue;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2181 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2182 } /* if (midtoken) */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2183 else if (begtoken (c))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2184 {
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
2185 switch (definedef)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2186 {
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
2187 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
2188 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
2189 {
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
2190 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
2191 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
2192 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
2193 case 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
2194 MAKE_TAG_FROM_OTH_LB (TRUE);
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
2195 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
2196 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
2197 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
2198 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
2199 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
2200 }
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 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
2202 structdef = snone;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2203 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
2204 case dsharpseen:
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2205 /* Take a quick peek ahead for a define directive,
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
2206 so we can avoid saving the token when not absolutely
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 necessary. [This is a speed hack.] */
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2208 if (c == 'd' && strneq (lp, "efine", 5)
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2209 && iswhite (*(lp + 5)))
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
2210 {
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 SAVE_TOKEN;
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 definedef = ddefineseen;
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 lp += 6;
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 }
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 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
2216 definedef = dignorerest;
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 continue;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2218 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2219 if (!yacc_rules || lp == newlb.buffer + 1)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2220 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2221 tokoff = lp - 1 - newlb.buffer;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2222 toklen = 1;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2223 midtoken = TRUE;
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 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2226 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2227 } /* if must look at token */
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
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2230 /* 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
2231 after having handled a token.*/
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2232 switch (c)
401
24b63d6679b6 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 240
diff changeset
2233 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2234 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
2235 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
2236 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2237 if (structdef == stagseen)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2238 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
2239 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
2240 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
2241 {
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
2242 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
2243 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
2244 {
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 MAKE_TAG_FROM_OTH_LB (FALSE);
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 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
2247 }
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 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
2249 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
2250 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
2251 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
2252 }
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2253 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2254 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
2255 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
2256 break;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2257 if (cblev == 0)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2258 switch (typdef)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2259 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2260 case tend:
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2261 MAKE_TAG_FROM_OTH_LB (FALSE);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2262 /* FALLTHRU */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2263 default:
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2264 typdef = tnone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2265 }
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2266 if (funcdef != fignore)
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2267 funcdef = fnone;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2268 if (structdef == stagseen)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2269 structdef = snone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2270 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2271 case ',':
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2272 if (definedef != dnone)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2273 break;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2274 if (funcdef != finlist && funcdef != fignore)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2275 funcdef = fnone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2276 if (structdef == stagseen)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2277 structdef = snone;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2278 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2279 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
2280 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
2281 break;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2282 if (cblev == 0 && typdef == tend)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2283 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2284 typdef = tignore;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2285 MAKE_TAG_FROM_OTH_LB (FALSE);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2286 break;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2287 }
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2288 if (funcdef != finlist && funcdef != fignore)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2289 funcdef = fnone;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2290 if (structdef == stagseen)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2291 structdef = snone;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2292 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2293 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
2294 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
2295 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2296 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
2297 {
9193
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2298 case fnone:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2299 switch (typdef)
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2300 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2301 case ttypedseen:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2302 case tend:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2303 /* 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
2304 This handles constructs like:
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2305 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
2306 if (*lp != '*')
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2307 {
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2308 typdef = tignore;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2309 MAKE_TAG_FROM_OTH_LB (FALSE);
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 break;
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2312 } /* switch (typdef) */
86fd33a4f327 * etags.c (C_entries): Recognise typedef of ANSI style functions.
Francesco Potortì <pot@gnu.org>
parents: 8789
diff changeset
2313 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2314 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
2315 funcdef = fstartlist;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2316 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2317 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
2318 funcdef = finlist;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2319 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
2320 }
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
2321 parlev++;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2322 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2323 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
2324 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
2325 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
2326 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
2327 {
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 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
2329 {
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
2330 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
2331 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
2332 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
2333 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
2334 }
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2335 if (cblev == 0 && typdef == tend)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2336 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2337 typdef = tignore;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2338 MAKE_TAG_FROM_OTH_LB (FALSE);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2339 }
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
2340 }
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 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
2342 parlev = 0;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2343 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2344 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
2345 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
2346 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2347 if (typdef == ttypedseen)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2348 typdef = tinbody;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2349 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
2350 {
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2351 case skeyseen: /* unnamed struct */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2352 structtag[0] = '\0';
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2353 structdef = sinbody;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2354 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2355 case stagseen:
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2356 case scolonseen: /* named struct */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2357 structdef = sinbody;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2358 MAKE_TAG_FROM_OTH_LB (FALSE);
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2359 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
2360 }
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2361 switch (funcdef)
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2362 {
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2363 case flistseen:
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2364 MAKE_TAG_FROM_OTH_LB (TRUE);
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2365 /* FALLTHRU */
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2366 case fignore:
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2367 funcdef = fnone;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2368 break;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2369 case fnone:
9635
8defeb29b293 * etags.c (prestr, substr): return a logical type.
Francesco Potortì <pot@gnu.org>
parents: 9621
diff changeset
2370 /* 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
2371 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
2372 cblev = -1;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2373 }
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2374 cblev++;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2375 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2376 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
2377 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
2378 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
2379 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
2380 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
2381 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2382 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
2383 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
2384 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2385 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
2386 {
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 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
2388 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
2389 }
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2390 else if (cblev > 0)
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2391 cblev--;
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2392 if (cblev == 0)
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2393 {
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2394 if (typdef == tinbody)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2395 typdef = tend;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2396 structdef = snone;
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
2397 strcpy (structtag, "<error 2>");
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2398 }
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2399 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
2400 case '=':
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
2401 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
2402 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
2403 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
2404 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
2405 /* 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
2406 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
2407 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
2408 break;
2323
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2409 case '\0':
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2410 /* 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
2411 if (quotednl)
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2412 CNL_SAVE_DEFINEDEF;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2413 else
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2414 CNL;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2415 break;
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2416 } /* switch (c) */
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2417
626d9ac52bc9 (YACC): flag added to c_ext.
Richard M. Stallman <rms@gnu.org>
parents: 2004
diff changeset
2418 } /* while not eof */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2419 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2420
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2421 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2422 * 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
2423 * 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
2424 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2425 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2426 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
2427 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2428 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2429 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
2430 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2431
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2432 /* 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
2433 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2434 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
2435 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2436 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2437 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
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 /* 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
2441 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2442 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
2443 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2444 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2445 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
2446 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2447
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2448 /* 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
2449 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2450 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
2451 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2452 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2453 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
2454 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2455
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2456 /* Fortran parsing */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2457
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2458 char *dbp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2459 int pfcnt;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2460
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2461 logical
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2462 tail (cp)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2463 char *cp;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2464 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2465 register int len = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2466
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2467 while (*cp && (*cp | ' ') == (dbp[len] | ' '))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2468 cp++, len++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2469 if (*cp == 0)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2470 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2471 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
2472 return TRUE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2473 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2474 return FALSE;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2475 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2476
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2477 void
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2478 takeprec ()
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2479 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2480 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2481 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2482 if (*dbp != '*')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2483 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2484 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2485 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2486 dbp++;
8180
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
2487 if (tail ("(*)"))
c98f9acb71e3 * etags.c (main): Don't barf on obsolete -t and -T switches.
Francesco Potortì <pot@gnu.org>
parents: 7776
diff changeset
2488 return;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2489 if (!isdigit (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2490 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2491 --dbp; /* force failure */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2492 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2493 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2494 do
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2495 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2496 while (isdigit (*dbp));
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2497 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2498
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2499 void
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2500 getit (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2501 FILE *inf;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2502 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2503 register char *cp;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2504 char c;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2505 char nambuf[BUFSIZ];
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2506
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2507 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2508 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2509 if (*dbp == '\0')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2510 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2511 lineno++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2512 linecharno = charno;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2513 charno += readline (&lb, inf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2514 dbp = lb.buffer;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2515 if (dbp[5] != '&')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2516 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2517 dbp += 6;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2518 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2519 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2520 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2521 if (!isalpha (*dbp)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2522 && *dbp != '_'
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 return;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2525 for (cp = dbp + 1;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2526 (*cp
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2527 && (isalpha (*cp) || isdigit (*cp) || (*cp == '_') || (*cp == '$')));
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2528 cp++)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2529 continue;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2530 c = *cp;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2531 *cp = '\0';
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2532 strcpy (nambuf, dbp);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2533 *cp = c;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2534 pfnote (nambuf, TRUE, FALSE, lb.buffer,
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2535 cp - lb.buffer + 1, lineno, linecharno);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2536 pfcnt++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2537 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2538
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2539 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2540 Fortran_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2541 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2542 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2543 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2544 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2545 pfcnt = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2546
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2547 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2548 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2549 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2550 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2551 charno += readline (&lb, inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2552 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2553 if (*dbp == '%')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2554 dbp++; /* Ratfor escape to fortran */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2555 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2556 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2557 if (*dbp == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2558 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2559 switch (*dbp | ' ')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2560 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2561 case 'i':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2562 if (tail ("integer"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2563 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2564 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2565 case 'r':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2566 if (tail ("real"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2567 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2568 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2569 case 'l':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2570 if (tail ("logical"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2571 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2572 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2573 case 'c':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2574 if (tail ("complex") || tail ("character"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2575 takeprec ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2576 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2577 case 'd':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2578 if (tail ("double"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2579 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2580 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2581 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2582 if (*dbp == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2583 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2584 if (tail ("precision"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2585 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2586 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2587 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2588 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2589 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2590 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2591 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2592 if (*dbp == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2593 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2594 switch (*dbp | ' ')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2595 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2596 case 'f':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2597 if (tail ("function"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2598 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2599 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2600 case 's':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2601 if (tail ("subroutine"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2602 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2603 continue;
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
2604 case 'e':
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
2605 if (tail ("entry"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2606 getit (inf);
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
2607 continue;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2608 case 'p':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2609 if (tail ("program"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2610 {
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2611 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2612 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2613 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2614 if (tail ("procedure"))
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2615 getit (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2616 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2617 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2618 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2619 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2620
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2621 /*
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2622 * 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
2623 * Unix and microcontroller assembly tag handling
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2624 * 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
2625 */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2626 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2627 Asm_labels (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2628 FILE *inf;
240
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 char nambuf[BUFSIZ];
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2631 register char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2632 char c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2633
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2634 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2635 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2636 pfcnt = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2637
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2638 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2639 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2640 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2641 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2642 charno += readline (&lb, inf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2643 cp = lb.buffer;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2644
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2645 /* 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
2646 following identifier. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2647 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2648 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2649 /* Read past label. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2650 cp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2651 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2652 cp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2653 if (*cp == ':' || isspace (*cp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2654 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2655 /* Found end of label, so copy it and add it to the table. */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2656 c = *cp;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2657 *cp = '\0';
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2658 strcpy (nambuf, lb.buffer);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2659 *cp = c;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2660 pfnote (nambuf, TRUE, FALSE, lb.buffer,
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2661 cp - lb.buffer + 1, lineno, linecharno);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2662 pfcnt++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2663 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2664 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2665 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2666 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2667
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2668 /* Added by Mosur Mohan, 4/22/88 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2669 /* Pascal parsing */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2670
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2671 #define GET_NEW_LINE \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2672 { \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2673 linecharno = charno; lineno++; \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2674 charno += 1 + readline (&lb, inf); \
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2675 dbp = lb.buffer; \
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 /* Locates tags for procedures & functions.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2679 * Doesn't do any type- or var-definitions.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2680 * It does look for the keyword "extern" or "forward"
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2681 * immediately following the procedure statement;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2682 * if found, the tag is skipped.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2683 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2684
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2685 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2686 Pascal_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2687 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2688 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2689 struct linebuffer tline; /* mostly copied from C_entries */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2690 long save_lcno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2691 int save_lineno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2692 char c, *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2693 char nambuf[BUFSIZ];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2694
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2695 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
2696 incomment, /* point is inside a comment */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2697 inquote, /* point is inside '..' string */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2698 get_tagname, /* point is after PROCEDURE/FUNCTION */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2699 /* keyword, so next item = potential tag */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2700 found_tag, /* point is after a potential tag */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2701 inparms, /* point is within parameter-list */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2702 verify_tag; /* point has passed the parm-list, so the */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2703 /* next token will determine whether */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2704 /* this is a FORWARD/EXTERN to be */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2705 /* ignored, or whether it is a real tag */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2706
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2707 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2708 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2709 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2710 *dbp = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2711 initbuffer (&tline);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2712
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2713 incomment = inquote = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2714 found_tag = FALSE; /* have a proc name; check if extern */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2715 get_tagname = FALSE; /* have found "procedure" keyword */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2716 inparms = FALSE; /* found '(' after "proc" */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2717 verify_tag = FALSE; /* check if "extern" is ahead */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2718
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2719 /* 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
2720 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2721 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2722 c = *dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2723 if (c == 0) /* if end of line */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2724 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2725 GET_NEW_LINE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2726 if (*dbp == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2727 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2728 if (!((found_tag && verify_tag) ||
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2729 get_tagname))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2730 c = *dbp++; /* only if don't need *dbp pointing */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2731 /* to the beginning of the name of */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2732 /* the procedure or function */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2733 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2734 if (incomment)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2735 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2736 if (c == '}') /* within { - } comments */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2737 incomment = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2738 else if (c == '*' && dbp[1] == ')') /* within (* - *) comments */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2739 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2740 dbp++;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2741 incomment = FALSE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2742 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2743 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2744 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2745 else if (inquote)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2746 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2747 if (c == '\'')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2748 inquote = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2749 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2750 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2751 else
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2752 switch (c)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2753 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2754 case '\'':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2755 inquote = TRUE; /* found first quote */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2756 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2757 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
2758 incomment = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2759 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2760 case '(':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2761 if (*dbp == '*') /* found open-(*-comment */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2762 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2763 incomment = TRUE;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2764 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2765 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2766 else if (found_tag) /* found '(' after tag, i.e., parm-list */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2767 inparms = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2768 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2769 case ')': /* end of parms list */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2770 if (inparms)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2771 inparms = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2772 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2773 case ';':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2774 if ((found_tag) && (!inparms)) /* end of proc or fn stmt */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2775 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2776 verify_tag = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2777 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2778 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2779 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2780 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2781 if ((found_tag) && (verify_tag) && (*dbp != ' '))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2782 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2783 /* check if this is an "extern" declaration */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2784 if (*dbp == 0)
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 if ((*dbp == 'e') || (*dbp == 'E'))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2787 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2788 if (tail ("extern")) /* superfluous, really! */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2789 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2790 found_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2791 verify_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2792 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2793 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2794 else if ((*dbp == 'f') || (*dbp == 'F'))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2795 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2796 if (tail ("forward")) /* check for forward reference */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2797 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2798 found_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2799 verify_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2800 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2801 }
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
2802 if ((found_tag) && (verify_tag)) /* not external proc, so make tag */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2803 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2804 found_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2805 verify_tag = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2806 pfnote (nambuf, TRUE, FALSE,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2807 tline.buffer, cp - tline.buffer + 1,
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2808 save_lineno, save_lcno);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2809 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2810 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2811 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2812 if (get_tagname) /* grab name of proc or fn */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2813 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2814 if (*dbp == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2815 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2816
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2817 /* save all values for later tagging */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2818 tline.size = lb.size;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2819 strcpy (tline.buffer, lb.buffer);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2820 save_lineno = lineno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2821 save_lcno = linecharno;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2822
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2823 /* grab block name */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2824 for (cp = dbp + 1; *cp && (!endtoken (*cp)); cp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2825 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2826 c = cp[0];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2827 cp[0] = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2828 strcpy (nambuf, dbp);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2829 cp[0] = c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2830 dbp = cp; /* restore dbp to e-o-token */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2831 get_tagname = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2832 found_tag = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2833 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2834
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2835 /* and proceed to check for "extern" */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2836 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2837 if (!incomment && !inquote && !found_tag && !get_tagname)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2838 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2839 /* check for proc/fn keywords */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2840 switch (c | ' ')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2841 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2842 case 'p':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2843 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2844 get_tagname = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2845 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2846 case 'f':
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2847 if (tail ("unction"))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2848 get_tagname = TRUE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2849 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2850 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2851 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2852 } /* while not eof */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2853 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2854
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2855 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2856 * lisp tag functions
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2857 * just look for (def or (DEF
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2858 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2859
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2860 int
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2861 L_isdef (tokp)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2862 register char *tokp;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2863 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2864 return ((tokp[1] == 'd' || tokp[1] == 'D')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2865 && (tokp[2] == 'e' || tokp[2] == 'E')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2866 && (tokp[3] == 'f' || tokp[3] == 'F'));
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2867 }
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2868
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2869 int
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2870 L_isquote (tokp)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2871 register char *tokp;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2872 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2873 return ((*(++tokp) == 'q' || *tokp == 'Q')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2874 && (*(++tokp) == 'u' || *tokp == 'U')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2875 && (*(++tokp) == 'o' || *tokp == 'O')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2876 && (*(++tokp) == 't' || *tokp == 'T')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2877 && (*(++tokp) == 'e' || *tokp == 'E')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
2878 && isspace(*(++tokp)));
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2879 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2880
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2881 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2882 L_getit ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2883 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2884 register char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2885 char c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2886 char nambuf[BUFSIZ];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2887
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2888 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
2889 dbp++;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2890 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
2891 {
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2892 dbp += 7;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2893 while (isspace(*dbp))
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2894 dbp++;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2895 }
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2896 for (cp = dbp /*+1*/; *cp && *cp != '(' && *cp != ' ' && *cp != ')'; cp++)
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2897 continue;
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2898 if (cp == dbp)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2899 return;
4663
5f0ff5c890a8 * etags.c (L_isdef, L_isquote, L_getit): small optimisations.
Francesco Potortì <pot@gnu.org>
parents: 4406
diff changeset
2900
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2901 c = cp[0];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2902 cp[0] = 0;
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
2903 strcpy (nambuf, dbp);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2904 cp[0] = c;
4051
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2905 pfnote (nambuf, TRUE, FALSE, lb.buffer,
73aa16fc728d (consider_token): was `==', now is `='.
Richard M. Stallman <rms@gnu.org>
parents: 3921
diff changeset
2906 cp - lb.buffer + 1, lineno, linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2907 pfcnt++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2908 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2909
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2910 void
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2911 Lisp_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2912 FILE *inf;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2913 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2914 lineno = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2915 charno = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2916 pfcnt = 0;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2917
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2918 while (!feof (inf))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2919 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2920 lineno++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2921 linecharno = charno;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2922 charno += readline (&lb, inf);
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2923 dbp = lb.buffer;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2924 if (dbp[0] == '(')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2925 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2926 if (L_isdef (dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2927 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2928 while (!isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2929 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2930 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2931 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2932 L_getit ();
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2933 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2934 else
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2935 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2936 /* Check for (foo::defmumble name-defined ... */
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2937 do
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2938 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2939 while (*dbp && !isspace (*dbp)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2940 && *dbp != ':' && *dbp != '(' && *dbp != ')');
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2941 if (*dbp == ':')
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2942 {
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2943 do
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2944 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2945 while (*dbp == ':');
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2946
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2947 if (L_isdef (dbp - 1))
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 while (!isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2950 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2951 while (isspace (*dbp))
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2952 dbp++;
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2953 L_getit ();
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2954 }
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 }
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 }
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2959 }
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2960
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2961 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2962 * Scheme tag functions
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2963 * look for (def... xyzzy
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2964 * look for (def... (xyzzy
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2965 * look for (def ... ((...(xyzzy ....
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2966 * look for (set! xyzzy
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2967 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2968
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2969 void get_scheme ();
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2970
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2971 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2972 Scheme_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2973 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2974 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2975 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2976 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2977 pfcnt = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2978
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2979 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2980 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2981 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2982 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
2983 charno += readline (&lb, inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2984 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2985 if (dbp[0] == '(' &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2986 (dbp[1] == 'D' || dbp[1] == 'd') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2987 (dbp[2] == 'E' || dbp[2] == 'e') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2988 (dbp[3] == 'F' || dbp[3] == 'f'))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2989 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2990 while (!isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2991 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2992 /* Skip over open parens and white space */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2993 while (*dbp && (isspace (*dbp) || *dbp == '('))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2994 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2995 get_scheme ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2996 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2997 if (dbp[0] == '(' &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2998 (dbp[1] == 'S' || dbp[1] == 's') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
2999 (dbp[2] == 'E' || dbp[2] == 'e') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3000 (dbp[3] == 'T' || dbp[3] == 't') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3001 (dbp[4] == '!' || dbp[4] == '!') &&
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3002 (isspace (dbp[5])))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3003 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3004 while (!isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3005 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3006 /* Skip over white space */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3007 while (isspace (*dbp))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3008 dbp++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3009 get_scheme ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3010 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3011 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3012 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3013
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3014 void
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3015 get_scheme ()
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3016 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3017 register char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3018 char c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3019 char nambuf[BUFSIZ];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3020
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3021 if (*dbp == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3022 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3023 /* Go till you get to white space or a syntactic break */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3024 for (cp = dbp + 1; *cp && *cp != '(' && *cp != ')' && !isspace (*cp); cp++)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3025 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3026 /* Null terminate the string there. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3027 c = cp[0];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3028 cp[0] = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3029 /* Copy the string */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3030 strcpy (nambuf, dbp);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3031 /* Unterminate the string */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3032 cp[0] = c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3033 /* Announce the change */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3034 pfnote (nambuf, TRUE, FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3035 pfcnt++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3036 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3037
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3038 /* Find tags in TeX and LaTeX input files. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3039
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3040 /* TEX_toktab is a table of TeX control sequences that define tags.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3041 Each TEX_tabent records one such control sequence.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3042 CONVERT THIS TO USE THE Stab TYPE!! */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3043
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3044 struct TEX_tabent
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3045 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3046 char *name;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3047 int len;
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 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3051
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3052 /* Default set of control sequences to put into TEX_toktab.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3053 The value of environment var TEXTAGS is prepended to this. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3054
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3055 char *TEX_defenv = "\
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3056 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem:typeout";
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3057
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3058 void TEX_mode ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3059 struct TEX_tabent *TEX_decode_env ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3060 void TEX_getit ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3061 int TEX_Token ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3062
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3063 char TEX_esc = '\\';
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3064 char TEX_opgrp = '{';
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3065 char TEX_clgrp = '}';
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3066
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/LaTeX scanning loop.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3069 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3070
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3071 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3072 TeX_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3073 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3074 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3075 char *lasthit;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3076
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3077 lineno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3078 charno = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3079 pfcnt = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3080
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3081 /* 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
3082 TEX_mode (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3083
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3084 /* Initialize token table once from environment. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3085 if (!TEX_toktab)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3086 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3087
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3088 while (!feof (inf))
1040
eb7ebe86e885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1026
diff changeset
3089 { /* Scan each line in file */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3090 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3091 linecharno = charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3092 charno += readline (&lb, inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3093 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3094 lasthit = dbp;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3095 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
3096 {
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3097 register int i;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3098
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3099 if (!*(++dbp))
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3100 break;
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3101 linecharno += dbp - lasthit;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3102 lasthit = dbp;
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3103 i = TEX_Token (lasthit);
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3104 if (0 <= i)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3105 {
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3106 TEX_getit (lasthit, TEX_toktab[i].len);
1040
eb7ebe86e885 entered into RCS
Jim Blandy <jimb@redhat.com>
parents: 1026
diff changeset
3107 break; /* We only save a line once */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3108 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3109 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3110 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3111 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3112
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3113 #define TEX_LESC '\\'
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3114 #define TEX_SESC '!'
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3115 #define TEX_cmt '%'
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3116
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3117 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3118 /* chars accordingly. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3119
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3120 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3121 TEX_mode (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3122 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3123 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3124 int c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3125
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3126 while ((c = getc (inf)) != EOF)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3127 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3128 /* Skip to next line if we hit the TeX comment char. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3129 if (c == TEX_cmt)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3130 while (c != '\n')
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3131 c = getc (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3132 else if (c == TEX_LESC || c == TEX_SESC )
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3133 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3134 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3135
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3136 if (c == TEX_LESC)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3137 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3138 TEX_esc = TEX_LESC;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3139 TEX_opgrp = '{';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3140 TEX_clgrp = '}';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3141 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3142 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3143 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3144 TEX_esc = TEX_SESC;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3145 TEX_opgrp = '<';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3146 TEX_clgrp = '>';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3147 }
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3148 rewind (inf);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3149 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3150
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3151 /* Read environment and prepend it to the default string. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3152 /* Build token table. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3153
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3154 struct TEX_tabent *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3155 TEX_decode_env (evarname, defenv)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3156 char *evarname;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3157 char *defenv;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3158 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3159 register char *env, *p;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3160
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3161 struct TEX_tabent *tab;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3162 int size, i;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3163
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3164 /* Append default string to environment. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3165 env = getenv (evarname);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3166 if (!env)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3167 env = defenv;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3168 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3169 env = concat (env, defenv, "");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3170
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3171 /* Allocate a token table */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3172 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
3173 if ((p = etags_strchr (p, ':')) && *(++p))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3174 size++;
1026
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3175 /* Add 1 to leave room for null terminator. */
cc96e2df9b71 *** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents: 774
diff changeset
3176 tab = xnew (size + 1, struct TEX_tabent);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3177
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3178 /* Unpack environment string into token table. Be careful about */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3179 /* zero-length strings (leading ':', "::" and trailing ':') */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3180 for (i = 0; *env;)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3181 {
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3182 p = etags_strchr (env, ':');
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3183 if (!p) /* End of environment string. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3184 p = env + strlen (env);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3185 if (p - env > 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3186 { /* Only non-zero strings. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3187 tab[i].name = savenstr (env, p - env);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3188 tab[i].len = strlen (tab[i].name);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3189 i++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3190 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3191 if (*p)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3192 env = p + 1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3193 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3194 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3195 tab[i].name = NULL; /* Mark end of table. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3196 tab[i].len = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3197 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3198 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3199 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3200 return tab;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3201 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3202
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3203 /* 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
3204 The name being defined actually starts at (NAME + LEN + 1).
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3205 But we seem to include the TeX command in the tag name. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3206
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3207 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3208 TEX_getit (name, len)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3209 char *name;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3210 int len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3211 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3212 char *p = name + len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3213 char nambuf[BUFSIZ];
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3214
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3215 if (*name == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3216 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3217
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3218 /* Let tag name extend to next group close (or end of line) */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3219 while (*p && *p != TEX_clgrp)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3220 p++;
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3221 strncpy (nambuf, name, p - name);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3222 nambuf[p - name] = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3223
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3224 pfnote (nambuf, TRUE, FALSE, lb.buffer, strlen (lb.buffer), lineno, linecharno);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3225 pfcnt++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3226 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3227
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3228 /* 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
3229 return the pointer to the first occurrence of that command in TEX_toktab.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3230 Otherwise return -1. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3231
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3232 /* Keep the capital `T' in `Token' for dumb truncating compilers
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3233 (this distinguishes it from `TEX_toktab' */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3234 int
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3235 TEX_Token (cp)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3236 char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3237 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3238 int i;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3239
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3240 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
3241 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3242 return i;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3243 return -1;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3244 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3245
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3246 /* Support for Prolog. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3247
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3248 /* whole head (not only functor, but also arguments)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3249 is gotten in compound term. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3250
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3251 void
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3252 prolog_getit (s)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3253 char *s;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3254 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3255 char nambuf[BUFSIZ], *save_s, tmpc;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3256 int insquote, npar;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3257
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3258 save_s = s;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3259 insquote = FALSE;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3260 npar = 0;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3261 while (1)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3262 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3263 if (*s == '\0') /* syntax error. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3264 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3265 else if (insquote && *s == '\'' && *(s + 1) == '\'')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3266 s += 2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3267 else if (*s == '\'')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3268 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3269 insquote = !insquote;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3270 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3271 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3272 else if (!insquote && *s == '(')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3273 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3274 npar++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3275 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3276 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3277 else if (!insquote && *s == ')')
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3278 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3279 npar--;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3280 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3281 if (npar == 0)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3282 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3283 else if (npar < 0) /* syntax error. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3284 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3285 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3286 else if (!insquote && *s == '.' && (isspace (*(s + 1)) || *(s + 1) == '\0'))
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3287 { /* fullstop. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3288 if (npar != 0) /* syntax error. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3289 return;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3290 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3291 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3292 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3293 else
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3294 s++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3295 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3296 tmpc = *s;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3297 *s = '\0';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3298 strcpy (nambuf, save_s);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3299 *s = tmpc;
4905
710950ca1b49 Tue Nov 2 19:46:52 1993 Francesco Potorti` (pot@cnuce.cnr.it)
Francesco Potortì <pot@gnu.org>
parents: 4904
diff changeset
3300 pfnote (nambuf, TRUE, FALSE, save_s, strlen (nambuf), lineno, linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3301 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3302
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3303 /* It is assumed that prolog predicate starts from column 0. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3304
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3305 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3306 Prolog_functions (inf)
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3307 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3308 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3309 void skip_comment (), prolog_getit ();
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3310
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3311 lineno = linecharno = charno = 0;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3312 while (!feof (inf))
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3313 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3314 lineno++;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3315 linecharno += charno;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3316 charno = readline (&lb, inf) + 1; /* 1 for newline. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3317 dbp = lb.buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3318 if (isspace (dbp[0])) /* not predicate header. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3319 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3320 else if (dbp[0] == '%') /* comment. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3321 continue;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3322 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
3323 skip_comment (&lb, inf, &lineno, &linecharno);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3324 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
3325 prolog_getit (dbp);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3326 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3327 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3328
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3329 void
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3330 skip_comment (plb, inf, plineno, plinecharno)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3331 struct linebuffer *plb;
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3332 FILE *inf;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3333 int *plineno; /* result */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3334 long *plinecharno; /* result */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3335 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3336 char *cp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3337
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3338 do
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3339 {
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3340 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
3341 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
3342 return;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3343 (*plineno)++;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3344 *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
3345 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3346 while (!feof(inf));
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
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3349 #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
3350 /* 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
3351 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
3352 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
3353 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
3354 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
3355 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
3356 char *
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3357 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
3358 char *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3359 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3360 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
3361 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
3362 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
3363
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3364 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
3365 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3366 if (quoted)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3367 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3368 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
3369 *copyto++ = '\t';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3370 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
3371 *copyto++ = sep;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3372 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3373 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3374 /* 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
3375 *copyto++ = '\\';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3376 *copyto++ = *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3377 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3378 quoted = FALSE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3379 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3380 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
3381 quoted = TRUE;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3382 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
3383 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3384 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3385 *copyto++ = *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
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3388 /* 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
3389 *copyto = '\0';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3390 return name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3391 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3392
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3393 /* 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
3394 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
3395 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3396 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
3397 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
3398 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3399 char *name;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3400 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
3401 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
3402
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3403 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
3404 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3405 /* 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
3406 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
3407 patterns = NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3408 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3409 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3410
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3411 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
3412 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3413 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
3414 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3415 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3416 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
3417 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3418 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
3419 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3420 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3421 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
3422 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
3423 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3424 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
3425 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3426 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3427 (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
3428
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3429 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
3430 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
3431 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
3432 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
3433 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
3434
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3435 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
3436 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
3437 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3438 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
3439 return;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3440 }
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 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
3443 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
3444 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
3445 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3446 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
3447 xrealloc (patterns,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3448 (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
3449 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
3450 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
3451 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
3452 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3453
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3454 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3455 * Do the subtitutions indicated by the regular expression and
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3456 * arguments.
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3457 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3458 char *
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3459 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
3460 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
3461 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
3462 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3463 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
3464 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
3465
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3466 /* 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
3467 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
3468 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3469 if (*t == '\\')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3470 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3471 ++t;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3472 if (!*t)
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 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
3475 progname);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3476 return NULL;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3477 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3478 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
3479 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3480 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
3481 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
3482 }
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 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3485
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3486 /* 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
3487 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
3488 size = 0;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3489 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
3490 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3491 if (*out == '\\')
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3492 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3493 ++out;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3494 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
3495 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3496 /* 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
3497 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
3498 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
3499 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
3500 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
3501 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3502 else
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 switch (*out)
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 case '\t':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3507 result[size++] = '\t';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3508 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3509 case '\\':
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3510 *out = '\\';
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3511 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3512 default:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3513 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
3514 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3515 }
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 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3518 else
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3519 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
3520 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3521 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
3522
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3523 return result;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3524 }
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 #endif /* ETAGS_REGEXPS */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3527 /* Initialize a linebuffer for use */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3528 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3529 initbuffer (linebuffer)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3530 struct linebuffer *linebuffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3531 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3532 linebuffer->size = 200;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3533 linebuffer->buffer = xnew (200, char);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3534 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3535
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3536 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3537 * Read a line of text from `stream' into `linebuffer'.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3538 * Return the number of characters read from `stream',
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3539 * which is the length of the line including the newline, if any.
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3540 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3541 long
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3542 readline_internal (linebuffer, stream)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3543 struct linebuffer *linebuffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3544 register FILE *stream;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3545 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3546 char *buffer = linebuffer->buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3547 register char *p = linebuffer->buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3548 register char *pend;
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3549 int newline; /* 1 if ended with '\n', 0 if ended with EOF */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3550
3591
507f64624555 Apply typo patches from Paul Eggert.
Jim Blandy <jimb@redhat.com>
parents: 3569
diff changeset
3551 pend = p + linebuffer->size; /* Separate to avoid 386/IX compiler bug. */
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3552
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3553 while (1)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3554 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3555 register int c = getc (stream);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3556 if (p == pend)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3557 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3558 linebuffer->size *= 2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3559 buffer = (char *) xrealloc (buffer, linebuffer->size);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3560 p += buffer - linebuffer->buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3561 pend = buffer + linebuffer->size;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3562 linebuffer->buffer = buffer;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3563 }
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
3564 if (c == EOF || c == '\n')
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3565 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3566 *p = 0;
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
3567 newline = (c == '\n') ? 1 : 0;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3568 break;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3569 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3570 *p++ = c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3571 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3572
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3573 return p - buffer + newline;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3574 }
9976
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3575
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3576 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3577 * 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
3578 * 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
3579 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3580 long
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3581 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
3582 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
3583 FILE *stream;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3584 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3585 /* 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
3586 int i;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3587 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
3588
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3589 #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
3590 /* 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
3591 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
3592 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3593 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
3594 (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
3595 switch (match)
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 case -2:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3598 /* Some error. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3599 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
3600 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3601 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
3602 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
3603 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3604 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3605 case -1:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3606 /* No match. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3607 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3608 default:
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3609 /* 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
3610 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
3611 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3612 /* 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
3613 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
3614 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
3615 &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 if (name != NULL)
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3617 pfnote (name, TRUE, TRUE, linebuffer->buffer,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3618 match, lineno, linecharno);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3619 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3620 else
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 /* Make an unnamed tag. */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3623 pfnote (NULL, TRUE, FALSE, linebuffer->buffer,
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3624 match, lineno, linecharno);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3625 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3626 break;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3627 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3628 }
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3629 #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
3630
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3631 return result;
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
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3634 /*
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3635 * 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
3636 * 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
3637 */
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3638 void
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3639 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
3640 FILE *inf;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3641 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3642 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
3643 {
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3644 ++lineno;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3645 linecharno = charno;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3646 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
3647 }
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
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3650
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3651 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3652 savestr (cp)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3653 char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3654 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3655 return savenstr (cp, strlen (cp));
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3656 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3657
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3658 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3659 savenstr (cp, len)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3660 char *cp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3661 int len;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3662 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3663 register char *dp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3664
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3665 dp = xnew (len + 1, char);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3666 strncpy (dp, cp, len);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3667 dp[len] = '\0';
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3668 return dp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3669 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3670
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3671 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3672 * Return the ptr in sp at which the character c last
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3673 * appears; NULL if not found
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3674 *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3675 * Identical to System V strrchr, included for portability.
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3676 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3677
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3678 char *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3679 etags_strrchr (sp, c)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3680 register char *sp, c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3681 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3682 register char *r;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3683
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3684 r = NULL;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3685 do
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3686 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3687 if (*sp == c)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3688 r = sp;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3689 } 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
3690 return r;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3691 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3692
774
11867ad5bab4 *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 727
diff changeset
3693
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3694 /*
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3695 * Return the ptr in sp at which the character c first
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3696 * appears; NULL if not found
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3697 *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3698 * Identical to System V strchr, included for portability.
240
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 char *
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3702 etags_strchr (sp, c)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3703 register char *sp, c;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3704 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3705 do
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3706 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3707 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
3708 return sp;
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3709 } while (*sp++);
2869e501c2de * etags.c [ETAGS_REGEXP]: All the new code that deals with regexps
Francesco Potortì <pot@gnu.org>
parents: 9975
diff changeset
3710 return NULL;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3711 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3712
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3713 /* Print error message and exit. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3714
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3715 /* VARARGS1 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3716 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3717 fatal (s1, s2)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3718 char *s1, *s2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3719 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3720 error (s1, s2);
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3721 exit (BAD);
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
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3724 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3725
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3726 /* VARARGS1 */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3727 void
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3728 error (s1, s2)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3729 char *s1, *s2;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3730 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3731 fprintf (stderr, "%s: ", progname);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3732 fprintf (stderr, s1, s2);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3733 fprintf (stderr, "\n");
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3734 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3735
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3736 /* Return a newly-allocated string whose contents
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3737 concatenate those of s1, s2, s3. */
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 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3740 concat (s1, s2, s3)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3741 char *s1, *s2, *s3;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3742 {
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3743 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3744 char *result = xnew (len1 + len2 + len3 + 1, char);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3745
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3746 strcpy (result, s1);
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3747 strcpy (result + len1, s2);
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3748 strcpy (result + len1 + len2, s3);
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3749 result[len1 + len2 + len3] = '\0';
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3750
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3751 return result;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3752 }
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3753
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
3754 #ifdef DOS_NT
7227
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3755 char *
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3756 etags_getcwd ()
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3757 {
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3758 char *p, cwd[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3759 getwd (cwd);
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3760 p = cwd;
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3761 while (*p)
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3762 if (*p == '\\')
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3763 *p++ = '/';
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3764 else
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3765 *p++ = tolower (*p);
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3766 return strdup (cwd);
6fa038c33a0f [MSDOS]: #include <sys/param.h> for the following.
Richard M. Stallman <rms@gnu.org>
parents: 7049
diff changeset
3767 }
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
3768 #else /* not DOS_NT */
6756
8086a2590e2f * etags.c (outf, outfiledir): renamed to tagf, tagfiledir.
Francesco Potortì <pot@gnu.org>
parents: 6592
diff changeset
3769 /* Does the same work as the system V getcwd, but does not need to
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3770 guess buffer size in advance. */
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3771 char *
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3772 etags_getcwd ()
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3773 {
6831
dbfdd66854c9 #undef static.
Richard M. Stallman <rms@gnu.org>
parents: 6756
diff changeset
3774 int bufsize = 256;
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3775 char *buf = xnew (bufsize, char);
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3776
8789
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3777 #ifdef HAVE_GETCWD
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3778 while (getcwd (buf, bufsize / 2) == NULL)
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3779 {
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3780 if (errno != ERANGE)
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3781 {
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3782 perror ("pwd");
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3783 exit (BAD);
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3784 }
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3785 bufsize *= 2;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3786 buf = xnew (bufsize, char);
8789
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3787 }
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3788 #else
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3789 do
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3790 {
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3791 FILE *pipe;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3792
7537
ad2451b94c28 (etags_getcwd): Cast result of popen.
Richard M. Stallman <rms@gnu.org>
parents: 7535
diff changeset
3793 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3794 if (pipe == NULL)
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3795 {
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3796 perror ("pwd");
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3797 exit (BAD);
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3798 }
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3799 if (fgets (buf, bufsize, pipe) == NULL)
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3800 {
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3801 perror ("pwd");
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3802 exit (BAD);
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3803 }
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3804 pclose (pipe);
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3805
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3806 bufsize *= 2;
9975
e21b0674f37c * etags.c (<errno.h>): #include added.
Francesco Potortì <pot@gnu.org>
parents: 9773
diff changeset
3807 buf = xnew (bufsize, char);
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3808
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3809 } while (buf[strlen (buf) - 1] != '\n');
8789
81a2817b99b2 (etags_getcwd): Use getcwd if available.
Karl Heuer <kwzh@gnu.org>
parents: 8180
diff changeset
3810 #endif
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3811
7775
4c63040423a8 * etags.c (etags_getcwd): Delete the trailing newline from cwd.
Francesco Potortì <pot@gnu.org>
parents: 7537
diff changeset
3812 buf[strlen (buf) - 1] = '\0';
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3813 return buf;
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3814 }
9773
bd49556a7552 (main, etags_getcwd): Test DOS_NT instead of MSDOS.
Richard M. Stallman <rms@gnu.org>
parents: 9635
diff changeset
3815 #endif /* not DOS_NT */
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3816
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3817 /* 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
3818 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
3819 should end with a slash). */
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3820
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3821 char *
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3822 relative_filename (file, dir)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3823 char *file, *dir;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3824 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3825 char *fp, *dp, *res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3826
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3827 /* Find the common root of file and dir. */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3828 fp = absolute_filename (file, cwd);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3829 dp = dir;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3830 while (*fp++ == *dp++)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3831 continue;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3832 do
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3833 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3834 fp--;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3835 dp--;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3836 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3837 while (*fp != '/');
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 /* 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
3840 for (dp = etags_strchr (dp + 1, '/'), res = "";
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3841 dp != NULL;
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3842 dp = etags_strchr (dp + 1, '/'))
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3843 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3844 res = concat (res, "../", "");
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3845 }
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 /* 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
3848 res = concat (res, fp + 1, "");
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 return res; /* temporary stub */
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
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3853 /* 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
3854 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
3855 end with a slash). */
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3856
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3857 char *
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3858 absolute_filename (file, cwd)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3859 char *file, *cwd;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3860 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3861 char *slashp, *cp, *res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3862
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3863 if (file[0] == '/')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3864 res = concat (file, "", "");
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3865 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3866 res = concat (cwd, file, "");
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3867
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3868 /* Delete the "/dirname/.." and "/." substrings. */
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3869 slashp = etags_strchr (res, '/');
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3870 while (slashp != NULL && slashp[0] != '\0')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3871 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3872 if (slashp[1] == '.')
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 if (slashp[2] == '.'
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3875 && (slashp[3] == '/' || slashp[3] == '\0'))
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3876 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3877 cp = slashp;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3878 do
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3879 cp--;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3880 while (cp >= res && *cp != '/');
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3881 if (*cp == '/')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3882 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3883 strcpy (cp, slashp + 3);
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 else /* else (cp == res) */
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3886 {
6944
daa29eabfc65 * etags.c (absolute_filename): compare against '\0' instead of NULL.
Francesco Potortì <pot@gnu.org>
parents: 6831
diff changeset
3887 if (slashp[3] != '\0')
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3888 strcpy (cp, slashp + 4);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3889 else
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3890 return ".";
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3891 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3892 slashp = cp;
7776
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3893 continue;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3894 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3895 else if (slashp[2] == '/' || slashp[2] == '\0')
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3896 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3897 strcpy (slashp, slashp + 2);
7776
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3898 continue;
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3899 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3900 }
7776
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3901
f91e2cf8770b * etags.c (absolute_filename): Remove infinite loop bug when
Francesco Potortì <pot@gnu.org>
parents: 7775
diff changeset
3902 slashp = etags_strchr (slashp + 1, '/');
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3903 }
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 return res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3906 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3907
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3908 /* 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
3909 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
3910 end with a slash). */
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3911
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3912 char *
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3913 absolute_dirname (file, cwd)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3914 char *file, *cwd;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3915 {
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3916 char *slashp, *res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3917 char save;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3918
6592
9a76406c9f98 * etags.c (main): use etags_getcwd for compatibility.
Francesco Potortì <pot@gnu.org>
parents: 6530
diff changeset
3919 slashp = etags_strrchr (file, '/');
6482
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3920 if (slashp == NULL)
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3921 return cwd;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3922 save = slashp[1];
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3923 slashp[1] = '\0';
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3924 res = absolute_filename (file, cwd);
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3925 slashp[1] = save;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3926
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3927 return res;
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3928 }
91112dd5c9f5 * etags.c (cwd, outfiledir): vars added.
Francesco Potortì <pot@gnu.org>
parents: 5976
diff changeset
3929
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3930 /* Like malloc but get fatal error if memory is exhausted. */
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3931
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3932 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3933 xmalloc (size)
5580
517d8eb361f8 * etags.c (stab_entry, stab_create, stab_find, stab_search,
Francesco Potortì <pot@gnu.org>
parents: 5448
diff changeset
3934 unsigned int size;
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3935 {
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3936 char *result = (char *) malloc (size);
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3937 if (result == NULL)
240
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3938 fatal ("virtual memory exhausted", 0);
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3939 return result;
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3940 }
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3941
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3942 char *
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3943 xrealloc (ptr, size)
939deddfb6b2 Initial revision
Jim Blandy <jimb@redhat.com>
parents:
diff changeset
3944 char *ptr;
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 {
5940
e663f6626075 * etags.c (absolute_pathnames, cwd): added global vars.
Francesco Potortì <pot@gnu.org>
parents: 5580
diff changeset
3947 char *result = (char *) realloc (ptr, size);
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");
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 }