annotate lib-src/etags.c @ 278:90d73dddcdc4 r21-0b37

Import from CVS: tag r21-0b37
author cvs
date Mon, 13 Aug 2007 10:31:29 +0200
parents 6330739388db
children c42ec1d1cded
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Tags file maker to go with GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Free Software Foundation, Inc. and Ken Arnold
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is not considered part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
18 along with this program; if not, write to the Free Software Foundation,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * Authors:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 * Ctags originally by Ken Arnold.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 * Fortran added by Jim Kleckner.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 * Ed Pelegri-Llopart added C typedefs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 * Gnu Emacs TAGS format and modifications by RMS?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 * Sam Kendall added C++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 * Francesco Potorti` reorganised C and C++ based on work by Joe Wells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 * Regexp tags by Tom Tromey.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
34 char pot_etags_version[] = "@(#) pot revision number is 12.28";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
36 /* Prototyping magic snarfed from gmalloc.c */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
37 #if defined (__cplusplus) || defined (__STDC__)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
38 #undef PP
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
39 #define PP(args) args
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
40 #undef __ptr_t
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
41 #define __ptr_t void *
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
42 #else /* Not C++ or ANSI C. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
43 #undef PP
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
44 #define PP(args) ()
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
45 #undef const
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
46 #define const
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
47 #undef __ptr_t
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
48 #define __ptr_t char *
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
49 #endif /* C++ or ANSI C. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
50
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
51 #ifdef HAVE_CONFIG_H
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
52 # include <config.h>
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
53 /* On some systems, Emacs defines static as nothing for the sake
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
54 of unexec. We don't want that here since we don't use unexec. */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
55 # undef static
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
56 # define ETAGS_REGEXPS /* use the regexp features */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
57 # define LONG_OPTIONS /* accept long options */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
58 #endif /* HAVE_CONFIG_H */
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
59
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 #define TRUE 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #define FALSE 0
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
62
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 #ifndef DEBUG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 # define DEBUG FALSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 #ifdef MSDOS
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
68 # include <fcntl.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
69 # include <sys/param.h>
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
70 # include <io.h>
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
71 # ifndef HAVE_CONFIG_H
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
72 # define DOS_NT
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
73 # include <sys/config.h>
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
74 # endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 #endif /* MSDOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 #ifdef WINDOWSNT
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
78 # include <stdlib.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
79 # include <fcntl.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
80 # include <string.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
81 # include <io.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
82 # define MAXPATHLEN _MAX_PATH
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
83 # ifdef HAVE_CONFIG_H
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
84 # undef HAVE_NTGUI
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
85 # else
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
86 # define DOS_NT
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
87 # define HAVE_GETCWD
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
88 # endif /* not HAVE_CONFIG_H */
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
89 #endif /* WINDOWSNT */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
90
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
91 #if !defined (WINDOWSNT) && defined (STDC_HEADERS)
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
92 #include <stdlib.h>
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
93 #include <string.h>
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
94 #endif
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
95
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
96 #ifdef HAVE_UNISTD_H
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
97 # include <unistd.h>
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
98 #else
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
99 # ifdef HAVE_GETCWD
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
100 extern char *getcwd ();
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
101 # endif
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
102 #endif /* HAVE_UNISTD_H */
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
103
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 #include <ctype.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 #include <errno.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 #ifndef errno
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
108 extern int errno;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 #include <sys/types.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 #include <sys/stat.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 #if !defined (S_ISREG) && defined (S_IFREG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
117 #ifdef LONG_OPTIONS
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
118 # include <getopt.h>
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
119 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
120 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
121 extern char *optarg;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
122 extern int optind, opterr;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
123 #endif /* LONG_OPTIONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 #ifdef ETAGS_REGEXPS
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
126 # include <regex.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 /* Define CTAGS to make the program "ctags" compatible with the usual one.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
130 Leave it undefined to make the program "etags", which makes emacs-style
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 tag tables and tags typedefs, #defines and struct/union/enum by default. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 #ifdef CTAGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 # undef CTAGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 # define CTAGS TRUE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 # define CTAGS FALSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 /* Exit codes for success and failure. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 #ifdef VMS
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
141 # define GOOD 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
142 # define BAD 0
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 #else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
144 # define GOOD 0
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
145 # define BAD 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 /* C extensions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 #define C_PLPL 0x00001 /* C++ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 #define C_STAR 0x00003 /* C* */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
151 #define C_JAVA 0x00005 /* JAVA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 #define YACC 0x10000 /* yacc file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
154 #define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
155 && (abort (), 1)) || !strcmp (s, t))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
156 #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
157 && (abort (), 1)) || !strncmp (s, t, n))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
158
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
159 #define lowcase(c) tolower ((char)c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
160
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
161 #define CHARS 256 /* 2^sizeof(char) */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
162 #define CHAR(x) ((unsigned int)x & (CHARS - 1))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
163 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
164 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
165 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
166 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
167 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
169 /*#ifdef INFODOCK*/
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
170 /*#undef OO_BROWSER*/
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
171 /* Due to the way this file is constructed, this unfortunately doesn't */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
172 /* work except for documentation purposes. -slb */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
173 #define OO_BROWSER 1
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
174 /*#endif*/
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
175
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
176 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
177 #define set_construct(construct) \
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
178 if (!oo_browser_construct) oo_browser_construct = construct
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
179 void oo_browser_clear_all_globals();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
180 void oo_browser_clear_some_globals();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
181 void oo_browser_check_and_clear_structtype();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
182 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
185 * xnew, xrnew -- allocate, reallocate storage
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 * SYNOPSIS: Type *xnew (int n, Type);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
188 * Type *xrnew (OldPointer, int n, Type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
190 #ifdef chkmalloc
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
191 # include "chkmalloc.h"
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
192 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
193 (n) * sizeof (Type)))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
194 # define xrnew(op,n,Type) ((Type *) trace_realloc (__FILE__, __LINE__, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
195 (op), (n) * sizeof (Type)))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
196 #else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
197 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
198 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
199 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
201 typedef int bool;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
203 typedef void Lang_function ();
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
204
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
205 typedef struct
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
206 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
207 char *name;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
208 Lang_function *function;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
209 char **suffixes;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
210 char **interpreters;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
211 } language;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
212
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
213 typedef struct node_st
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
214 { /* sorting structure */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 char *name; /* function or type name */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
216 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
217 short int construct; /* Construct type for the OO-Browser */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
218 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 char *file; /* file name */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
220 bool is_func; /* use pattern or line no */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
221 bool been_warned; /* set if noticed dup */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
222 int lno; /* line number tag is on */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 long cno; /* character number line starts on */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 char *pat; /* search pattern */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
225 struct node_st *left, *right; /* left and right sons */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
226 } node;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
227
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
228 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
229 /* If you add to this array, you must add a corresponding entry to the
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
230 following enum. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
231 static char *oo_browser_default_classes[] =
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
232 /* Lack of square brackets around some of these entries are intentional. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
233 {"null", "class", "method", "[constant]", "[enumeration]", "[enum_label]",
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
234 "extern", "[function]", "[macro]", "objc", "[structure]", "[type]",
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
235 "[union]", "[variable]"};
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
236
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
237 /* If you add to this enum, you must add a corresponding entry to the
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
238 preceding array. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
239 enum oo_browser_constructs {C_NULL, C_CLASS, C_METHOD, C_CONSTANT, C_ENUMERATION,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
240 C_ENUM_LABEL, C_EXTERN, C_FUNCTION, C_MACRO,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
241 C_OBJC, C_STRUCTURE, C_TYPE, C_UNION, C_VARIABLE};
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
242
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
243 enum oo_browser_constructs oo_browser_construct = C_NULL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
244 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
245
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
246 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
247 * A `linebuffer' is a structure which holds a line of text.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
248 * `readline_internal' reads a line from a stream into a linebuffer
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
249 * and works regardless of the length of the line.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
250 * SIZE is the size of BUFFER, LEN is the length of the string in
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
251 * BUFFER after readline reads it.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
252 */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
253 typedef struct
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
254 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
255 long size;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
256 int len;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
257 char *buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
258 } linebuffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
259
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
260 extern char *getenv PP ((const char *envvar));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
261
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
262 /* Many compilers barf on this:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
263 Lang_function Asm_labels;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
264 so let's write it this way */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
265 void Asm_labels PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
266 void C_entries PP ((int c_ext, FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
267 void default_C_entries PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
268 void plain_C_entries PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
269 void Cjava_entries PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
270 void Cplusplus_entries PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
271 void Yacc_entries PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
272 void Cobol_paragraphs PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
273 void Cstar_entries PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
274 void Erlang_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
275 void Fortran_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
276 void Lisp_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
277 void Pascal_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
278 void Perl_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
279 void Postscript_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
280 void Prolog_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
281 void Python_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
282 void Scheme_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
283 void TeX_functions PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
284 void just_read_file PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
285
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
286 void print_language_names PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
287 void print_version PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
288 void print_help PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
289
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
290 language *get_language_from_name PP ((char *name));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
291 language *get_language_from_interpreter PP ((char *interpreter));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
292 language *get_language_from_suffix PP ((char *suffix));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
293 int total_size_of_entries PP ((node *np));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
294 long readline PP ((linebuffer *lbp, FILE *stream));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
295 long readline_internal PP ((linebuffer *lbp, FILE *stream));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 #ifdef ETAGS_REGEXPS
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
297 void analyse_regex PP ((char *regex_arg));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
298 void add_regex PP ((char *regexp_pattern, language *lang));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
299 void free_patterns PP ((void));
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
300 #endif /* ETAGS_REGEXPS */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
301 void error PP ((const char *s1, const char *s2));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
302 void suggest_asking_for_help PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
303 void fatal PP ((char *s1, char *s2));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
304 void pfatal PP ((char *s1));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
305 void add_node PP ((node *np, node **cur_node_p));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
306
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
307 void init PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
308 void initbuffer PP ((linebuffer *lbp));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
309 void find_entries PP ((char *file, FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
310 void free_tree PP ((node *np));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
311 void pfnote PP ((char *name, bool is_func, char *linestart, int linelen, int lno, long cno));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
312 void new_pfnote PP ((char *name, int namelen, bool is_func, char *linestart, int linelen, int lno, long cno));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
313 void process_file PP ((char *file));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
314 void put_entries PP ((node *np));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
315 void takeprec PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
316
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
317 char *concat PP ((char *s1, char *s2, char *s3));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
318 char *skip_spaces PP ((char *cp));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
319 char *skip_non_spaces PP ((char *cp));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
320 char *savenstr PP ((char *cp, int len));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
321 char *savestr PP ((char *cp));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
322 char *etags_strchr PP ((char *sp, int c));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
323 char *etags_strrchr PP ((char *sp, int c));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
324 char *etags_getcwd PP ((void));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
325 char *relative_filename PP ((char *file, char *dir));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
326 char *absolute_filename PP ((char *file, char *dir));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
327 char *absolute_dirname PP ((char *file, char *dir));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
328 bool filename_is_absolute PP ((char *fn));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
329 void canonicalize_filename PP ((char *fn));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
330 void grow_linebuffer PP ((linebuffer *lbp, int toksize));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
331 long *xmalloc PP ((unsigned int size));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
332 long *xrealloc PP ((char *ptr, unsigned int size));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 char searchar = '/'; /* use /.../ searches */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 char *tagfile; /* output file */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
338 char *progname; /* name this program was invoked with */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 char *cwd; /* current working directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 char *tagfiledir; /* directory of tagfile */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 FILE *tagf; /* ioptr for tags file */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
342
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
343 char *curfile; /* current input file name */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
344 language *curlang; /* current language */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
345
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
346 int lineno; /* line number of current line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
347 long charno; /* current character number */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
348 long linecharno; /* charno of start of current line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
349 char *dbp; /* pointer to start of current tag */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
350 node *head; /* the head of the binary tree of tags */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
351
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
352 linebuffer lb; /* the current line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
353 linebuffer token_name; /* used by C_entries as a temporary area */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 long linepos;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
357 linebuffer lb; /* used by C_entries instead of lb */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 } lbs[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 /* boolean "functions" (see init) */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
361 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
362 char
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
363 /* white chars */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
364 *white = " \f\t\n\r",
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
365 /* not in a name */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
366 *nonam = " \f\t\n\r(=,[;",
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
367 /* token ending chars */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
368 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
369 /* token starting chars */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
370 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
371 /* valid in-token chars */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
372 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
374 bool append_to_tagfile; /* -a: append to tags */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
375 /* The following four default to TRUE for etags, but to FALSE for ctags. */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
376 bool typedefs; /* -t: create tags for C typedefs */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
377 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 /* 0 struct/enum/union decls, and C++ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 /* member functions. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
380 bool constantypedefs; /* -d: create tags for C #define, enum */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
381 /* constants and variables. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 /* -D: opposite of -d. Default under ctags. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
383 bool globals; /* create tags for global variables */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
384 bool members; /* create tags for C member variables */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
385 bool update; /* -u: update tags */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
386 bool vgrind_style; /* -v: create vgrind style index output */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
387 bool no_warnings; /* -w: suppress warnings */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
388 bool cxref_style; /* -x: create cxref style output */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
389 bool cplusplus; /* .[hc] means C++, not C */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
390 bool noindentypedefs; /* -I: ignore indentation in C */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
391 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
392 bool oo_browser_format; /* -O: OO-Browser tags format */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
393 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
394
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
395 #ifdef LONG_OPTIONS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 struct option longopts[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
398 { "append", no_argument, NULL, 'a' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
399 { "backward-search", no_argument, NULL, 'B' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
400 { "c++", no_argument, NULL, 'C' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
401 { "cxref", no_argument, NULL, 'x' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
402 { "defines", no_argument, NULL, 'd' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
403 { "no-defines", no_argument, NULL, 'D' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
404 { "globals", no_argument, &globals, TRUE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
405 { "no-globals", no_argument, &globals, FALSE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
406 { "help", no_argument, NULL, 'h' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
407 { "help", no_argument, NULL, 'H' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
408 { "ignore-indentation", no_argument, NULL, 'I' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
409 { "include", required_argument, NULL, 'i' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
410 { "language", required_argument, NULL, 'l' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
411 { "members", no_argument, &members, TRUE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
412 { "no-members", no_argument, &members, FALSE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
413 { "no-warn", no_argument, NULL, 'w' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
414 { "output", required_argument, NULL, 'o' },
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
415 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
416 { "oo-browser", no_argument, NULL, 'O' },
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
417 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
418 #ifdef ETAGS_REGEXPS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
419 { "regex", required_argument, NULL, 'r' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
420 { "no-regex", no_argument, NULL, 'R' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
421 #endif /* ETAGS_REGEXPS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
422 { "typedefs", no_argument, NULL, 't' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
423 { "typedefs-and-c++", no_argument, NULL, 'T' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
424 { "update", no_argument, NULL, 'u' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
425 { "version", no_argument, NULL, 'V' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
426 { "vgrind", no_argument, NULL, 'v' },
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 { 0 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 };
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
429 #endif /* LONG_OPTIONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 /* Structure defining a regular expression. Elements are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 the compiled pattern, and the name string. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
434 typedef struct pattern
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
436 struct pattern *p_next;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
437 language *language;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
438 char *regex;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 struct re_pattern_buffer *pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 struct re_registers regs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 char *name_pattern;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
442 bool error_signaled;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
443 } pattern;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 /* Array of all regexps. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
446 pattern *p_head = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 * Language stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 /* Non-NULL if language fixed. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
454 language *forced_lang = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 /* Assembly code */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
457 char *Asm_suffixes [] = { "a", /* Unix assembler */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 "asm", /* Microcontroller assembly */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "def", /* BSO/Tasking definition includes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 "inc", /* Microcontroller include files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 "ins", /* Microcontroller include files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "s", "sa", /* Unix assembler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 "src", /* BSO/Tasking C compiler output */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 /* Note that .c and .h can be considered C++, if the --c++ flag was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 given. That is why default_C_entries is called here. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
469 char *default_C_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 { "c", "h", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
472 char *Cplusplus_suffixes [] =
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
473 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
474 "M", /* Objective C++ */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
475 "pdb", /* Postscript with C syntax */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
476 NULL };
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
477
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
478 char *Cjava_suffixes [] =
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
479 { "java", NULL };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
480
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
481 char *Cobol_suffixes [] =
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
482 { "COB", "cob", NULL };
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
483
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
484 char *Cstar_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 { "cs", "hs", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
487 char *Erlang_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
488 { "erl", "hrl", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
489
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
490 char *Fortran_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 { "F", "f", "f90", "for", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
493 char *Lisp_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
496 char *Pascal_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 { "p", "pas", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
499 char *Perl_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 { "pl", "pm", NULL };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
501 char *Perl_interpreters [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
502 { "perl", "@PERL@", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
503
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
504 char *plain_C_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
505 { "pc", /* Pro*C file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
506 "m", /* Objective C file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
507 "lm", /* Objective lex file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
508 NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
509
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
510 char *Postscript_suffixes [] =
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
511 { "ps", NULL };
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
512
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
513 char *Prolog_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 { "prolog", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
516 char *Python_suffixes [] =
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
517 { "py", NULL };
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
518
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
519 /* Can't do the `SCM' or `scm' prefix with a version number. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
520 char *Scheme_suffixes [] =
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
521 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "ss", "t", NULL };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
523 char *TeX_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
524 { "TeX", "bib", "clo", "cls", "ltx", "sty", "tex", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
525
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
526 char *Yacc_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
527 { "y", "ym", NULL }; /* .ym is Objective yacc file */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
529 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
530 * Table of languages.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
531 *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
532 * It is ok for a given function to be listed under more than one
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
533 * name. I just didn't.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
534 */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
535
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
536 language lang_names [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
538 { "asm", Asm_labels, Asm_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
539 { "c", default_C_entries, default_C_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
540 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
541 { "c*", Cstar_entries, Cstar_suffixes, NULL },
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
542 { "cobol", Cobol_paragraphs, Cobol_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
543 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
544 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
545 { "java", Cjava_entries, Cjava_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
546 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
547 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
548 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
549 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
550 { "proc", plain_C_entries, plain_C_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
551 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
552 { "python", Python_functions, Python_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
553 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
554 { "tex", TeX_functions, TeX_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
555 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
556 { "auto", NULL }, /* default guessing scheme */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
557 { "none", just_read_file }, /* regexp matching only */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
558 { NULL, NULL } /* end of list */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
562 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
563 print_language_names ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
565 language *lang;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
566 char **ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 puts ("\nThese are the currently supported languages, along with the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 default file name suffixes:");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 printf ("\t%s\t", lang->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 if (lang->suffixes != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 for (ext = lang->suffixes; *ext != NULL; ext++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 printf (" .%s", *ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 puts ("");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 puts ("Where `auto' means use default language for files based on file\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 name suffix, and `none' means only do regexp processing on files.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 If no language is specified and no matching suffix is found,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 the first line of the file is read for a sharp-bang (#!) sequence\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 followed by the name of an interpreter. If no such sequence is found,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 Fortran is tried first; if no tags are found, C is tried next.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 #ifndef VERSION
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
587 # define VERSION "20"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
589 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
590 print_version ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
592 printf ("%s (GNU Emacs %s)\n", (CTAGS) ? "ctags" : "etags", VERSION);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
593 puts ("Copyright (C) 1996 Free Software Foundation, Inc. and Ken Arnold");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
594 puts ("This program is distributed under the same terms as Emacs");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
599 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
600 print_help ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
602 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
603 \n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
604 These are the options accepted by %s.\n", progname, progname);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
605 #ifdef LONG_OPTIONS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
606 puts ("You may use unambiguous abbreviations for the long option names.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
607 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
608 puts ("Long option names do not work with this executable, as it is not\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
609 linked with GNU getopt.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
610 #endif /* LONG_OPTIONS */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
611 puts ("A - as file name means read names from stdin (one per line).");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
612 if (!CTAGS)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
613 printf (" Absolute names are stored in the output file as they are.\n\
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
614 Relative ones are stored relative to the output file's directory.");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
615 puts ("\n");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 puts ("-a, --append\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 Append tag entries to existing tags file.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 puts ("-B, --backward-search\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 Write the search commands for the tag entries using '?', the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 backward-search command instead of '/', the forward-search command.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 puts ("-C, --c++\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 Treat files whose name suffix defaults to C language as C++ files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 puts ("-d, --defines\n\
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
630 Create tag entries for C #define constants and enum constants, too.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 puts ("-D, --no-defines\n\
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
633 Don't create tag entries for C #define constants and enum constants.\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
634 This makes the tags file smaller.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 puts ("-i FILE, --include=FILE\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 Include a note in tag file indicating that, when searching for\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 a tag, one should also consult the tags file FILE after\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 checking the current file.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 puts ("-l LANG, --language=LANG\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 Force the following files to be considered as written in the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 named language up to the next --language=LANG option.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
647 if (CTAGS)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
648 puts ("--globals\n\
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
649 Create tag entries for global variables in some languages.");
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
650 else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
651 puts ("--no-globals\n\
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
652 Do not create tag entries for global variables in some\n\
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
653 languages. This makes the tags file smaller.");
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
654 puts ("--members\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
655 Create tag entries for member variables in C and derived languages.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
656
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 #ifdef ETAGS_REGEXPS
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
658 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 Make a tag for each line matching pattern REGEXP in the\n\
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
660 following files. regexfile is a file containing one REGEXP\n\
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
661 per line. REGEXP is anchored (as if preceded by ^).\n\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 named tags can be created with:\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 puts ("-R, --no-regex\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 Don't create tags from regexps for the following files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 puts ("-o FILE, --output=FILE\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 Write the tags to FILE.");
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
670 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
671 puts ("-O, --oo-browser\n\
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
672 Generate a specialized tags format used only by the Altrasoft OO-Browser.");
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
673 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 puts ("-I, --ignore-indentation\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 Don't rely on indentation quite as much as normal. Currently,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 this means not to assume that a closing brace in the first\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 column is the final brace of a function or structure\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 definition in C and C++.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 puts ("-t, --typedefs\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 Generate tag entries for C typedefs.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 puts ("-T, --typedefs-and-c++\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 and C++ member functions.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 puts ("-u, --update\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 Update the tag entries for the given files, leaving tag\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 entries for other files in place. Currently, this is\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 implemented by deleting the existing entries for the given\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 files and then rewriting the new entries at the end of the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 tags file. It is often faster to simply rebuild the entire\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 tag file than to use this.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 puts ("-v, --vgrind\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 Generates an index of items intended for human consumption,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 similar to the output of vgrind. The index is sorted, and\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 gives the page number of each item.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 puts ("-w, --no-warn\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 Suppress warning messages about entries defined in multiple\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 puts ("-x, --cxref\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 The output uses line numbers instead of page numbers, but\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 beyond that the differences are cosmetic; try both to see\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 which you like.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 puts ("-V, --version\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 Print the version of the program.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 -h, --help\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 Print this help message.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 print_language_names ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
715 puts ("");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
716 puts ("Report bugs to bug-gnu-emacs@prep.ai.mit.edu");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
717
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 enum argument_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 at_language,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 at_regexp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 at_filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
729 /* This structure helps us allow mixing of --lang and file names. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 typedef struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 enum argument_type arg_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 char *what;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
734 language *lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 } argument;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 #ifdef VMS /* VMS specific functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 #define EOS '\0'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 /* This is a BUG! ANY arbitrary limit is a BUG!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 Won't someone please fix this? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 #define MAX_FILE_SPEC_LEN 255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 typedef struct {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 short curlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 char body[MAX_FILE_SPEC_LEN + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 } vspec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
751 returning in each successive call the next file name matching the input
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 spec. The function expects that each in_spec passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 to it will be processed to completion; in particular, up to and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 including the call following that in which the last matching name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 is returned, the function ignores the value of in_spec, and will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 only start processing a new spec with the following call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 If an error occurs, on return out_spec contains the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 of in_spec when the error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
760 With each successive file name returned in out_spec, the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 function's return value is one. When there are no more matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 names the function returns zero. If on the first call no file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 matches in_spec, or there is any other error, -1 is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 #include <rmsdef.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 #include <descrip.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 #define OUTSIZE MAX_FILE_SPEC_LEN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 short
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
770 fn_exp (out, in)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
771 vspec *out;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
772 char *in;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 static long context = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 static struct dsc$descriptor_s o;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 static struct dsc$descriptor_s i;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
777 static bool pass1 = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 short retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 if (pass1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 pass1 = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 o.dsc$a_pointer = (char *) out;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 o.dsc$w_length = (short)OUTSIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 i.dsc$a_pointer = in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 i.dsc$w_length = (short)strlen(in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 i.dsc$b_dtype = DSC$K_DTYPE_T;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 i.dsc$b_class = DSC$K_CLASS_S;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 o.dsc$b_dtype = DSC$K_DTYPE_VT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 o.dsc$b_class = DSC$K_CLASS_VS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 out->body[out->curlen] = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 else if (status == RMS$_NMF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 strcpy(out->body, in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 retval = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 lib$find_file_end(&context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 pass1 = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 name of each file specified by the provided arg expanding wildcards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
815 gfnames (arg, p_error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
816 char *arg;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
817 bool *p_error;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 switch (fn_exp (&filename, arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 case 1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 *p_error = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 return filename.body;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 *p_error = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 *p_error = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 return filename.body;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 #ifndef OLD /* Newer versions of VMS do provide `system'. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
836 system (cmd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
837 char *cmd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
839 error ("%s", "system() function not implemented under VMS");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 #define VERSION_DELIM ';'
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
844 char *massage_name (s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
845 char *s;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 char *start = s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 for ( ; *s; s++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 if (*s == VERSION_DELIM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 *s = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 *s = lowcase (*s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 return start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 #endif /* VMS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
862 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
863 main (argc, argv)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
864 int argc;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
865 char *argv[];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 int i;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
868 unsigned int nincluded_files;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
869 char **included_files;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 char *this_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 argument *argbuffer;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
872 int current_arg, file_count;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
873 linebuffer filename_lb;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 #ifdef VMS
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
875 bool got_err;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 #ifdef DOS_NT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 _fmode = O_BINARY; /* all of files are treated as binary files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 #endif /* DOS_NT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 progname = argv[0];
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
883 nincluded_files = 0;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
884 included_files = xnew (argc, char *);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
885 current_arg = 0;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
886 file_count = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 /* Allocate enough no matter what happens. Overkill, but each one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 is small. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 argbuffer = xnew (argc, argument);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 /* Set syntax for regular expression routines. */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
894 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 * If etags, always find typedefs and structure tags. Why not?
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
899 * Also default is to find macro constants, enum constants and
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
900 * global variables.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 if (!CTAGS)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
903 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
904 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
905 globals = TRUE;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
906 members = FALSE;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
907 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
911 int opt;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
912 char *optstring;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
913
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
914 #ifdef ETAGS_REGEXPS
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
915 #ifndef OO_BROWSER
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
916 optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH";
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
917 #else
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
918 optstring = "-aCdDf:Il:o:r:RStTi:BOuvxwVhH";
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
919 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
920 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
921 #ifndef OO_BROWSER
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
922 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
923 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
924 optstring = "-aCdDf:Il:o:StTi:BOuvxwVhH";
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
925 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
926 #endif /* ETAGS_REGEXPS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
927
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
928 #ifndef LONG_OPTIONS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
929 optstring = optstring + 1;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
930 #endif /* LONG_OPTIONS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
931
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
932 opt = getopt_long (argc, argv, optstring, longopts, 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 if (opt == EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 switch (opt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 /* If getopt returns 0, then it has already processed a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 long-named option. We should do nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 case 1:
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
944 /* This means that a file name has been seen. Record it. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 argbuffer[current_arg].arg_type = at_filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 argbuffer[current_arg].what = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 ++file_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 /* Common options. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
952 case 'a': append_to_tagfile = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
953 case 'C': cplusplus = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
954 case 'd': constantypedefs = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
955 case 'D': constantypedefs = FALSE; break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 case 'f': /* for compatibility with old makefiles */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 case 'o':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 if (tagfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
960 /* convert char to string, to call error with */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
961 char buf[2];
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
962 sprintf (buf, "%c", opt);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
963 error ("-%s option may only be given once.", buf);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
964 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 tagfile = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 break;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
968 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
969 case 'O':
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
970 oo_browser_format = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
971 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
972 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 case 'I':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 case 'S': /* for backward compatibility */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 noindentypedefs = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 case 'l':
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
978 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
979 language *lang = get_language_from_name (optarg);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
980 if (lang != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
981 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
982 argbuffer[current_arg].lang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
983 argbuffer[current_arg].arg_type = at_language;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
984 ++current_arg;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
985 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
986 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 case 'r':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 argbuffer[current_arg].arg_type = at_regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 argbuffer[current_arg].what = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 case 'R':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 argbuffer[current_arg].arg_type = at_regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 argbuffer[current_arg].what = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 case 'V':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 print_version ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 case 'h':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 case 'H':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 print_help ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 case 't':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 typedefs = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 case 'T':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 typedefs = typedefs_and_cplusplus = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 #if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 /* Etags options */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 included_files[nincluded_files++] = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 #else /* CTAGS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 /* Ctags options. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1020 case 'B': searchar = '?'; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1021 case 'u': update = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1022 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1023 case 'x': cxref_style = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1024 case 'w': no_warnings = TRUE; break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 #endif /* CTAGS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 default:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1027 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 for (; optind < argc; ++optind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 argbuffer[current_arg].arg_type = at_filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 argbuffer[current_arg].what = argv[optind];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 ++file_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 if (nincluded_files == 0 && file_count == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1041 error ("no input files specified.", 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1042 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 if (tagfile == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1046 tagfile = CTAGS ? "tags" : "TAGS";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 cwd = etags_getcwd (); /* the current working directory */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1048 if (cwd[strlen (cwd) - 1] != '/')
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1049 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1050 char *oldcwd = cwd;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1051 cwd = concat (oldcwd, "/", "");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1052 free (oldcwd);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1053 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 if (streq (tagfile, "-"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1055 tagfiledir = cwd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1057 tagfiledir = absolute_dirname (tagfile, cwd);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 init (); /* set up boolean "functions" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 initbuffer (&lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 initbuffer (&token_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 initbuffer (&lbs[0].lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 initbuffer (&lbs[1].lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 initbuffer (&filename_lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 if (streq (tagfile, "-"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1070 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1071 tagf = stdout;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1072 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1073 /* Switch redirected `stdout' to binary mode (setting `_fmode'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1074 doesn't take effect until after `stdout' is already open). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1075 if (!isatty (fileno (stdout)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1076 setmode (fileno (stdout), O_BINARY);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1077 #endif /* DOS_NT */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1078 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 if (tagf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 pfatal (tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 * Loop through files finding functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 for (i = 0; i < current_arg; ++i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 switch (argbuffer[i].arg_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 case at_language:
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1093 forced_lang = argbuffer[i].lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 case at_regexp:
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1097 analyse_regex (argbuffer[i].what);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 case at_filename:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 if (got_err)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1106 error ("can't find file %s\n", this_file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 argc--, argv++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 this_file = massage_name (this_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 this_file = argbuffer[i].what;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 #endif
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1116 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1117 oo_browser_clear_all_globals();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1118 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 /* Input file named "-" means read file names from stdin
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1120 (one per line) and use them. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 if (streq (this_file, "-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 while (readline_internal (&filename_lb, stdin) > 0)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1123 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1124 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1125 oo_browser_clear_some_globals();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1126 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 process_file (filename_lb.buffer);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1128 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1129 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1130 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 process_file (this_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1140 #ifdef ETAGS_REGEXPS
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1141 free_patterns ();
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1142 #endif /* ETAGS_REGEXPS */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1143
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 while (nincluded_files-- > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 fprintf (tagf, "\f\n%s,include\n", *included_files++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 fclose (tagf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 /* If CTAGS, we are here. process_file did not write the tags yet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 because we want them ordered. Let's do it now. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 if (cxref_style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 if (update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 char cmd[BUFSIZ];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 for (i = 0; i < current_arg; ++i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 if (argbuffer[i].arg_type != at_filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 sprintf (cmd,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 tagfile, argbuffer[i].what, tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 if (system (cmd) != GOOD)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1172 fatal ("failed to execute shell command", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 append_to_tagfile = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 if (tagf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 pfatal (tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 fclose (tagf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 if (update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 char cmd[BUFSIZ];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 exit (system (cmd));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1189 return GOOD;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1194 * Return a language given the name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1196 language *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1197 get_language_from_name (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1198 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1200 language *lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1202 if (name == NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1203 error ("empty language name", (char *)NULL);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1204 else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1205 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1206 for (lang = lang_names; lang->name != NULL; lang++)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1207 if (streq (name, lang->name))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1208 return lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1209 error ("unknown language \"%s\"", name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1210 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1211
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1212 return NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1217 * Return a language given the interpreter name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1219 language *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1220 get_language_from_interpreter (interpreter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1221 char *interpreter;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1223 language *lang;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1224 char **iname;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 if (interpreter == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 if (lang->interpreters != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 for (iname = lang->interpreters; *iname != NULL; iname++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 if (streq (*iname, interpreter))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1232 return lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1240 * Return a language given the file suffix.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1242 language *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1243 get_language_from_suffix (suffix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1244 char *suffix;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1246 language *lang;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1247 char **ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 if (suffix == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 if (lang->suffixes != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 for (ext = lang->suffixes; *ext != NULL; ext++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 if (streq (*ext, suffix))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1255 return lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 * This routine is called on each file argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1265 process_file (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1266 char *file;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 struct stat stat_buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 FILE *inf;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1270
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1271 canonicalize_filename (file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1274 error ("skipping %s: it is not a regular file.", file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 if (streq (file, tagfile) && !streq (tagfile, "-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1279 error ("skipping inclusion of %s in self.", file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 inf = fopen (file, "r");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 if (inf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 perror (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 find_entries (file, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 char *filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1295 if (filename_is_absolute (file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 {
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
1297 /* file is an absolute file name. Canonicalise it. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 filename = absolute_filename (file, cwd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 {
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
1302 /* file is a file name relative to cwd. Make it relative
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 to the directory of the tags file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 filename = relative_filename (file, tagfiledir);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 }
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1306 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1307 if (oo_browser_format)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1308 fprintf (tagf, "\f\n%s\n", filename);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1309 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1310 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 free (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 free_tree (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 head = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 * This routine sets up the boolean pseudo-functions which work
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1321 * by setting boolean flags dependent upon the corresponding character.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 * Every char which is NOT in that string is not a white char. Therefore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 * all of the array "_wht" is set to FALSE, and then the elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 * of a char is TRUE if it is the string "white", else FALSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1328 init ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1330 register char *sp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 register int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1333 for (i = 0; i < CHARS; i++)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1334 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1335 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1336 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1337 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1338 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1339 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1340 iswhite('\0') = iswhite('\n');
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1341 notinname('\0') = notinname('\n');
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1342 begtoken('\0') = begtoken('\n');
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1343 intoken('\0') = intoken('\n');
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1344 endtoken('\0') = endtoken('\n');
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 * This routine opens the specified file and calls the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 * which finds the function and type definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1351 node *last_node = NULL;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1352
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1354 find_entries (file, inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1355 char *file;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1356 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 char *cp;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1359 language *lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1360 node *old_last_node;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1361
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 curfile = savestr (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 /* If user specified a language, use it. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1365 lang = forced_lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1366 if (lang != NULL && lang->function != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1368 curlang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1369 lang->function (inf);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1370 free (curfile);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 cp = etags_strrchr (file, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 if (cp != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 cp += 1;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1379 lang = get_language_from_suffix (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1380 if (lang != NULL && lang->function != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1382 curlang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1383 lang->function (inf);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1384 free (curfile);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 /* Look for sharp-bang as the first two characters. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1391 if (readline_internal (&lb, inf) > 0
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
1392 && lb.len >= 2
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 && lb.buffer[0] == '#'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 && lb.buffer[1] == '!')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 char *lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 /* Set lp to point at the first char after the last slash in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 line or, if no slashes, at the first nonblank. Then set cp to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 the first successive blank and terminate the string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 lp = etags_strrchr (lb.buffer+2, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 if (lp != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 lp += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1405 lp = skip_spaces (lb.buffer + 2);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1406 cp = skip_non_spaces (lp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 *cp = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1409 if (strlen (lp) > 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1411 lang = get_language_from_interpreter (lp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1412 if (lang != NULL && lang->function != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1414 curlang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1415 lang->function (inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 fclose (inf);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1417 free (curfile);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 /* Try Fortran. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 old_last_node = last_node;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1426 curlang = get_language_from_name ("fortran");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 Fortran_functions (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 /* No Fortran entries found. Try C. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 if (old_last_node == last_node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 rewind (inf);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1433 curlang = get_language_from_name (cplusplus ? "c++" : "c");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 default_C_entries (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1436 free (curfile);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 /* Record a tag. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1442 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1443 pfnote (name, is_func, linestart, linelen, lno, cno)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1444 char *name; /* tag name, or NULL if unnamed */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1445 bool is_func; /* tag is a function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 char *linestart; /* start of the line where tag is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 int linelen; /* length of the line where tag is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 int lno; /* line number */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 long cno; /* character number */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1451 register node *np;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1452
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1453 if (CTAGS && name == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1454 return;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1455
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1456 np = xnew (1, node);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 /* If ctags mode, change name "main" to M<thisfilename>. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 if (CTAGS && !cxref_style && streq (name, "main"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 register char *fp = etags_strrchr (curfile, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 np->name = concat ("M", fp == 0 ? curfile : fp + 1, "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 fp = etags_strrchr (np->name, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 if (fp && fp[1] != '\0' && fp[2] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 fp[0] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 np->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 np->been_warned = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 np->file = curfile;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 np->is_func = is_func;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 np->lno = lno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 /* Our char numbers are 0-base, because of C language tradition?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 ctags compatibility? old versions compatibility? I don't know.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1475 Anyway, since emacs's are 1-base we expect etags.el to take care
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 of the difference. If we wanted to have 1-based numbers, we would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 uncomment the +1 below. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 np->cno = cno /* + 1 */ ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 np->left = np->right = NULL;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1480 if (CTAGS && !cxref_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1481 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1482 if (strlen (linestart) < 50)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1483 np->pat = concat (linestart, "$", "");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1484 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1485 np->pat = savenstr (linestart, 50);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1486 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1487 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1488 np->pat = savenstr (linestart, linelen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1490 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1491 if (oo_browser_format)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1492 np->construct = oo_browser_construct;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1493 oo_browser_construct = C_NULL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1494 oo_browser_check_and_clear_structtype();
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1495 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1496
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 add_node (np, &head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1500 /* Date: Wed, 22 Jan 1997 02:56:31 -0500 [last amended 18 Sep 1997]
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1501 * From: Sam Kendall <kendall@mv.mv.com>
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1502 * Subject: Proposal for firming up the TAGS format specification
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1503 * To: F.Potorti@cnuce.cnr.it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1504 *
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1505 * pfnote should emit the optimized form [unnamed tag] only if:
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1506 * 1. name does not contain any of the characters " \t\r\n(),;";
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1507 * 2. linestart contains name as either a rightmost, or rightmost but
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1508 * one character, substring;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1509 * 3. the character, if any, immediately before name in linestart must
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1510 * be one of the characters " \t(),;";
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1511 * 4. the character, if any, immediately after name in linestart must
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1512 * also be one of the characters " \t(),;".
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1513 *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1514 * The real implementation uses the notinname() macro, which recognises
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1515 * characters slightly different form " \t\r\n(),;". See the variable
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1516 * `nonam'.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1517 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1518 #define traditional_tag_style TRUE
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1519 void
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1520 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1521 char *name; /* tag name, or NULL if unnamed */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1522 int namelen; /* tag length */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1523 bool is_func; /* tag is a function */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1524 char *linestart; /* start of the line where tag is */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1525 int linelen; /* length of the line where tag is */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1526 int lno; /* line number */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1527 long cno; /* character number */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1528 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1529 register char *cp;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1530 bool named;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1531
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1532 named = TRUE;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1533 if (!CTAGS)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1534 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1535 for (cp = name; !notinname (*cp); cp++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1536 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1537 if (*cp == '\0') /* rule #1 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1538 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1539 cp = linestart + linelen - namelen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1540 if (notinname (linestart[linelen-1]))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1541 cp -= 1; /* rule #4 */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1542 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1543 if (!oo_browser_format
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1544 && cp >= linestart /* rule #2 */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1545 #else
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1546 if (cp >= linestart /* rule #2 */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1547 #endif
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1548 && (cp == linestart
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1549 || notinname (cp[-1])) /* rule #3 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1550 && strneq (name, cp, namelen)) /* rule #2 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1551 named = FALSE; /* use unnamed tag */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1552 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1553 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1554
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1555 if (named)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1556 name = savenstr (name, namelen);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1557 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1558 name = NULL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1559 pfnote (name, is_func, linestart, linelen, lno, cno);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1560 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1561
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 * free_tree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 * recurse on left children, iterate on right children.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1567 free_tree (np)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1568 register node *np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1570 while (np)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1572 register node *node_right = np->right;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1573 free_tree (np->left);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1574 if (np->name != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1575 free (np->name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1576 free (np->pat);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1577 free (np);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1578 np = node_right;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 * add_node ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 * Adds a node to the tree of nodes. In etags mode, we don't keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 * it sorted; we just keep a linear list. In ctags mode, maintain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 * an ordered tree, with no attempt at balancing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 * add_node is the only function allowed to add nodes, so it can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 * maintain state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1592 add_node (np, cur_node_p)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1593 node *np, **cur_node_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 register int dif;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1596 register node *cur_node = *cur_node_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 if (cur_node == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1600 *cur_node_p = np;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1601 last_node = np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 /* Etags Mode */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 if (last_node == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1609 fatal ("internal error in add_node", (char *)NULL);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1610 last_node->right = np;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1611 last_node = np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 /* Ctags Mode */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1616 dif = strcmp (np->name, cur_node->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 * If this tag name matches an existing one, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 * do not add the node, but maybe print a warning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 if (!dif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1624 if (streq (np->file, cur_node->file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 if (!no_warnings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1629 np->file, lineno, np->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 fprintf (stderr, "Second entry ignored\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 else if (!cur_node->been_warned && !no_warnings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 fprintf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 (stderr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 "Duplicate entry in files %s and %s: %s (Warning only)\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1638 np->file, cur_node->file, np->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 cur_node->been_warned = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 /* Actually add the node */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1645 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1649 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1650 /* Default class name for the current OO-Browser tag. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1651 static char *oo_browser_class;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1652 /* Prefix character to use in OO-Browser listings for the current tag. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1653 static char oo_browser_prefix;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1654 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1655
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1657 put_entries (np)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1658 register node *np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 register char *sp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1662 if (np == NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 /* Output subentries that precede this one */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1666 put_entries (np->left);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 /* Output this entry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1672 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1673 if (oo_browser_format)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1674 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1675 /* Omit C++ `class' and `method' entries as well as Objective-C
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1676 entries from this OO-Browser tags file since the browser handles
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1677 them independently of this file. Omit `extern' variable declarations
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1678 as they are unused by the OO-Browser. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1679 if (np->construct != C_CLASS
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1680 && np->construct != C_METHOD
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1681 && np->construct != C_EXTERN
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1682 && np->construct != C_OBJC)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1683 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1684 oo_browser_class = oo_browser_default_classes[np->construct];
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1685 switch (np->construct)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1686 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1687 case C_CONSTANT:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1688 case C_ENUMERATION:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1689 case C_ENUM_LABEL:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1690 case C_STRUCTURE:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1691 case C_TYPE:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1692 case C_UNION:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1693 case C_VARIABLE:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1694 oo_browser_prefix = '=';
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1695 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1696 case C_FUNCTION:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1697 case C_MACRO:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1698 oo_browser_prefix = '-';
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1699 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1700 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1701 if (np->name != NULL)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1702 fprintf (tagf, "%s@%c %s@%s\n",
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1703 oo_browser_class, oo_browser_prefix,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1704 np->name, np->pat);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1705 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1706 fprintf (tagf, "%s@%c ???@%s\n",
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1707 oo_browser_class, oo_browser_prefix, np->pat);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1708 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1709 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1710 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1711 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1712 #endif
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1713 if (np->name != NULL)
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1714 fprintf (tagf, "%s\177%s\001%d,%ld\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1715 np->pat, np->name, np->lno, np->cno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 else
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1717 fprintf (tagf, "%s\177%d,%ld\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1718 np->pat, np->lno, np->cno);
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1719 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1720 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1721 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1723 else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1725 if (np->name == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1726 error ("internal error: NULL name in ctags mode.", (char *)NULL);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1727
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1728 if (cxref_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1729 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1730 if (vgrind_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1731 fprintf (stdout, "%s %s %d\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1732 np->name, np->file, (np->lno + 63) / 64);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1733 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1734 fprintf (stdout, "%-16s %3d %-16s %s\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1735 np->name, np->lno, np->file, np->pat);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1738 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1739 fprintf (tagf, "%s\t%s\t", np->name, np->file);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1740
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1741 if (np->is_func)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1742 { /* a function */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1743 putc (searchar, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1744 putc ('^', tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1745
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1746 for (sp = np->pat; *sp; sp++)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1747 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1748 if (*sp == '\\' || *sp == searchar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1749 putc ('\\', tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1750 putc (*sp, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1751 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1752 putc (searchar, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1753 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1754 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1755 { /* a typedef; text pattern inadequate */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1756 fprintf (tagf, "%d", np->lno);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1757 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1758 putc ('\n', tagf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 /* Output subentries that follow this one */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1763 put_entries (np->right);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 /* Length of a number's decimal representation. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1767 int number_len PP ((long num));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1768 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1769 number_len (num)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1770 long num;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1772 int len = 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1773 while ((num /= 10) > 0)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1774 len += 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 return len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 * Return total number of characters that put_entries will output for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 * the nodes in the subtree of the specified node. Works only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 * we are not ctags, but called only in that case. This count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 * is irrelevant with the new tags.el, but is still supplied for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 * backward compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 int
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1786 total_size_of_entries (np)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1787 register node *np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 register int total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1791 if (np == NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1794 for (total = 0; np != NULL; np = np->right)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 /* Count left subentries. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1797 total += total_size_of_entries (np->left);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 /* Count this entry */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1800 total += strlen (np->pat) + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1801 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1802 if (np->name != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1803 total += 1 + strlen (np->name); /* \001name */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 return total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 * The C symbol tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 enum sym_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1814 st_none,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1815 st_C_objprot, st_C_objimpl, st_C_objend,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1816 st_C_gnumacro,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1817 st_C_ignore,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1818 st_C_javastruct,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1819 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1820 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1821 , st_C_union, st_C_class, st_C_extern, st_C_inline
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1822 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 /* Feed stuff between (but not including) %[ and %] lines to:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1826 gperf -c -k 1,3 -o -p -r -t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 %[
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1828 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 %%
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1830 @interface, 0, st_C_objprot
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1831 @protocol, 0, st_C_objprot
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1832 @implementation,0, st_C_objimpl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1833 @end, 0, st_C_objend
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1834 import, C_JAVA, st_C_ignore
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1835 package, C_JAVA, st_C_ignore
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1836 friend, C_PLPL, st_C_ignore
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1837 extends, C_JAVA, st_C_javastruct
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1838 implements, C_JAVA, st_C_javastruct
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1839 interface, C_JAVA, st_C_struct
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1840 class, C_PLPL, st_C_class
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1841 namespace, C_PLPL, st_C_struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 domain, C_STAR, st_C_struct
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1843 union, 0, st_C_union
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 struct, 0, st_C_struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 enum, 0, st_C_enum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 typedef, 0, st_C_typedef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 define, 0, st_C_define
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1848 inline, 0, st_C_inline
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1849 bool, C_PLPL, st_C_typespec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 long, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 short, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 int, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 char, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 float, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 double, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 signed, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 unsigned, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 auto, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 void, 0, st_C_typespec
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1860 extern, 0, st_C_extern
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 static, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 const, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 volatile, 0, st_C_typespec
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1864 explicit, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1865 mutable, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1866 typename, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1867 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1868 DEFUN, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1869 SYSCALL, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1870 ENTRY, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1871 PSEUDO, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1872 # These are defined inside C functions, so currently they are not met.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1873 # EXFUN used in glibc, DEFVAR_* in emacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1874 #EXFUN, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1875 #DEFVAR_, 0, st_C_gnumacro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 %]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 and replace lines between %< and %> with its output. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 /*%<*/
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1879 /* C code produced by gperf version 2.5 (GNU C++ version) */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1880 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1881 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1883 #define TOTAL_KEYWORDS 41
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 #define MIN_WORD_LENGTH 3
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1885 #define MAX_WORD_LENGTH 15
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1886 #define MIN_HASH_VALUE 19
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1887 #define MAX_HASH_VALUE 100
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1888 /* maximum key range = 82, duplicates = 0 */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1889
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1890 static unsigned int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1891 hash (str, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1892 register char *str;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1893 register int unsigned len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1895 static unsigned char asso_values[] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1897 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1898 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1899 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1900 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1901 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1902 101, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1903 101, 101, 101, 101, 25, 101, 101, 101, 31, 33,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1904 46, 101, 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1905 60, 101, 101, 43, 1, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1906 101, 101, 101, 101, 101, 101, 101, 11, 17, 4,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1907 44, 63, 31, 8, 101, 29, 101, 101, 14, 15,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1908 44, 5, 13, 101, 38, 15, 25, 33, 55, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1909 101, 101, 101, 101, 101, 101, 101, 101,
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1910 };
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1911 return len + asso_values[str[2]] + asso_values[str[0]];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1914 struct C_stab_entry *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1915 in_word_set (str, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1916 register char *str;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1917 register unsigned int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1919 static struct C_stab_entry wordlist[] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1921 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1922 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1923 {"",}, {"char", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1924 {"class", C_PLPL, st_C_class},
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1925 {"",}, {"",}, {"",},
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1926 {"package", C_JAVA, st_C_ignore},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1927 {"short", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1928 {"bool", C_PLPL, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1929 {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1930 {"signed", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1931 {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1932 {"static", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1933 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1934 {"ENTRY", 0, st_C_gnumacro},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1935 {"auto", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1936 {"float", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1937 {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1938 {"typedef", 0, st_C_typedef},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1939 {"typename", C_PLPL, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1940 {"mutable", C_PLPL, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1941 {"import", C_JAVA, st_C_ignore},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1942 {"inline", 0, st_C_inline},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1943 {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1944 {"implements", C_JAVA, st_C_javastruct},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1945 {"const", 0, st_C_typespec},
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1946 {"",},
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1947 {"@implementation", 0, st_C_objimpl},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1948 {"unsigned", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1949 {"int", 0, st_C_typespec},
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1950 {"",},
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1951 {"struct", 0, st_C_struct},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1952 {"",}, {"",},
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1953 {"long", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1954 {"interface", C_JAVA, st_C_struct},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1955 {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1956 {"domain", C_STAR, st_C_struct},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1957 {"friend", C_PLPL, st_C_ignore},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1958 {"union", 0, st_C_union},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1959 {"namespace", C_PLPL, st_C_struct},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1960 {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1961 {"@protocol", 0, st_C_objprot},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1962 {"@end", 0, st_C_objend},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1963 {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1964 {"volatile", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1965 {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1966 {"@interface", 0, st_C_objprot},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1967 {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1968 {"define", 0, st_C_define},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1969 {"DEFUN", 0, st_C_gnumacro},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1970 {"double", 0, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1971 {"explicit", C_PLPL, st_C_typespec},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1972 {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1973 {"void", 0, st_C_typespec},
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1974 {"",}, {"",}, {"",}, {"",},
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1975 {"SYSCALL", 0, st_C_gnumacro},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1976 {"extern", 0, st_C_extern},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1977 {"extends", C_JAVA, st_C_javastruct},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1978 {"",}, {"",}, {"",},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1979 {"PSEUDO", 0, st_C_gnumacro},
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1980 {"enum", 0, st_C_enum},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 register int key = hash (str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
1987 if (key <= MAX_HASH_VALUE && key >= 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1989 register char *s = wordlist[key].name;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1990
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1991 if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 return &wordlist[key];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 /*%>*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1999 enum sym_type C_symtype PP ((char *str, int len, int c_ext));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2000 enum sym_type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2001 C_symtype (str, len, c_ext)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2002 char *str;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2003 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2004 int c_ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2006 register struct C_stab_entry *se = in_word_set (str, len);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 return st_none;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 return se->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 /*
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2014 * C functions and variables are recognized using a simple
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2015 * finite automaton. fvdef is its state variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2017 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2019 fvnone, /* nothing seen */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2020 fvnameseen, /* function or variable name seen */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2021 fstartlist, /* func: just after open parenthesis */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2022 finlist, /* func: in parameter list */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2023 flistseen, /* func: after parameter list */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2024 fignore, /* func: before open brace */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2025 vignore /* var-like: ignore until ';' */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2026 } fvdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 * typedefs are recognized using a simple finite automaton.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2031 * typdef is its state variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2033 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 tnone, /* nothing seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 ttypedseen, /* typedef keyword seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 tinbody, /* inside typedef body */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 tend, /* just before typedef tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 tignore /* junk after typedef tag */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2040 } typdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 * struct-like structures (enum, struct and union) are recognized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 * using another simple finite automaton. `structdef' is its state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 * variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2048 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 snone, /* nothing seen yet */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 skeyseen, /* struct-like keyword seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 stagseen, /* struct-like tag seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 scolonseen, /* colon seen after struct-like tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 sinbody /* in struct body: recognize member func defs*/
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2055 } structdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 * struct tag, and structtype is the type of the preceding struct-like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 * keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2062 char *structtag = "<uninited>";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 enum sym_type structtype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2065 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2066 void
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2067 oo_browser_check_and_clear_structtype()
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2068 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2069 /* Allow for multiple enum_label tags. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2070 if (structtype != st_C_enum)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2071 structtype = st_none;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2072 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2073 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2074
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2076 * When objdef is different from onone, objtag is the name of the class.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2077 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2078 char *objtag = "<uninited>";
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2079
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2080 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 * Yet another little state machine to deal with preprocessor lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2083 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 dnone, /* nothing seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 dsharpseen, /* '#' seen as first char on line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 ddefineseen, /* '#' and 'define' seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 dignorerest /* ignore rest of line */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2089 } definedef;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2090
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2091 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2092 * State machine for Objective C protocols and implementations.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2093 * Tom R.Hageman <tom@basil.icce.rug.nl>
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2094 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2095 enum
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2096 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2097 onone, /* nothing seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2098 oprotocol, /* @interface or @protocol seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2099 oimplementation, /* @implementations seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2100 otagseen, /* class name seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2101 oparenseen, /* parenthesis before category seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2102 ocatseen, /* category name seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2103 oinbody, /* in @implementation body */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2104 omethodsign, /* in @implementation body, after +/- */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2105 omethodtag, /* after method name */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2106 omethodcolon, /* after method colon */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2107 omethodparm, /* after method parameter */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2108 oignore /* wait for @end */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2109 } objdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2111 /*
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2112 * Use this structure to keep info about the token read, and how it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2113 * should be tagged. Used by the make_C_tag function to build a tag.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2114 */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2115 typedef struct
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2116 {
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2117 bool valid;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2118 char *str;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2119 bool named;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2120 int linelen;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2121 int lineno;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2122 long linepos;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2123 char *buffer;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2124 } token;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2125
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2126 token tok; /* latest token read */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2127
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 * Set this to TRUE, and the next token considered is called a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 * Used only for GNU emacs's function-defining macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2132 bool next_token_is_func;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 * TRUE in the rules part of a yacc file, FALSE outside (parse as C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2137 bool yacc_rules;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2140 * methodlen is the length of the method name stored in token_name.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2141 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2142 int methodlen;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2143
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2144 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2145 void
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2146 oo_browser_clear_all_globals()
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2147 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2148 /* Initialize globals so there is no carry over between files. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2149 oo_browser_construct = C_NULL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2150 fvdef = fvnone; typdef = tnone; structdef = snone;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2151 definedef = dnone; objdef = onone;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2152 structtype = st_none;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2153 next_token_is_func = yacc_rules = FALSE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2154 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2155
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2156 void
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2157 oo_browser_clear_some_globals()
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2158 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2159 oo_browser_construct = C_NULL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2160 structtype = st_none;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2161 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2162 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2163
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2164 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165 * consider_token ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 * checks to see if the current token is at the start of a
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2167 * function or variable, or corresponds to a typedef, or
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2168 * is a struct/union/enum tag, or #define, or an enum constant.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2170 * *IS_FUNC gets TRUE iff the token is a function or #define macro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2171 * with args. C_EXT is which language we are looking at.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 * In the future we will need some way to adjust where the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 * the token is; for instance, implementing the C++ keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 * `operator' properly will adjust the end of the token to be after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 * whatever follows `operator'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178 * Globals
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2179 * fvdef IN OUT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 * structdef IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 * definedef IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 * typdef IN OUT
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2183 * objdef IN OUT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 * next_token_is_func IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2186 bool consider_token PP ((char *str, int len, int c, int c_ext,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2187 int cblev, int parlev, bool *is_func_or_var));
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2188 bool
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2189 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 register char *str; /* IN: token pointer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 register int len; /* IN: token length */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2192 register int c; /* IN: first char after the token */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 int c_ext; /* IN: C extensions mask */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 int cblev; /* IN: curly brace level */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2195 int parlev; /* IN: parenthesis level */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2196 bool *is_func_or_var; /* OUT: function or variable found */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 enum sym_type toktype = C_symtype (str, len, c_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2200 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2201 switch (toktype)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2202 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2203 case st_C_struct:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2204 set_construct(C_STRUCTURE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2205 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2206 case st_C_union:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2207 set_construct(C_UNION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2208 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2209 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2210 set_construct(C_CLASS);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2211 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2212 case st_C_enum:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2213 set_construct(C_ENUMERATION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2214 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2215 case st_C_typedef:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2216 set_construct(C_TYPE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2217 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2218 case st_C_extern:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2219 set_construct(C_EXTERN);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2220 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2221 case st_C_inline:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2222 set_construct(C_FUNCTION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2223 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2224 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2225 #endif
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2226
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 * Advance the definedef state machine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 switch (definedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 case dnone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 /* We're not on a preprocessor line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 case dsharpseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 if (toktype == st_C_define)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 definedef = ddefineseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 definedef = dignorerest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 case ddefineseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 * Make a tag for any macro, unless it is a constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 * and constantypedefs is FALSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 definedef = dignorerest;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2251 #ifndef OO_BROWSER
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2252 *is_func_or_var = (c == '(');
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2253 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2254 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2255 char *p = str + len * sizeof(char);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2256
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2257 if (*p == '(')
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2258 /* This must be a macro since there is no
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2259 whitespace between the opening parenthesis
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2260 and the definition name. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2261 *is_func_or_var = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2262 else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2263 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2264 *is_func_or_var = FALSE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2265
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2266 /* Handle possible whitespace between macro tag and opening
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2267 parenthesis and ensure this is an actual macro.
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2268 -- Bob Weiner, Altrasoft, 11/19/1997 */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2269 while (*p && isspace(*p)) p++;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2270 if (*p) c = *p;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2271
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2272 /* Skip over nested parentheses. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2273 if (c == '(')
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2274 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2275 short depth = 1;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2277 while (*++p && depth > 0 && *p != '\n')
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2278 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2279 switch (*p)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2280 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2281 case '(':
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2282 depth++; break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2283 case ')':
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2284 depth--; break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2285 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2286 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2287
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2288 /* If this is a macro, we have just passed
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2289 the arguments and there will be more on
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2290 the line before the NULL character that marks
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2291 the end of the line token. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2292 while (*p == ' ' || *p == '\t') p++;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2293 if (*p) *is_func_or_var = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2294 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2295 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2296 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2297
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2298 set_construct((*is_func_or_var) ? C_MACRO : C_CONSTANT);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2299 #endif
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2300 if (!*is_func_or_var && !constantypedefs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 case dignorerest:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 default:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2307 error ("internal error: definedef value.", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 * Now typedefs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 case tnone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 if (toktype == st_C_typedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 if (typedefs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 typdef = ttypedseen;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2320 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 case ttypedseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 case st_none:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 case st_C_typespec:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2329 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2330 case st_C_extern:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2331 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 typdef = tend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 case st_C_enum:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2336 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2337 case st_C_union:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2338 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2339 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 /* Do not return here, so the structdef stuff has a chance. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 case tend:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 case st_C_typespec:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 case st_C_enum:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2350 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2351 case st_C_extern:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2352 case st_C_union:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2353 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2354 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 * This structdef business is currently only invoked when cblev==0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 * It should be recursively invoked whatever the curly brace level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 * and a stack of states kept, to allow for definitions of structs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 * within structs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 * This structdef business is NOT invoked when we are ctags and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 * file is plain C. This is because a struct tag may have the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 * name as another tag, and this loses with ctags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2372 case st_C_javastruct:
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2373 if (structdef == stagseen)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2374 structdef = scolonseen;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2375 return FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 case st_C_enum:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2378 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2379 case st_C_union:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2380 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2381 case st_C_extern:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2382 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 if (typdef == ttypedseen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 structdef = skeyseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 structtype = toktype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2391
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 if (structdef == skeyseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2394 /* Save the tag for struct/union/class, for functions and variables
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2395 that may be defined inside. */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2396 #ifndef OO_BROWSER
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 if (structtype == st_C_struct)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2398 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2399 if (structtype == st_C_struct
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2400 || structtype == st_C_union
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2401 || structtype == st_C_class)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2402 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 structtag = savenstr (str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 structtag = "<enum>";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 structdef = stagseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2410 /* Avoid entering fvdef stuff if typdef is going on. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 if (typdef != tnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 definedef = dnone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2417 /* Detect GNU macros.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2418
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2419 DEFUN note for writers of emacs C code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2420 The DEFUN macro, used in emacs C source code, has a first arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2421 that is a string (the lisp function name), and a second arg that
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2422 is a C function name. Since etags skips strings, the second arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2423 is tagged. This is unfortunate, as it would be better to tag the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2424 first arg. The simplest way to deal with this problem would be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2425 to name the tag with a name built from the function name, by
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2426 removing the initial 'F' character and substituting '-' for '_'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2427 Anyway, this assumes that the conventions of naming lisp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2428 functions will never change. Currently, this method is not
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2429 implemented, so writers of emacs code are recommended to put the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2430 first two args of a DEFUN on the same line. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2431 if (definedef == dnone && toktype == st_C_gnumacro)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2432 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2433 next_token_is_func = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2434 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2435 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 if (next_token_is_func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 next_token_is_func = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2439 fvdef = fignore;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2440 *is_func_or_var = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2444 /* Detect Objective C constructs. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2445 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2446 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2447 case onone:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2448 switch (toktype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2449 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2450 case st_C_objprot:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2451 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2452 set_construct(C_OBJC);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2453 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2454 objdef = oprotocol;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2455 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2456 case st_C_objimpl:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2457 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2458 set_construct(C_OBJC);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2459 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2460 objdef = oimplementation;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2461 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2462 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2463 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2464 case oimplementation:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2465 /* Save the class tag for functions or variables defined inside. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2466 objtag = savenstr (str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2467 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2468 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2469 case oprotocol:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2470 /* Save the class tag for categories. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2471 objtag = savenstr (str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2472 objdef = otagseen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2473 *is_func_or_var = TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2474 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2475 case oparenseen:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2476 objdef = ocatseen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2477 *is_func_or_var = TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2478 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2479 case oinbody:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2480 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2481 case omethodsign:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2482 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2483 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2484 objdef = omethodtag;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2485 methodlen = len;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2486 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2487 strncpy (token_name.buffer, str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2488 token_name.buffer[methodlen] = '\0';
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2489 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2490 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2491 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2492 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2493 case omethodcolon:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2494 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2495 objdef = omethodparm;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2496 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2497 case omethodparm:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2498 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2499 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2500 objdef = omethodtag;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2501 methodlen += len;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2502 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2503 strncat (token_name.buffer, str, len);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2504 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2505 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2506 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2507 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2508 case oignore:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2509 if (toktype == st_C_objend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2510 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2511 /* Memory leakage here: the string pointed by objtag is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2512 never released, because many tests would be needed to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2513 avoid breaking on incorrect input code. The amount of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2514 memory leaked here is the sum of the lengths of the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2515 class tags.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2516 free (objtag); */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2517 objdef = onone;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2518 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2519 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2520 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2521
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2522 /* A function, variable or enum constant? */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 case st_C_typespec:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2526 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2527 case st_C_extern:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2528 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2529 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2530 fvdef = fvnone; /* should be useless */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2531 return FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2532 case st_C_ignore:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2533 fvdef = vignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 return FALSE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2535 case st_none:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2536 if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2537 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2538 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2539 oo_browser_construct = C_ENUM_LABEL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2540 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2541 return TRUE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2542 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2543 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2544 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2545 if (fvdef == fvnone)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2547 fvdef = fvnameseen; /* function or variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2548 *is_func_or_var = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 * C_entries ()
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2558 * This routine finds functions, variables, typedefs,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2559 * #define's, enum constants and struct/union/enum definitions in
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2560 * #C syntax and adds them to the list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 #define current_lb_is_new (newndx == curndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 #define switch_line_buffers() (curndx = 1 - curndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 #define curlb (lbs[curndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 #define othlb (lbs[1-curndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 #define newlb (lbs[newndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 #define curlinepos (lbs[curndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 #define othlinepos (lbs[1-curndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 #define newlinepos (lbs[newndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2572 #define CNL_SAVE_DEFINEDEF() \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 curlinepos = charno; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 lineno++; \
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2576 linecharno = charno; \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 charno += readline (&curlb, inf); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 lp = curlb.buffer; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 quotednl = FALSE; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 newndx = curndx; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2583 #define CNL() \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 do { \
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2585 CNL_SAVE_DEFINEDEF(); \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 if (savetok.valid) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 tok = savetok; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 savetok.valid = FALSE; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 definedef = dnone; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2594
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2595 void make_C_tag PP ((bool isfun));
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2596 void
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2597 make_C_tag (isfun)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2598 bool isfun;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2599 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2600 /* This function should never be called when tok.valid is FALSE, but
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2601 we must protect against invalid input or internal errors. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2602 if (tok.valid)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2603 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2604 if (traditional_tag_style)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2605 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2606 /* This was the original code. Now we call new_pfnote instead,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2607 which uses the new method for naming tags (see new_pfnote). */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2608 char *name = NULL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2609
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2610 if (CTAGS || tok.named)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2611 name = savestr (token_name.buffer);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2612 pfnote (name, isfun,
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2613 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2614 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2615 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2616 new_pfnote (token_name.buffer, token_name.len, isfun,
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2617 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2618 tok.valid = FALSE;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2619 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2620 else if (DEBUG)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2621 abort ();
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2622 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2623
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2624
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2625 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2626 C_entries (c_ext, inf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 int c_ext; /* extension of C */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2628 FILE *inf; /* input file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2629 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 register char c; /* latest char read; '\0' for end of line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 register char *lp; /* pointer one beyond the character `c' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 int curndx, newndx; /* indices for current and new lb */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2633 register int tokoff; /* offset in line of start of current token */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2634 register int toklen; /* length of current token */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2635 char *qualifier; /* string used to qualify names */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2636 int qlen; /* length of qualifier */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 int cblev; /* current curly brace level */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 int parlev; /* current parenthesis level */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2639 bool incomm, inquote, inchar, quotednl, midtoken;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2640 bool cplpl, cjava;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2641 token savetok; /* token saved during preprocessor handling */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2642
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2643
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2644 tokoff = toklen = 0; /* keep compiler quiet */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 curndx = newndx = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 lp = curlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 *lp = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2651 fvdef = fvnone; typdef = tnone; structdef = snone;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2652 definedef = dnone; objdef = onone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2653 next_token_is_func = yacc_rules = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2654 midtoken = inquote = inchar = incomm = quotednl = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2655 tok.valid = savetok.valid = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2656 cblev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2657 parlev = 0;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2658 cplpl = (c_ext & C_PLPL) == C_PLPL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2659 cjava = (c_ext & C_JAVA) == C_JAVA;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2660 if (cjava)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2661 { qualifier = "."; qlen = 1; }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2662 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2663 { qualifier = "::"; qlen = 2; }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 c = *lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 if (c == '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 /* If we're at the end of the line, the next character is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 '\0'; don't skip it, because it's the thing that tells us
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 to read the next line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 if (*lp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 quotednl = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 c = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 else if (incomm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 case '*':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 if (*lp == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 c = *lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 incomm = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 /* Newlines inside comments do not end macro definitions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 traditional cpp. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2695 CNL_SAVE_DEFINEDEF ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 else if (inquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 case '"':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2707 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 /* Newlines inside strings do not end macro definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 in traditional cpp, even though compilers don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 usually accept them. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2711 CNL_SAVE_DEFINEDEF ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 else if (inchar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 /* Hmmm, something went wrong. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2722 CNL ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 inchar = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2731 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2733 case '"':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2734 inquote = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2735 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2736 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 inchar = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2740 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2741 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2742 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 case '/':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 if (*lp == '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 incomm = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2750 else if (/* cplpl && */ *lp == '/')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2752 c = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2754 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 case '%':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 if ((c_ext & YACC) && *lp == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 /* entering or exiting rules section in yacc file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 lp++;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2762 definedef = dnone; fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 typdef = tnone; structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2764 next_token_is_func = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 midtoken = inquote = inchar = incomm = quotednl = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 cblev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 yacc_rules = !yacc_rules;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 case '#':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 if (definedef == dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 char *cp;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2776 bool cpptoken = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 /* Look back on this line. If all blanks, or nonblanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 followed by an end of comment, this is a preprocessor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 token. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 for (cp = newlb.buffer; cp < lp-1; cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 if (!iswhite (*cp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 if (*cp == '*' && *(cp+1) == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 cpptoken = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 cpptoken = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 if (cpptoken)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 definedef = dsharpseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 } /* if (definedef == dnone) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 } /* switch (c) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 /* Consider token only if some complicated conditions are satisfied. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801 if ((definedef != dnone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 || (cblev == 0 && structdef != scolonseen)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2803 || (cblev == 1 && cplpl && structdef == sinbody)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2804 || (structdef == sinbody && structtype == st_C_enum))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2805 && typdef != tignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2806 && definedef != dignorerest
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2807 && fvdef != finlist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2809 if (midtoken)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 if (endtoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2813 if (c == ':' && cplpl && *lp == ':' && begtoken(*(lp + 1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2815 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2816 * This handles :: in the middle, but not at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2817 * beginning of an identifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 lp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 toklen += 3;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2821 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2822 set_construct(C_METHOD);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2823 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2825 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2827 bool funorvar = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 if (yacc_rules
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2830 || consider_token (newlb.buffer + tokoff, toklen, c,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2831 c_ext, cblev, parlev, &funorvar))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2833 tok.named = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 if (structdef == sinbody
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 && definedef == dnone
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2836 && funorvar)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2837 /* function or var defined in C++ class body */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2839 int len = strlen (structtag) + qlen + toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2840 grow_linebuffer (&token_name, len + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 strcpy (token_name.buffer, structtag);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2842 strcat (token_name.buffer, qualifier);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 strncat (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2844 newlb.buffer + tokoff, toklen);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2845 token_name.len = len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 tok.named = TRUE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2847 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2848 oo_browser_construct = C_METHOD;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2849 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2851 else if (objdef == ocatseen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2852 /* Objective C category */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2853 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2854 int len = strlen (objtag) + 2 + toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2855 grow_linebuffer (&token_name, len + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2856 strcpy (token_name.buffer, objtag);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2857 strcat (token_name.buffer, "(");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2858 strncat (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2859 newlb.buffer + tokoff, toklen);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2860 strcat (token_name.buffer, ")");
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2861 token_name.len = len;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2862 tok.named = TRUE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2863 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2864 oo_browser_construct = C_OBJC;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2865 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2866 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2867 else if (objdef == omethodtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2868 || objdef == omethodparm)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2869 /* Objective C method */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2870 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2871 tok.named = TRUE;
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2872 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2873 oo_browser_construct = C_OBJC;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2874 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2875 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2876 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2877 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2878 grow_linebuffer (&token_name, toklen + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2879 strncpy (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2880 newlb.buffer + tokoff, toklen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 token_name.buffer[toklen] = '\0';
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2882 token_name.len = toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2883 /* Name macros. */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2884 tok.named
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2885 = (structdef == stagseen
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2886 || typdef == tend
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2887 #ifdef OO_BROWSER
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2888 /* Also name #define constants,
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2889 enumerations and enum_labels.
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2890 Conditionalize `funorvar' reference
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2891 here or #defines will appear without
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2892 their #names.
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2893 -- Bob Weiner, Altrasoft, 4/25/1998 */
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2894 || ((oo_browser_format || funorvar)
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2895 && definedef == dignorerest)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2896 || (oo_browser_format
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2897 && (oo_browser_construct == C_ENUMERATION
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2898 || oo_browser_construct == C_ENUM_LABEL))
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2899 #else
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2900 || (funorvar
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2901 && definedef == dignorerest)
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2902 #endif
278
90d73dddcdc4 Import from CVS: tag r21-0b37
cvs
parents: 276
diff changeset
2903 );
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 tok.lineno = lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 tok.linelen = tokoff + toklen + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 tok.buffer = newlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 tok.linepos = newlinepos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2909 tok.valid = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 if (definedef == dnone
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2912 && (fvdef == fvnameseen
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 || structdef == stagseen
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2914 || typdef == tend
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2915 || objdef != onone))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 if (current_lb_is_new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 switch_line_buffers ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 else
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2921 make_C_tag (funorvar);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 midtoken = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 } /* if (endtoken (c)) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 else if (intoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 toklen++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 } /* if (midtoken) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 else if (begtoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2933 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 switch (definedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2936 case dnone:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2937 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 case fstartlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2940 fvdef = finlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 case flistseen:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2943 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2944 set_construct(C_MACRO);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
2945 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2946 make_C_tag (TRUE); /* a function */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2947 fvdef = fignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2949 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2950 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 }
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2953 if (structdef == stagseen && !cjava)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 case dsharpseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 savetok = tok;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 if (!yacc_rules || lp == newlb.buffer + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 tokoff = lp - 1 - newlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 toklen = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 midtoken = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 } /* if (begtoken) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 } /* if must look at token */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 /* Detect end of line, colon, comma, semicolon and various braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 after having handled a token.*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 case ':':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2975 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2977 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2978 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2979 case otagseen:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2980 objdef = oignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2981 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2982 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2983 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2984 case omethodparm:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2985 objdef = omethodcolon;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2986 methodlen += 1;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2987 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2988 strcat (token_name.buffer, ":");
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2989 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2990 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2991 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 structdef = scolonseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 else
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2995 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2997 case fvnameseen:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998 if (yacc_rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3000 make_C_tag (FALSE); /* a yacc function */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3001 fvdef = fignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 case fstartlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3005 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 case ';':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 if (cblev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 case tend:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3016 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3017 set_construct(C_TYPE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3018 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3019 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 typdef = tnone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3024 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3026 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3027 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3028 case fvnameseen:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3029 #ifndef OO_BROWSER
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3030 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3031 make_C_tag (FALSE); /* a variable */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3032 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3033 if (constantypedefs && structdef == snone)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3034 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3035 tok.named = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3036 switch (structtype)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3037 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3038 case st_C_enum:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3039 set_construct(C_ENUMERATION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3040 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3041 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3042 set_construct(C_CLASS);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3043 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3044 default:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3045 set_construct(C_VARIABLE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3046 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3047 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3048 make_C_tag (FALSE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3049 /* Force reset of st_C_enum structtype value. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3050 structtype = st_none;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3051 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3052 #endif
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3053 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3054 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3055 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 /* The following instruction invalidates the token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 Probably the token should be invalidated in all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 other cases where some state machine is reset. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 tok.valid = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 case ',':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3067 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3068 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3069 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3070 case omethodparm:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3071 make_C_tag (TRUE); /* an Objective C method */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3072 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3073 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3074 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3075 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3076 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3077 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3078 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3079 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3080 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3081 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3082 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3083 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3084 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3085 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3086 fvdef = fvnone;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3087 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 case '[':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 if (cblev == 0 && typdef == tend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3096 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3097 set_construct(C_TYPE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3098 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 typdef = tignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3100 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3103 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3104 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3105 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3106 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3107 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3108 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3109 case fvnameseen:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3110 #ifndef OO_BROWSER
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3111 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3112 make_C_tag (FALSE); /* a variable */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3113 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3114 if (constantypedefs && structdef == snone)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3115 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3116 tok.named = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3117 switch (structtype)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3118 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3119 case st_C_enum:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3120 set_construct(C_ENUMERATION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3121 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3122 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3123 set_construct(C_CLASS);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3124 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3125 default:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3126 set_construct(C_VARIABLE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3127 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3128 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3129 make_C_tag (FALSE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3130 /* Force reset of st_C_enum structtype value. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3131 structtype = st_none;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3132 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3133 #endif
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3134 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3135 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3136 fvdef = fvnone;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3137 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 case '(':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3144 if (objdef == otagseen && parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3145 objdef = oparenseen;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3146 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3148 case fvnone:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 case ttypedseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 case tend:
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
3153 if (tok.valid && *lp != '*')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3155 /* This handles constructs like:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3156 typedef void OperatorFun (int fun); */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3157 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3158 set_construct(C_TYPE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3159 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3160 make_C_tag (FALSE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 typdef = tignore;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 } /* switch (typdef) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3166 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3167 fvdef = fstartlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3170 fvdef = finlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3172 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 parlev++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 case ')':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3178 if (objdef == ocatseen && parlev == 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3179 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3180 make_C_tag (TRUE); /* an Objective C category */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3181 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3182 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183 if (--parlev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3184 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3185 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3186 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3187 case fstartlist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3188 case finlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3189 fvdef = flistseen;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3190 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3192 if (cblev == 0 && typdef == tend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3193 {
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3194 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3195 set_construct(C_TYPE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3196 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 typdef = tignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3198 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3200 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3201 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 parlev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 case '{':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 if (typdef == ttypedseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 typdef = tinbody;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 switch (structdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 case skeyseen: /* unnamed struct */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3212 structdef = sinbody;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 structtag = "_anonymous_";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 case stagseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 case scolonseen: /* named struct */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 structdef = sinbody;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3218 make_C_tag (FALSE); /* a struct */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3221 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 case flistseen:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3224 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3225 set_construct(C_FUNCTION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3226 /* Ensure function name is recorded.
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3227 -- Bob Weiner, Altrasoft */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3228 tok.named = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3229 #endif
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3230 make_C_tag (TRUE); /* a function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3231 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 case fignore:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3233 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3234 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3235 case fvnone:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3236 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3237 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3238 case otagseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3239 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3240 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3241 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3242 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3243 case omethodparm:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3244 make_C_tag (TRUE); /* an Objective C method */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3245 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3246 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3247 default:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3248 /* Neutralize `extern "C" {' grot. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3249 if (cblev == 0 && structdef == snone && typdef == tnone)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3250 cblev = -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3251 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 cblev++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 case '*':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 break;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3258 if (fvdef == fstartlist)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3259 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 case '}':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 if (!noindentypedefs && lp == newlb.buffer + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 cblev = 0; /* reset curly brace level if first column */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 parlev = 0; /* also reset paren level, just in case... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3269 else if (cblev > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3270 cblev--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 if (cblev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 if (typdef == tinbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 typdef = tend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 /* Memory leakage here: the string pointed by structtag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 never released, because I fear to miss something and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 break things while freeing the area. The amount of
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3278 memory leaked here is the sum of the lengths of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 struct tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 if (structdef == sinbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 free (structtag); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 structtag = "<error>";
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3285 #ifdef OO_BROWSER
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3286 /* Next line added to avoid any state carryover between
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3287 functions. -- Bob Weiner, Altrasoft, 11/19/1997 */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3288 fvdef = fvnone; oo_browser_construct = C_NULL;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3289 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3292 case '=':
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3293 if (definedef != dnone)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3294 break;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3295 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3296 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3297 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3298 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3299 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3300 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3301 case fvnameseen:
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3302 #ifndef OO_BROWSER
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3303 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3304 make_C_tag (FALSE); /* a variable */
276
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3305 #else
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3306 if (constantypedefs)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3307 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3308 tok.named = TRUE;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3309 switch (structtype)
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3310 {
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3311 case st_C_enum:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3312 set_construct(C_ENUMERATION);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3313 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3314 case st_C_class:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3315 set_construct(C_CLASS);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3316 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3317 default:
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3318 /* a global variable */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3319 set_construct(C_VARIABLE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3320 break;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3321 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3322 make_C_tag (FALSE);
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3323 /* Force reset of st_C_enum structtype value. */
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3324 structtype = st_none;
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3325 }
6330739388db Import from CVS: tag r21-0b36
cvs
parents: 272
diff changeset
3326 #endif
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3327 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3328 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3329 fvdef = vignore;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3330 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3331 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3332 case '+':
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3333 case '-':
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3334 if (objdef == oinbody && cblev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3335 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3336 objdef = omethodsign;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3337 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3338 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3339 /* FALLTHRU */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3340 case '#': case '~': case '&': case '%': case '/': case '|':
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3341 case '^': case '!': case '<': case '>': case '.': case '?': case ']':
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 /* These surely cannot follow a function tag. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3345 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3346 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 case '\0':
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3349 if (objdef == otagseen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3350 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3351 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3352 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3353 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 /* If a macro spans multiple lines don't reset its state. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 if (quotednl)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3356 CNL_SAVE_DEFINEDEF ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3358 CNL ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 } /* switch (c) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362 } /* while not eof */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 * Process either a C++ file or a C file depending on the setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 * of a global flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3370 default_C_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3371 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3372 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3373 C_entries (cplusplus ? C_PLPL : 0, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 /* Always do plain ANSI C. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378 plain_C_entries (inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 FILE *inf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 C_entries (0, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 /* Always do C++. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3386 Cplusplus_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3387 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 C_entries (C_PLPL, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3392 /* Always do Java. */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3393 void
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3394 Cjava_entries (inf)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3395 FILE *inf;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3396 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3397 C_entries (C_JAVA, inf);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3398 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3399
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 /* Always do C*. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3402 Cstar_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3403 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 C_entries (C_STAR, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 /* Always do Yacc. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3410 Yacc_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3411 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413 C_entries (YACC, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3416 /* A useful macro. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3417 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3418 for (lineno = charno = 0; /* loop initialization */ \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3419 !feof (file_pointer) /* loop test */ \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3420 && (lineno++, /* instructions at start of loop */ \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3421 linecharno = charno, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3422 charno += readline (&line_buffer, file_pointer), \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3423 char_pointer = lb.buffer, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3424 TRUE); \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3425 )
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3426
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3427
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3428 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3429 * Read a file, but do no processing. This is used to do regexp
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3430 * matching on files that have no language defined.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3431 */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3432 void
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3433 just_read_file (inf)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3434 FILE *inf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3435 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3436 register char *dummy;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3437
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3438 LOOP_ON_INPUT_LINES (inf, lb, dummy)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3439 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3440 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3441
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 /* Fortran parsing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3444 bool tail PP ((char *cp));
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3445 bool
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3446 tail (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3447 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 register int len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 while (*cp && lowcase(*cp) == lowcase(dbp[len]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 cp++, len++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 if (*cp == '\0' && !intoken(dbp[len]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 dbp += len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3462 takeprec ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3464 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 if (*dbp != '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 dbp++;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3468 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 if (strneq (dbp, "(*)", 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 dbp += 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 if (!isdigit (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 --dbp; /* force failure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 while (isdigit (*dbp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3484 void getit PP ((FILE *inf));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3486 getit (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3487 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3491 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 if (dbp[5] != '&')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 dbp += 6;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3501 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3502 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3503 if (!isalpha (*dbp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3504 && *dbp != '_'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 && *dbp != '$')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 return;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3507 for (cp = dbp + 1; *cp && intoken (*cp); cp++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3509 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3510 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3512
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3513
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3514 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3515 Fortran_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3516 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3517 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3518 LOOP_ON_INPUT_LINES (inf, lb, dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3519 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3520 if (*dbp == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3521 dbp++; /* Ratfor escape to fortran */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3522 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3523 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3524 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3525 switch (lowcase (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3526 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3527 case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3528 if (tail ("integer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3529 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3530 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3531 case 'r':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3532 if (tail ("real"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 if (tail ("logical"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539 case 'c':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3540 if (tail ("complex") || tail ("character"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3543 case 'd':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3544 if (tail ("double"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3546 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 if (tail ("precision"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3555 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 switch (lowcase (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 case 'f':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 if (tail ("function"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 case 's':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 if (tail ("subroutine"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 case 'e':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 if (tail ("entry"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 if (tail ("program"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 if (tail ("procedure"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3585 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 * Bob Weiner, Motorola Inc., 4/3/94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 * Unix and microcontroller assembly tag handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3591 Asm_labels (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3592 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3596 LOOP_ON_INPUT_LINES (inf, lb, cp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3597 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 /* If first char is alphabetic or one of [_.$], test for colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599 following identifier. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 /* Read past label. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 if (*cp == ':' || isspace (*cp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3607 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 /* Found end of label, so copy it and add it to the table. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3609 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3616 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 * Perl support by Bart Robinson <lomew@cs.utah.edu>
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3618 * enhanced by Michael Ernst <mernst@alum.mit.edu>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3620 * Perl variable names: /^(my|local).../
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3621 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3622 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623 Perl_functions (inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 FILE *inf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3628 LOOP_ON_INPUT_LINES (inf, lb, cp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3630 if (*cp++ == 's'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3631 && *cp++ == 'u'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3632 && *cp++ == 'b' && isspace (*cp++))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3633 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3634 cp = skip_spaces (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3635 if (*cp != '\0')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3636 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3637 while (*cp != '\0'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3638 && !isspace (*cp) && *cp != '{' && *cp != '(')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3639 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3640 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3641 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3642 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3643 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3644 else if (globals /* only if tagging global vars is enabled */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3645 && ((cp = lb.buffer,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3646 *cp++ == 'm'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3647 && *cp++ == 'y')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3648 || (cp = lb.buffer,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3649 *cp++ == 'l'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3650 && *cp++ == 'o'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3651 && *cp++ == 'c'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3652 && *cp++ == 'a'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3653 && *cp++ == 'l'))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3654 && (*cp == '(' || isspace (*cp)))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3655 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3656 /* After "my" or "local", but before any following paren or space. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3657 char *varname = NULL;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3658
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3659 cp = skip_spaces (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3660 if (*cp == '$' || *cp == '@' || *cp == '%')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3661 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3662 char* varstart = ++cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3663 while (isalnum (*cp) || *cp == '_')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3664 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3665 varname = savenstr (varstart, cp-varstart);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3666 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3667 else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3668 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3669 /* Should be examining a variable list at this point;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3670 could insist on seeing an open parenthesis. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3671 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3672 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3673 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3674
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3675 /* Perhaps I should back cp up one character, so the TAGS table
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3676 doesn't mention (and so depend upon) the following char. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3677 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3678 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3679 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3680 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3681 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3682
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3683 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3684 * Python support by Eric S. Raymond <esr@thyrsus.com>
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3685 * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3686 */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3687 void
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3688 Python_functions (inf)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3689 FILE *inf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3690 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3691 register char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3692
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3693 LOOP_ON_INPUT_LINES (inf, lb, cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3694 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3695 if (*cp++ == 'd'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3696 && *cp++ == 'e'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3697 && *cp++ == 'f' && isspace (*cp++))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3698 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3699 cp = skip_spaces (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3700 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3701 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3702 pfnote ((char *) NULL, TRUE,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3703 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3704 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3705
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 cp = lb.buffer;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3707 if (*cp++ == 'c'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3708 && *cp++ == 'l'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3709 && *cp++ == 'a'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3710 && *cp++ == 's'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3711 && *cp++ == 's' && isspace (*cp++))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3713 cp = skip_spaces (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3714 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 cp++;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3716 pfnote ((char *) NULL, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3722 /* Idea by Corny de Souza
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3723 * Cobol tag functions
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3724 * We could look for anything that could be a paragraph name.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3725 * i.e. anything that starts in column 8 is one word and ends in a full stop.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3726 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3727 void
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3728 Cobol_paragraphs (inf)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3729 FILE *inf;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3730 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3731 register char *bp, *ep;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3732
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3733 LOOP_ON_INPUT_LINES (inf, lb, bp)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3734 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3735 if (lb.len < 9)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3736 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3737 bp += 8;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3738
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3739 /* If eoln, compiler option or comment ignore whole line. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3740 if (bp[-1] != ' ' || !isalnum (bp[0]))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3741 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3742
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3743 for (ep = bp; isalnum (*ep) || *ep == '-'; ep++)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3744 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3745 if (*ep++ == '.')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3746 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3747 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3748 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3749 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3750
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751 /* Added by Mosur Mohan, 4/22/88 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 /* Pascal parsing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 * Locates tags for procedures & functions. Doesn't do any type- or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 * var-definitions. It does look for the keyword "extern" or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 * "forward" immediately following the procedure statement; if found,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758 * the tag is skipped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3761 Pascal_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3762 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3764 linebuffer tline; /* mostly copied from C_entries */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3765 long save_lcno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3766 int save_lineno, save_len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3767 char c, *cp, *namebuf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3769 bool /* each of these flags is TRUE iff: */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770 incomment, /* point is inside a comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771 inquote, /* point is inside '..' string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 get_tagname, /* point is after PROCEDURE/FUNCTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 keyword, so next item = potential tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3774 found_tag, /* point is after a potential tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3775 inparms, /* point is within parameter-list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3776 verify_tag; /* point has passed the parm-list, so the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3777 next token will determine whether this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778 is a FORWARD/EXTERN to be ignored, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779 whether it is a real tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3781 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3782 namebuf = NULL; /* keep compiler quiet */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786 *dbp = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3787 initbuffer (&tline);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3789 incomment = inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3790 found_tag = FALSE; /* have a proc name; check if extern */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3791 get_tagname = FALSE; /* have found "procedure" keyword */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3792 inparms = FALSE; /* found '(' after "proc" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3793 verify_tag = FALSE; /* check if "extern" is ahead */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3794
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3795
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3796 while (!feof (inf)) /* long main loop to get next char */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3797 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3798 c = *dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3799 if (c == '\0') /* if end of line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3800 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3801 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3802 linecharno = charno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3803 charno += readline (&lb, inf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3804 dbp = lb.buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3805 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3806 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3807 if (!((found_tag && verify_tag)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3808 || get_tagname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3809 c = *dbp++; /* only if don't need *dbp pointing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 to the beginning of the name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3811 the procedure or function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 if (incomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815 if (c == '}') /* within { } comments */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816 incomment = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 else if (c == '*' && *dbp == ')') /* within (* *) comments */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3818 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3819 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3820 incomment = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3821 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3822 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824 else if (inquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3825 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3826 if (c == '\'')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3827 inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3828 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3829 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3830 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3831 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3832 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3833 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3834 inquote = TRUE; /* found first quote */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3835 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3836 case '{': /* found open { comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3837 incomment = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839 case '(':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840 if (*dbp == '*') /* found open (* comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3841 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842 incomment = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3843 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3844 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3845 else if (found_tag) /* found '(' after tag, i.e., parm-list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 inparms = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848 case ')': /* end of parms list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849 if (inparms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 inparms = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852 case ';':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853 if (found_tag && !inparms) /* end of proc or fn stmt */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3855 verify_tag = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3859 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3860 if (found_tag && verify_tag && (*dbp != ' '))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3861 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3862 /* check if this is an "extern" declaration */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3864 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865 if (lowcase (*dbp == 'e'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 if (tail ("extern")) /* superfluous, really! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870 verify_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873 else if (lowcase (*dbp) == 'f')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875 if (tail ("forward")) /* check for forward reference */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3876 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3877 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878 verify_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881 if (found_tag && verify_tag) /* not external proc, so make tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 verify_tag = FALSE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3885 pfnote (namebuf, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886 tline.buffer, save_len, save_lineno, save_lcno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3890 if (get_tagname) /* grab name of proc or fn */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3891 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 /* save all values for later tagging */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
3896 grow_linebuffer (&tline, lb.len + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3897 strcpy (tline.buffer, lb.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3898 save_lineno = lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3899 save_lcno = linecharno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 /* grab block name */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3902 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3903 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3904 namebuf = (CTAGS) ? savenstr (dbp, cp-dbp) : NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3905 dbp = cp; /* set dbp to e-o-token */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906 save_len = dbp - lb.buffer + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907 get_tagname = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908 found_tag = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 /* and proceed to check for "extern" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 else if (!incomment && !inquote && !found_tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 /* check for proc/fn keywords */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916 switch (lowcase (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918 case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 get_tagname = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922 case 'f':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923 if (tail ("unction"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924 get_tagname = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3927 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3928 } /* while not eof */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930 free (tline.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934 * lisp tag functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935 * look for (def or (DEF, quote or QUOTE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3937 int L_isdef PP ((char *strp));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3938 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3939 L_isdef (strp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3940 register char *strp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942 return ((strp[1] == 'd' || strp[1] == 'D')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943 && (strp[2] == 'e' || strp[2] == 'E')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 && (strp[3] == 'f' || strp[3] == 'F'));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3946 int L_isquote PP ((char *strp));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3947 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3948 L_isquote (strp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3949 register char *strp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3951 return ((*++strp == 'q' || *strp == 'Q')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3952 && (*++strp == 'u' || *strp == 'U')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3953 && (*++strp == 'o' || *strp == 'O')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3954 && (*++strp == 't' || *strp == 'T')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3955 && (*++strp == 'e' || *strp == 'E')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3956 && isspace (*++strp));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3959 void L_getit PP ((void));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3960 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3961 L_getit ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 if (*dbp == '\'') /* Skip prefix quote */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966 dbp++;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3967 else if (*dbp == '(')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3969 if (L_isquote (dbp))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3970 dbp += 7; /* Skip "(quote " */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3971 else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3972 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3973 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3975
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 for (cp = dbp /*+1*/;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3977 *cp != '\0' && *cp != '(' && *cp != ' ' && *cp != ')';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3978 cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3979 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3980 if (cp == dbp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3981 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3982
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3983 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3984 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3988 Lisp_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3989 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3991 LOOP_ON_INPUT_LINES (inf, lb, dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993 if (dbp[0] == '(')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995 if (L_isdef (dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3997 dbp = skip_non_spaces (dbp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3998 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3999 L_getit ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4000 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003 /* Check for (foo::defmumble name-defined ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005 dbp++;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4006 while (*dbp != '\0' && !isspace (*dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 && *dbp != ':' && *dbp != '(' && *dbp != ')');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008 if (*dbp == ':')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012 while (*dbp == ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014 if (L_isdef (dbp - 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4016 dbp = skip_non_spaces (dbp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4017 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 L_getit ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026 /*
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4027 * Postscript tag functions
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4028 * Just look for lines where the first character is '/'
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4029 * Richard Mlynarik <mly@adoc.xerox.com>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4030 */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4031 void
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4032 Postscript_functions (inf)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4033 FILE *inf;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4034 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4035 register char *bp, *ep;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4036
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4037 LOOP_ON_INPUT_LINES (inf, lb, bp)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4038 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4039 if (bp[0] == '/')
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4040 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4041 for (ep = bp+1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4042 *ep != '\0' && *ep != ' ' && *ep != '{';
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4043 ep++)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4044 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4045 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4046 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4047 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4048 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4049 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4050
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4051
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4052 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4053 * Scheme tag functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4054 * look for (def... xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4055 * look for (def... (xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 * look for (def ... ((...(xyzzy ....
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057 * look for (set! xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4058 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4059
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4060 void get_scheme PP ((void));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4063 Scheme_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4064 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4065 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4066 LOOP_ON_INPUT_LINES (inf, lb, dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4067 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4068 if (dbp[0] == '('
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4069 && (dbp[1] == 'D' || dbp[1] == 'd')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4070 && (dbp[2] == 'E' || dbp[2] == 'e')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4071 && (dbp[3] == 'F' || dbp[3] == 'f'))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4073 dbp = skip_non_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 /* Skip over open parens and white space */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4075 while (isspace (*dbp) || *dbp == '(')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077 get_scheme ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4079 if (dbp[0] == '('
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4080 && (dbp[1] == 'S' || dbp[1] == 's')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4081 && (dbp[2] == 'E' || dbp[2] == 'e')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4082 && (dbp[3] == 'T' || dbp[3] == 't')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4083 && (dbp[4] == '!' || dbp[4] == '!')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4084 && (isspace (dbp[5])))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4085 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4086 dbp = skip_non_spaces (dbp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4087 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088 get_scheme ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4089 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4090 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4091 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4094 get_scheme ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4095 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4096 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100 /* Go till you get to white space or a syntactic break */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101 for (cp = dbp + 1;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4102 *cp != '\0' && *cp != '(' && *cp != ')' && !isspace (*cp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4104 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4105 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4106 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 /* Find tags in TeX and LaTeX input files. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111 /* TEX_toktab is a table of TeX control sequences that define tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 Each TEX_tabent records one such control sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113 CONVERT THIS TO USE THE Stab TYPE!! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4114 struct TEX_tabent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4115 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4116 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4117 int len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4118 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4120 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4121
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4122 /* Default set of control sequences to put into TEX_toktab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4123 The value of environment var TEXTAGS is prepended to this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4124
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4125 char *TEX_defenv = "\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4126 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4127 :part:appendix:entry:index";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4128
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4129 void TEX_mode PP ((FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4130 struct TEX_tabent *TEX_decode_env PP ((char *evarname, char *defenv));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4131 int TEX_Token PP ((char *cp));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4133 char TEX_esc = '\\';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4134 char TEX_opgrp = '{';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4135 char TEX_clgrp = '}';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4137 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4138 * TeX/LaTeX scanning loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4139 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4140 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4141 TeX_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4142 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4143 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4144 char *cp, *lasthit;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4145 register int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4147 /* Select either \ or ! as escape character. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4148 TEX_mode (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4149
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4150 /* Initialize token table once from environment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4151 if (!TEX_toktab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4152 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4153
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4154 LOOP_ON_INPUT_LINES (inf, lb, cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4155 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4156 lasthit = cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4157 /* Look at each esc in line. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4158 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4160 if (*++cp == '\0')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161 break;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4162 linecharno += cp - lasthit;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4163 lasthit = cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 i = TEX_Token (lasthit);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4165 if (i >= 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4166 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4167 /* We seem to include the TeX command in the tag name.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4168 register char *p;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4169 for (p = lasthit + TEX_toktab[i].len;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4170 *p != '\0' && *p != TEX_clgrp;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4171 p++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4172 continue; */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4173 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4174 lb.buffer, lb.len, lineno, linecharno);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4175 break; /* We only tag a line once */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4179 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 #define TEX_LESC '\\'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 #define TEX_SESC '!'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183 #define TEX_cmt '%'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186 chars accordingly. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4188 TEX_mode (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4189 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 int c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4193 while ((c = getc (inf)) != EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 /* Skip to next line if we hit the TeX comment char. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 if (c == TEX_cmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 while (c != '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 c = getc (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 else if (c == TEX_LESC || c == TEX_SESC )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 if (c == TEX_LESC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 TEX_esc = TEX_LESC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206 TEX_opgrp = '{';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 TEX_clgrp = '}';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211 TEX_esc = TEX_SESC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 TEX_opgrp = '<';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 TEX_clgrp = '>';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4215 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218 /* Read environment and prepend it to the default string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4219 Build token table. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4220 struct TEX_tabent *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4221 TEX_decode_env (evarname, defenv)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4222 char *evarname;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4223 char *defenv;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4225 register char *env, *p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 struct TEX_tabent *tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228 int size, i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4230 /* Append default string to environment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4231 env = getenv (evarname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4232 if (!env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233 env = defenv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4234 else
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4235 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4236 char *oldenv = env;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4237 env = concat (oldenv, defenv, "");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4238 free (oldenv);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4239 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241 /* Allocate a token table */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 for (size = 1, p = env; p;)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4243 if ((p = etags_strchr (p, ':')) && *++p != '\0')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4244 size++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4245 /* Add 1 to leave room for null terminator. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4246 tab = xnew (size + 1, struct TEX_tabent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4247
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4248 /* Unpack environment string into token table. Be careful about */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249 /* zero-length strings (leading ':', "::" and trailing ':') */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4250 for (i = 0; *env;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4252 p = etags_strchr (env, ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 if (!p) /* End of environment string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 p = env + strlen (env);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 if (p - env > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 { /* Only non-zero strings. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4257 tab[i].name = savenstr (env, p - env);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 tab[i].len = strlen (tab[i].name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 i++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261 if (*p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4262 env = p + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4263 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 tab[i].name = NULL; /* Mark end of table. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 tab[i].len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270 return tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 /* If the text at CP matches one of the tag-defining TeX command names,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 return the pointer to the first occurrence of that command in TEX_toktab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 Otherwise return -1.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4276 Keep the capital `T' in `token' for dumb truncating compilers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 (this distinguishes it from `TEX_toktab' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4279 TEX_Token (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4280 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 for (i = 0; TEX_toktab[i].len > 0; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 return i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4290 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4291 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4292 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4293 * Assumes that the predicate starts at column 0.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4294 * Only the first clause of a predicate is added.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4295 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4296 int prolog_pred PP ((char *s, char *last));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4297 void prolog_skip_comment PP ((linebuffer *plb, FILE *inf));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4298 int prolog_atom PP ((char *s, int pos));
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4299
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4300 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4301 Prolog_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4302 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4304 char *cp, *last;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4305 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4306 int allocated;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4307
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4308 allocated = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4309 len = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4310 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4311
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4312 LOOP_ON_INPUT_LINES (inf, lb, cp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4313 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4314 if (cp[0] == '\0') /* Empty line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4315 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4316 else if (isspace (cp[0])) /* Not a predicate */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4317 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4318 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4319 prolog_skip_comment (&lb, inf);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4320 else if ((len = prolog_pred (cp, last)) > 0)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4321 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4322 /* Predicate. Store the function name so that we only
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4323 generate a tag for the first clause. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4324 if (last == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4325 last = xnew(len + 1, char);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4326 else if (len + 1 > allocated)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4327 last = xrnew (last, len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4328 allocated = len + 1;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4329 strncpy (last, cp, len);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4330 last[len] = '\0';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4331 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4334
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4335
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4337 prolog_skip_comment (plb, inf)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4338 linebuffer *plb;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4339 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 for (cp = plb->buffer; *cp != '\0'; cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346 if (cp[0] == '*' && cp[1] == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 return;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4348 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4349 linecharno += readline (plb, inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351 while (!feof(inf));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4353
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4354 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4355 * A predicate definition is added if it matches:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4356 * <beginning of line><Prolog Atom><whitespace>(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4357 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4358 * It is added to the tags database if it doesn't match the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4359 * name of the previous clause header.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4360 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4361 * Return the size of the name of the predicate, or 0 if no header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4362 * was found.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4363 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4364 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4365 prolog_pred (s, last)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4366 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4367 char *last; /* Name of last clause. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4368 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4369 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4370 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4371
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4372 pos = prolog_atom (s, 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4373 if (pos < 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4374 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4375
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4376 len = pos;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4377 pos = skip_spaces (s + pos) - s;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4378
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4379 if ((s[pos] == '(') || (s[pos] == '.'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4380 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4381 if (s[pos] == '(')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4382 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4383
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4384 /* Save only the first clause. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4385 if (last == NULL
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4386 || len != strlen (last)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4387 || !strneq (s, last, len))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4388 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4389 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4390 s, pos, lineno, linecharno);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4391 return len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4392 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4393 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4394 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4395 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4396
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4397 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4398 * Consume a Prolog atom.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4399 * Return the number of bytes consumed, or -1 if there was an error.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4400 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4401 * A prolog atom, in this context, could be one of:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4402 * - An alphanumeric sequence, starting with a lower case letter.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4403 * - A quoted arbitrary string. Single quotes can escape themselves.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4404 * Backslash quotes everything.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4405 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4406 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4407 prolog_atom (s, pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4408 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4409 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4410 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4411 int origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4412
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4413 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4414
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4415 if (islower(s[pos]) || (s[pos] == '_'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4416 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4417 /* The atom is unquoted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4418 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4419 while (isalnum(s[pos]) || (s[pos] == '_'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4420 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4421 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4422 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4423 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4424 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4425 else if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4426 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4427 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4428
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4429 while (1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4430 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4431 if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4432 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4433 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4434 if (s[pos] != '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4435 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4436 pos++; /* A double quote */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4437 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4438 else if (s[pos] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4439 /* Multiline quoted atoms are ignored. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4440 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4441 else if (s[pos] == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4442 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4443 if (s[pos+1] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4444 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4445 pos += 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4446 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4447 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4448 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4449 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4450 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4451 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4452 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4453 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4454 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4455
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4456 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4457 * Support for Erlang -- Anders Lindgren, Feb 1996.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4458 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4459 * Generates tags for functions, defines, and records.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4460 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4461 * Assumes that Erlang functions start at column 0.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4462 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4463 int erlang_func PP ((char *s, char *last));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4464 void erlang_attribute PP ((char *s));
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4465 int erlang_atom PP ((char *s, int pos));
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4466
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4467 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4468 Erlang_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4469 FILE *inf;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4470 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4471 char *cp, *last;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4472 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4473 int allocated;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4474
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4475 allocated = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4476 len = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4477 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4478
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4479 LOOP_ON_INPUT_LINES (inf, lb, cp)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4480 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4481 if (cp[0] == '\0') /* Empty line */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4482 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4483 else if (isspace (cp[0])) /* Not function nor attribute */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4484 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4485 else if (cp[0] == '%') /* comment */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4486 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4487 else if (cp[0] == '"') /* Sometimes, strings start in column one */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4488 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4489 else if (cp[0] == '-') /* attribute, e.g. "-define" */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4490 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4491 erlang_attribute (cp);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4492 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4493 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4494 else if ((len = erlang_func (cp, last)) > 0)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4495 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4496 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4497 * Function. Store the function name so that we only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4498 * generates a tag for the first clause.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4499 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4500 if (last == NULL)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4501 last = xnew (len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4502 else if (len + 1 > allocated)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4503 last = xrnew (last, len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4504 allocated = len + 1;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4505 strncpy (last, cp, len);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4506 last[len] = '\0';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4507 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4508 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4509 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4510
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4511
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4512 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4513 * A function definition is added if it matches:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4514 * <beginning of line><Erlang Atom><whitespace>(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4515 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4516 * It is added to the tags database if it doesn't match the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4517 * name of the previous clause header.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4518 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4519 * Return the size of the name of the function, or 0 if no function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4520 * was found.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4521 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4522 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4523 erlang_func (s, last)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4524 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4525 char *last; /* Name of last clause. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4526 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4527 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4528 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4529
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4530 pos = erlang_atom (s, 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4531 if (pos < 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4532 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4533
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4534 len = pos;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4535 pos = skip_spaces (s + pos) - s;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4536
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4537 /* Save only the first clause. */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4538 if (s[pos++] == '('
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4539 && (last == NULL
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4540 || len != strlen (last)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4541 || !strneq (s, last, len)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4542 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4543 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4544 s, pos, lineno, linecharno);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4545 return len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4546 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4547
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4548 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4549 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4550
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4551
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4552 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4553 * Handle attributes. Currently, tags are generated for defines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4554 * and records.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4555 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4556 * They are on the form:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4557 * -define(foo, bar).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4558 * -define(Foo(M, N), M+N).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4559 * -record(graph, {vtab = notable, cyclic = true}).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4560 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4561 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4562 erlang_attribute (s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4563 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4564 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4565 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4566 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4567
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4568 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4569 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4570 pos = skip_spaces (s + 7) - s;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4571 if (s[pos++] == '(')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4572 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4573 pos = skip_spaces (s + pos) - s;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4574 len = erlang_atom (s, pos);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4575 if (len != 0)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4576 pfnote ((CTAGS) ? savenstr (& s[pos], len) : NULL, TRUE,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4577 s, pos + len, lineno, linecharno);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4578 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4579 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4580 return;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4581 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4582
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4583
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4584 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4585 * Consume an Erlang atom (or variable).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4586 * Return the number of bytes consumed, or -1 if there was an error.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4587 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4588 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4589 erlang_atom (s, pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4590 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4591 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4592 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4593 int origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4594
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4595 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4596
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4597 if (isalpha (s[pos]) || s[pos] == '_')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4598 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4599 /* The atom is unquoted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4600 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4601 while (isalnum (s[pos]) || s[pos] == '_')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4602 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4603 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4604 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4605 else if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4606 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4607 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4608
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4609 while (1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4610 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4611 if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4612 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4613 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4614 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4615 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4616 else if (s[pos] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4617 /* Multiline quoted atoms are ignored. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4618 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4619 else if (s[pos] == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4620 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4621 if (s[pos+1] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4622 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4623 pos += 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4624 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4625 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4626 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4627 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4628 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4629 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4630 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4631 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4632 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4634 #ifdef ETAGS_REGEXPS
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4635
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4636 /* Take a string like "/blah/" and turn it into "blah", making sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4637 that the first and last characters are the same, and handling
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4638 quoted separator characters. Actually, stops on the occurrence of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4639 an unquoted separator. Also turns "\t" into a Tab character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4640 Returns pointer to terminating separator. Works in place. Null
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4641 terminates name string. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4642 char * scan_separators PP ((char *name));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4643 char *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4644 scan_separators (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4645 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4646 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4647 char sep = name[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4648 char *copyto = name;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
4649 bool quoted = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4651 for (++name; *name != '\0'; ++name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4652 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4653 if (quoted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4654 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4655 if (*name == 't')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4656 *copyto++ = '\t';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4657 else if (*name == sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4658 *copyto++ = sep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4659 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4660 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4661 /* Something else is quoted, so preserve the quote. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4662 *copyto++ = '\\';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4663 *copyto++ = *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4664 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4665 quoted = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4666 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4667 else if (*name == '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4668 quoted = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4669 else if (*name == sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4670 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4671 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4672 *copyto++ = *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4673 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4675 /* Terminate copied string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4676 *copyto = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4677 return name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4678 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4679
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4680 /* Look at the argument of --regex or --no-regex and do the right
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4681 thing. Same for each line of a regexp file. */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4682 void
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4683 analyse_regex (regex_arg)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4684 char *regex_arg;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4685 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4686 if (regex_arg == NULL)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4687 free_patterns (); /* --no-regex: remove existing regexps */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4688
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4689 /* A real --regexp option or a line in a regexp file. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4690 switch (regex_arg[0])
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4691 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4692 /* Comments in regexp file or null arg to --regex. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4693 case '\0':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4694 case ' ':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4695 case '\t':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4696 break;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4697
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4698 /* Read a regex file. This is recursive and may result in a
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4699 loop, which will stop when the file descriptors are exhausted. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4700 case '@':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4701 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4702 FILE *regexfp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4703 linebuffer regexbuf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4704 char *regexfile = regex_arg + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4705
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4706 /* regexfile is a file containing regexps, one per line. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4707 regexfp = fopen (regexfile, "r");
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4708 if (regexfp == NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4709 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4710 pfatal (regexfile);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4711 return;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4712 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4713 initbuffer (&regexbuf);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4714 while (readline_internal (&regexbuf, regexfp) > 0)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4715 analyse_regex (regexbuf.buffer);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4716 free (regexbuf.buffer);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4717 fclose (regexfp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4718 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4719 break;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4720
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4721 /* Regexp to be used for a specific language only. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4722 case '{':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4723 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4724 language *lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4725 char *lang_name = regex_arg + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4726 char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4727
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4728 for (cp = lang_name; *cp != '}'; cp++)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4729 if (*cp == '\0')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4730 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4731 error ("unterminated language name in regex: %s", regex_arg);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4732 return;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4733 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4734 *cp = '\0';
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4735 lang = get_language_from_name (lang_name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4736 if (lang == NULL)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4737 return;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4738 add_regex (cp + 1, lang);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4739 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4740 break;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4741
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4742 /* Regexp to be used for any language. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4743 default:
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4744 add_regex (regex_arg, NULL);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4745 break;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4746 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4747 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4748
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4749 /* Turn a name, which is an ed-style (but Emacs syntax) regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4750 expression, into a real regular expression by compiling it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4751 void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4752 add_regex (regexp_pattern, lang)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4753 char *regexp_pattern;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4754 language *lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4755 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4756 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4757 const char *err;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4758 struct re_pattern_buffer *patbuf;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4759 pattern *pp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4760
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4761
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4762 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4763 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4764 error ("%s: unterminated regexp", regexp_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4765 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4766 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4767 name = scan_separators (regexp_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4768 if (regexp_pattern[0] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4769 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4770 error ("null regexp", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4771 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4772 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4773 (void) scan_separators (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4775 patbuf = xnew (1, struct re_pattern_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4776 patbuf->translate = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4777 patbuf->fastmap = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4778 patbuf->buffer = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4779 patbuf->allocated = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4781 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4782 if (err != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4783 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4784 error ("%s while compiling pattern", err);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4785 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4786 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4787
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4788 pp = p_head;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4789 p_head = xnew (1, pattern);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4790 p_head->regex = savestr (regexp_pattern);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4791 p_head->p_next = pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4792 p_head->language = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4793 p_head->pattern = patbuf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4794 p_head->name_pattern = savestr (name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4795 p_head->error_signaled = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4796 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4798 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4799 * Do the substitutions indicated by the regular expression and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4800 * arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4801 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4802 char * substitute PP ((char *in, char *out, struct re_registers *regs));
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4803 char *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4804 substitute (in, out, regs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4805 char *in, *out;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4806 struct re_registers *regs;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4807 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4808 char *result, *t;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4809 int size, dig, diglen;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4810
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4811 result = NULL;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4812 size = strlen (out);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4813
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4814 /* Pass 1: figure out how much to allocate by finding all \N strings. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4815 if (out[size - 1] == '\\')
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4816 fatal ("pattern error in \"%s\"", out);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4817 for (t = etags_strchr (out, '\\');
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4818 t != NULL;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4819 t = etags_strchr (t + 2, '\\'))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4820 if (isdigit (t[1]))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4821 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4822 dig = t[1] - '0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4823 diglen = regs->end[dig] - regs->start[dig];
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4824 size += diglen - 2;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4825 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4826 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4827 size -= 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4828
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4829 /* Allocate space and do the substitutions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4830 result = xnew (size + 1, char);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4831
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4832 for (t = result; *out != '\0'; out++)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4833 if (*out == '\\' && isdigit (*++out))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4834 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4835 /* Using "dig2" satisfies my debugger. Bleah. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4836 dig = *out - '0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4837 diglen = regs->end[dig] - regs->start[dig];
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4838 strncpy (t, in + regs->start[dig], diglen);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4839 t += diglen;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4840 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4841 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4842 *t++ = *out;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4843 *t = '\0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4844
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4845 if (DEBUG && (t > result + size || t - result != strlen (result)))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4846 abort ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4848 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4849 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4850
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4851 /* Deallocate all patterns. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4852 void
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4853 free_patterns ()
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4854 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4855 pattern *pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4856 while (p_head != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4857 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4858 pp = p_head->p_next;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4859 free (p_head->regex);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4860 free (p_head->name_pattern);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4861 free (p_head);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4862 p_head = pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4863 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4864 return;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4865 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4867 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4868 /* Initialize a linebuffer for use */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4869 void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4870 initbuffer (lbp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4871 linebuffer *lbp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4872 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4873 lbp->size = 200;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4874 lbp->buffer = xnew (200, char);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4875 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4877 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4878 * Read a line of text from `stream' into `lbp', excluding the
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4879 * newline or CR-NL, if any. Return the number of characters read from
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4880 * `stream', which is the length of the line including the newline.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4881 *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4882 * On DOS or Windows we do not count the CR character, if any, before the
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4883 * NL, in the returned length; this mirrors the behavior of emacs on those
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4884 * platforms (for text files, it translates CR-NL to NL as it reads in the
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4885 * file).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4886 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4887 long
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4888 readline_internal (lbp, stream)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4889 linebuffer *lbp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4890 register FILE *stream;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4891 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4892 char *buffer = lbp->buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4893 register char *p = lbp->buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4894 register char *pend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4895 int chars_deleted;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4896
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4897 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4898
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4899 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4900 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4901 register int c = getc (stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4902 if (p == pend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4903 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4904 /* We're at the end of linebuffer: expand it. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4905 lbp->size *= 2;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4906 buffer = xrnew (buffer, lbp->size, char);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4907 p += buffer - lbp->buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4908 pend = buffer + lbp->size;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4909 lbp->buffer = buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4910 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4911 if (c == EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4912 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4913 *p = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4914 chars_deleted = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4915 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4916 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4917 if (c == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4918 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4919 if (p > buffer && p[-1] == '\r')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4920 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4921 p -= 1;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4922 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4923 /* Assume CRLF->LF translation will be performed by Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4924 when loading this file, so CRs won't appear in the buffer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4925 It would be cleaner to compensate within Emacs;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4926 however, Emacs does not know how many CRs were deleted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4927 before any given point in the file. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4928 chars_deleted = 1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4929 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4930 chars_deleted = 2;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4931 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4932 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4933 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4934 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4935 chars_deleted = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4936 }
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4937 *p = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4938 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4939 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4940 *p++ = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4941 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4942 lbp->len = p - buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4943
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4944 return lbp->len + chars_deleted;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4945 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4947 /*
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4948 * Like readline_internal, above, but in addition try to match the
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4949 * input line against relevant regular expressions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4950 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4951 long
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4952 readline (lbp, stream)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4953 linebuffer *lbp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4954 FILE *stream;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4955 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4956 /* Read new line. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4957 long result = readline_internal (lbp, stream);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4958 #ifdef ETAGS_REGEXPS
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4959 int match;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4960 pattern *pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4961
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4962 /* Match against relevant patterns. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4963 if (lbp->len > 0)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4964 for (pp = p_head; pp != NULL; pp = pp->p_next)
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4965 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4966 /* Only use generic regexps or those for the current language. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4967 if (pp->language != NULL && pp->language != curlang)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4968 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4969
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4970 match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4971 switch (match)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4972 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4973 case -2:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4974 /* Some error. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4975 if (!pp->error_signaled)
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4976 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4977 error ("error while matching \"%s\"", pp->regex);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4978 pp->error_signaled = TRUE;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4979 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4980 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4981 case -1:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4982 /* No match. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4983 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4984 default:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4985 /* Match occurred. Construct a tag. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4986 if (pp->name_pattern[0] != '\0')
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4987 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4988 /* Make a named tag. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4989 char *name = substitute (lbp->buffer,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4990 pp->name_pattern, &pp->regs);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4991 if (name != NULL)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4992 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4993 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4994 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4995 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4996 /* Make an unnamed tag. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4997 pfnote ((char *)NULL, TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4998 lbp->buffer, match, lineno, linecharno);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4999 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5000 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5001 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5002 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5003 #endif /* ETAGS_REGEXPS */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5004
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5005 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5006 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5008 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5009 * Return a pointer to a space of size strlen(cp)+1 allocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5010 * with xnew where the string CP has been copied.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5011 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5012 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5013 savestr (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5014 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5015 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5016 return savenstr (cp, strlen (cp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5017 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5019 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5020 * Return a pointer to a space of size LEN+1 allocated with xnew where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5021 * the string CP has been copied for at most the first LEN characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5022 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5023 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5024 savenstr (cp, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5025 char *cp;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5026 int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5027 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5028 register char *dp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5029
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5030 dp = xnew (len + 1, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5031 strncpy (dp, cp, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5032 dp[len] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5033 return dp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5034 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5035
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5036 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5037 * Return the ptr in sp at which the character c last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5038 * appears; NULL if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5039 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5040 * Identical to System V strrchr, included for portability.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5041 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5042 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5043 etags_strrchr (sp, c)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5044 register char *sp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5045 register int c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5046 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5047 register char *r;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5049 r = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5050 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5051 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5052 if (*sp == c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5053 r = sp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5054 } while (*sp++);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5055 return r;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5056 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5059 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5060 * Return the ptr in sp at which the character c first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5061 * appears; NULL if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5062 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5063 * Identical to System V strchr, included for portability.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5064 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5065 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5066 etags_strchr (sp, c)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5067 register char *sp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5068 register int c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5069 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5070 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5071 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5072 if (*sp == c)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5073 return sp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5074 } while (*sp++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5075 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5076 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5077
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5078 /* Skip spaces, return new pointer. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5079 char *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5080 skip_spaces (cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5081 char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5082 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5083 while (isspace (*cp)) /* isspace('\0')==FALSE */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5084 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5085 return cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5086 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5087
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5088 /* Skip non spaces, return new pointer. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5089 char *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5090 skip_non_spaces (cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5091 char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5092 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5093 while (!iswhite (*cp)) /* iswhite('\0')==TRUE */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5094 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5095 return cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5096 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5097
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5098 /* Print error message and exit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5099 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5100 fatal (s1, s2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5101 char *s1, *s2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5102 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5103 error (s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5104 exit (BAD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5105 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5107 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5108 pfatal (s1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5109 char *s1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5110 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5111 perror (s1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5112 exit (BAD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5113 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5114
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5115 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5116 suggest_asking_for_help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5117 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5118 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5119 progname,
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5120 #ifdef LONG_OPTIONS
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5121 "--help"
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5122 #else
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5123 "-h"
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5124 #endif
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5125 );
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5126 exit (BAD);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5127 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5128
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5129 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5130 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5131 error (s1, s2)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5132 const char *s1, *s2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5133 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5134 fprintf (stderr, "%s: ", progname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5135 fprintf (stderr, s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5136 fprintf (stderr, "\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5139 /* Return a newly-allocated string whose contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5140 concatenate those of s1, s2, s3. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5141 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5142 concat (s1, s2, s3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5143 char *s1, *s2, *s3;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5144 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5145 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5146 char *result = xnew (len1 + len2 + len3 + 1, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5148 strcpy (result, s1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5149 strcpy (result + len1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5150 strcpy (result + len1 + len2, s3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5151 result[len1 + len2 + len3] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5153 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5154 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5156 /* Does the same work as the system V getcwd, but does not need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5157 guess the buffer size in advance. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5158 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5159 etags_getcwd ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5160 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5161 #ifdef HAVE_GETCWD
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5162 int bufsize = 200;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5163 char *path = xnew (bufsize, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5165 while (getcwd (path, bufsize) == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5166 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5167 if (errno != ERANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5168 pfatal ("getcwd");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5169 bufsize *= 2;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5170 free (path);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5171 path = xnew (bufsize, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5172 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5173
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5174 canonicalize_filename (path);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5175 return path;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5176
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5177 #else /* not HAVE_GETCWD */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5178 #ifdef MSDOS
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5179 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5180
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5181 getwd (path);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5182
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5183 for (p = path; *p != '\0'; p++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5184 if (*p == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5185 *p = '/';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5186 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5187 *p = lowcase (*p);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5188
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5189 return strdup (path);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5190 #else /* not MSDOS */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5191 linebuffer path;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5192 FILE *pipe;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5194 initbuffer (&path);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5195 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5196 if (pipe == NULL || readline_internal (&path, pipe) == 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5197 pfatal ("pwd");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5198 pclose (pipe);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5200 return path.buffer;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5201 #endif /* not MSDOS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5202 #endif /* not HAVE_GETCWD */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5203 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5204
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5205 /* Return a newly allocated string containing the file name of FILE
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5206 relative to the absolute directory DIR (which should end with a slash). */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5207 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5208 relative_filename (file, dir)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5209 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5210 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5211 char *fp, *dp, *afn, *res;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5212 int i;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5213
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5214 /* Find the common root of file and dir (with a trailing slash). */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5215 afn = absolute_filename (file, cwd);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5216 fp = afn;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5217 dp = dir;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5218 while (*fp++ == *dp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5219 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5220 fp--, dp--; /* back to the first differing char */
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5221 do /* look at the equal chars until '/' */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5222 fp--, dp--;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5223 while (*fp != '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5224
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5225 /* Build a sequence of "../" strings for the resulting relative file name. */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5226 i = 0;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5227 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5228 i += 1;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5229 res = xnew (3*i + strlen (fp + 1) + 1, char);
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5230 res[0] = '\0';
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5231 while (i-- > 0)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5232 strcat (res, "../");
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5233
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5234 /* Add the file name relative to the common root of file and dir. */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5235 strcat (res, fp + 1);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5236 free (afn);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5238 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5239 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5240
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5241 /* Return a newly allocated string containing the absolute file name
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5242 of FILE given DIR (which should end with a slash). */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5243 char *
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5244 absolute_filename (file, dir)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5245 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5246 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5247 char *slashp, *cp, *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5248
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5249 if (filename_is_absolute (file))
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5250 res = savestr (file);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5251 #ifdef DOS_NT
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5252 /* We don't support non-absolute file names with a drive
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5253 letter, like `d:NAME' (it's too much hassle). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5254 else if (file[1] == ':')
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5255 fatal ("%s: relative file names with drive letters not supported", file);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5256 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5257 else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5258 res = concat (dir, file, "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5260 /* Delete the "/dirname/.." and "/." substrings. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5261 slashp = etags_strchr (res, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5262 while (slashp != NULL && slashp[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5263 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5264 if (slashp[1] == '.')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5265 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5266 if (slashp[2] == '.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5267 && (slashp[3] == '/' || slashp[3] == '\0'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5268 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5269 cp = slashp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5270 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5271 cp--;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5272 while (cp >= res && !filename_is_absolute (cp));
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5273 if (cp < res)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5274 cp = slashp; /* the absolute name begins with "/.." */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5275 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5276 /* Under MSDOS and NT we get `d:/NAME' as absolute
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5277 file name, so the luser could say `d:/../NAME'.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5278 We silently treat this as `d:/NAME'. */
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5279 else if (cp[0] != '/')
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5280 cp = slashp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5281 #endif
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5282 strcpy (cp, slashp + 3);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5283 slashp = cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5284 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5286 else if (slashp[2] == '/' || slashp[2] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5287 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5288 strcpy (slashp, slashp + 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5289 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5290 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5293 slashp = etags_strchr (slashp + 1, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5294 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5295
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5296 if (res[0] == '\0')
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5297 return savestr ("/");
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5298 else
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5299 return res;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5300 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5302 /* Return a newly allocated string containing the absolute
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5303 file name of dir where FILE resides given DIR (which should
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5304 end with a slash). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5305 char *
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5306 absolute_dirname (file, dir)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5307 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5308 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5309 char *slashp, *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5310 char save;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5311
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5312 canonicalize_filename (file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5313 slashp = etags_strrchr (file, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5314 if (slashp == NULL)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5315 return savestr (dir);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5316 save = slashp[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5317 slashp[1] = '\0';
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5318 res = absolute_filename (file, dir);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5319 slashp[1] = save;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5320
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5321 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5322 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5323
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5324 /* Whether the argument string is an absolute file name. The argument
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5325 string must have been canonicalized with canonicalize_filename. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5326 bool
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5327 filename_is_absolute (fn)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5328 char *fn;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5329 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5330 return (fn[0] == '/'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5331 #ifdef DOS_NT
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5332 || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5333 #endif
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5334 );
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5335 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5336
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5337 /* Translate backslashes into slashes. Works in place. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5338 void
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5339 canonicalize_filename (fn)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5340 register char *fn;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5341 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5342 #ifdef DOS_NT
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5343 for (; *fn != '\0'; fn++)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5344 if (*fn == '\\')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5345 *fn = '/';
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5346 #else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5347 /* No action. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5348 #endif
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5349 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5350
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5351 /* Increase the size of a linebuffer. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5352 void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5353 grow_linebuffer (lbp, toksize)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5354 linebuffer *lbp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5355 int toksize;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5356 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5357 while (lbp->size < toksize)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5358 lbp->size *= 2;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5359 lbp->buffer = xrnew (lbp->buffer, lbp->size, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5360 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5361
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5362 /* Like malloc but get fatal error if memory is exhausted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5363 long *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5364 xmalloc (size)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5365 unsigned int size;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5366 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5367 long *result = (long *) malloc (size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5368 if (result == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5369 fatal ("virtual memory exhausted", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5370 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5371 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5372
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5373 long *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5374 xrealloc (ptr, size)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5375 char *ptr;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5376 unsigned int size;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5377 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5378 long *result = (long *) realloc (ptr, size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5379 if (result == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5380 fatal ("virtual memory exhausted", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5381 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5382 }