annotate lib-src/ootags.c @ 347:7c94d56991e1 r21-1-3

Import from CVS: tag r21-1-3
author cvs
date Mon, 13 Aug 2007 10:53:48 +0200
parents 57709be46d1b
children a4f53d9b3154
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1 /* Tags file maker to go with GNU Emacs
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3 Free Software Foundation, Inc. and Ken Arnold
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5 This file is not considered part of GNU Emacs.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
6
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
10 (at your option) any later version.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
11
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
15 GNU General Public License for more details.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
16
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
18 along with this program; if not, write to the Free Software Foundation,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
20
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
21 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
22 * Authors:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
23 * Ctags originally by Ken Arnold.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
24 * Fortran added by Jim Kleckner.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
25 * Ed Pelegri-Llopart added C typedefs.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
26 * Gnu Emacs TAGS format and modifications by RMS?
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
27 * Sam Kendall added C++.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
28 * Francesco Potorti` reorganised C and C++ based on work by Joe Wells.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
29 * Regexp tags by Tom Tromey.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
30 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
32 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
33
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
34 char pot_etags_version[] = "@(#) pot revision number is 12.28";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
35
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
36 /* Prototyping magic snarfed from gmalloc.c */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
37 #if defined (__cplusplus) || defined (__STDC__)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
38 #undef PP
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
39 #define PP(args) args
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
40 #undef __ptr_t
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
41 #define __ptr_t void *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
42 #else /* Not C++ or ANSI C. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
43 #undef PP
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
44 #define PP(args) ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
45 #undef const
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
46 #define const
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
47 #undef __ptr_t
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
48 #define __ptr_t char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
49 #endif /* C++ or ANSI C. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
50
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
51 #ifdef HAVE_CONFIG_H
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
52 # include <config.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
53 /* On some systems, Emacs defines static as nothing for the sake
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
54 of unexec. We don't want that here since we don't use unexec. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
55 # undef static
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
56 # define ETAGS_REGEXPS /* use the regexp features */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
57 # define LONG_OPTIONS /* accept long options */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
58 #endif /* HAVE_CONFIG_H */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
59
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
60 #define TRUE 1
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
61 #define FALSE 0
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
62
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
63 #ifndef DEBUG
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
64 # define DEBUG FALSE
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
65 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
66
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
67 #ifdef MSDOS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
68 # include <fcntl.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
69 # include <sys/param.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
70 # include <io.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
71 # ifndef HAVE_CONFIG_H
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
72 # define DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
73 # include <sys/config.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
74 # endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
75 #endif /* MSDOS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
76
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
77 #ifdef WINDOWSNT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
78 # include <stdlib.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
79 # include <fcntl.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
80 # include <string.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
81 # include <io.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
82 # define MAXPATHLEN _MAX_PATH
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
83 # ifdef HAVE_CONFIG_H
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
84 # undef HAVE_NTGUI
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
85 # else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
86 # define DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
87 # define HAVE_GETCWD
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
88 # endif /* not HAVE_CONFIG_H */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
89 #endif /* WINDOWSNT */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
90
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
91 #if !defined (WINDOWSNT) && defined (STDC_HEADERS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
92 #include <stdlib.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
93 #include <string.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
94 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
95
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
96 #ifdef HAVE_UNISTD_H
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
97 # include <unistd.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
98 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
99 # ifdef HAVE_GETCWD
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
100 extern char *getcwd ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
101 # endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
102 #endif /* HAVE_UNISTD_H */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
103
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
104 #include <stdio.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
105 #include <ctype.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
106 #include <errno.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
107 #ifndef errno
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
108 extern int errno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
109 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
110 #include <sys/types.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
111 #include <sys/stat.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
112
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
113 #if !defined (S_ISREG) && defined (S_IFREG)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
114 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
115 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
116
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
117 #ifdef LONG_OPTIONS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
118 # include <getopt.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
119 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
120 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
121 extern char *optarg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
122 extern int optind, opterr;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
123 #endif /* LONG_OPTIONS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
124
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
125 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
126 # include <regex.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
127 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
128
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
129 /* Define CTAGS to make the program "ctags" compatible with the usual one.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
130 Leave it undefined to make the program "etags", which makes emacs-style
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
131 tag tables and tags typedefs, #defines and struct/union/enum by default. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
132 #ifdef CTAGS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
133 # undef CTAGS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
134 # define CTAGS TRUE
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
135 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
136 # define CTAGS FALSE
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
137 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
138
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
139 /* Exit codes for success and failure. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
140 #ifdef VMS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
141 # define GOOD 1
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
142 # define BAD 0
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
143 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
144 # define GOOD 0
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
145 # define BAD 1
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
146 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
147
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
148 /* C extensions. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
149 #define C_PLPL 0x00001 /* C++ */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
150 #define C_STAR 0x00003 /* C* */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
151 #define C_JAVA 0x00005 /* JAVA */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
152 #define YACC 0x10000 /* yacc file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
153
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
154 #define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
155 && (abort (), 1)) || !strcmp (s, t))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
156 #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
157 && (abort (), 1)) || !strncmp (s, t, n))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
158
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
159 #define lowcase(c) tolower ((char)c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
160
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
161 #define CHARS 256 /* 2^sizeof(char) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
162 #define CHAR(x) ((unsigned int)x & (CHARS - 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
163 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
164 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
165 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
166 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
167 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
168
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
169 /*#ifdef INFODOCK*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
170 /*#undef OO_BROWSER*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
171 /* Due to the way this file is constructed, this unfortunately doesn't */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
172 /* work except for documentation purposes. -slb */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
173 #define OO_BROWSER 1
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
174 /*#endif*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
175
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
176 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
177 #define set_construct(construct) \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
178 if (!oo_browser_construct) oo_browser_construct = construct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
179 void oo_browser_clear_all_globals();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
180 void oo_browser_clear_some_globals();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
181 void oo_browser_check_and_clear_structtype();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
182 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
183
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
184 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
185 * xnew, xrnew -- allocate, reallocate storage
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
186 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
187 * SYNOPSIS: Type *xnew (int n, Type);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
188 * Type *xrnew (OldPointer, int n, Type);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
189 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
190 #ifdef chkmalloc
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
191 # include "chkmalloc.h"
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
192 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
193 (n) * sizeof (Type)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
194 # define xrnew(op,n,Type) ((Type *) trace_realloc (__FILE__, __LINE__, \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
195 (op), (n) * sizeof (Type)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
196 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
197 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
198 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
199 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
200
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
201 typedef int bool;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
202
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
203 typedef void Lang_function ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
204
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
205 typedef struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
206 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
207 char *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
208 Lang_function *function;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
209 char **suffixes;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
210 char **interpreters;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
211 } language;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
212
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
213 typedef struct node_st
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
214 { /* sorting structure */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
215 char *name; /* function or type name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
216 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
217 short int construct; /* Construct type for the OO-Browser */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
218 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
219 char *file; /* file name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
220 bool is_func; /* use pattern or line no */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
221 bool been_warned; /* set if noticed dup */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
222 int lno; /* line number tag is on */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
223 long cno; /* character number line starts on */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
224 char *pat; /* search pattern */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
225 struct node_st *left, *right; /* left and right sons */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
226 } node;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
227
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
228 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
229 /* If you add to this array, you must add a corresponding entry to the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
230 following enum. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
231 static char *oo_browser_default_classes[] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
232 /* Lack of square brackets around some of these entries are intentional. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
233 {"null", "class", "method", "[constant]", "[enumeration]", "[enum_label]",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
234 "extern", "[function]", "[macro]", "objc", "[structure]", "[type]",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
235 "[union]", "[variable]"};
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
236
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
237 /* If you add to this enum, you must add a corresponding entry to the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
238 preceding array. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
239 enum oo_browser_constructs {C_NULL, C_CLASS, C_METHOD, C_CONSTANT, C_ENUMERATION,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
240 C_ENUM_LABEL, C_EXTERN, C_FUNCTION, C_MACRO,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
241 C_OBJC, C_STRUCTURE, C_TYPE, C_UNION, C_VARIABLE};
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
242
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
243 enum oo_browser_constructs oo_browser_construct = C_NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
244 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
245
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
246 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
247 * A `linebuffer' is a structure which holds a line of text.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
248 * `readline_internal' reads a line from a stream into a linebuffer
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
249 * and works regardless of the length of the line.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
250 * SIZE is the size of BUFFER, LEN is the length of the string in
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
251 * BUFFER after readline reads it.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
252 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
253 typedef struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
254 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
255 long size;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
256 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
257 char *buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
258 } linebuffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
259
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
260 extern char *getenv PP ((const char *envvar));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
261
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
262 /* Many compilers barf on this:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
263 Lang_function Asm_labels;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
264 so let's write it this way */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
265 void Asm_labels PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
266 void C_entries PP ((int c_ext, FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
267 void default_C_entries PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
268 void plain_C_entries PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
269 void Cjava_entries PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
270 void Cplusplus_entries PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
271 void Yacc_entries PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
272 void Cobol_paragraphs PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
273 void Cstar_entries PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
274 void Erlang_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
275 void Fortran_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
276 void Lisp_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
277 void Pascal_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
278 void Perl_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
279 void Postscript_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
280 void Prolog_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
281 void Python_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
282 void Scheme_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
283 void TeX_functions PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
284 void just_read_file PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
285
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
286 void print_language_names PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
287 void print_version PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
288 void print_help PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
289
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
290 language *get_language_from_name PP ((char *name));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
291 language *get_language_from_interpreter PP ((char *interpreter));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
292 language *get_language_from_suffix PP ((char *suffix));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
293 int total_size_of_entries PP ((node *np));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
294 long readline PP ((linebuffer *lbp, FILE *stream));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
295 long readline_internal PP ((linebuffer *lbp, FILE *stream));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
296 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
297 void analyse_regex PP ((char *regex_arg));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
298 void add_regex PP ((char *regexp_pattern, language *lang));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
299 void free_patterns PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
300 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
301 void error PP ((const char *s1, const char *s2));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
302 void suggest_asking_for_help PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
303 void fatal PP ((char *s1, char *s2));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
304 void pfatal PP ((char *s1));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
305 void add_node PP ((node *np, node **cur_node_p));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
306
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
307 void init PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
308 void initbuffer PP ((linebuffer *lbp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
309 void find_entries PP ((char *file, FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
310 void free_tree PP ((node *np));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
311 void pfnote PP ((char *name, bool is_func, char *linestart, int linelen, int lno, long cno));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
312 void new_pfnote PP ((char *name, int namelen, bool is_func, char *linestart, int linelen, int lno, long cno));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
313 void process_file PP ((char *file));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
314 void put_entries PP ((node *np));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
315 void takeprec PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
316
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
317 char *concat PP ((char *s1, char *s2, char *s3));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
318 char *skip_spaces PP ((char *cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
319 char *skip_non_spaces PP ((char *cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
320 char *savenstr PP ((char *cp, int len));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
321 char *savestr PP ((char *cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
322 char *etags_strchr PP ((char *sp, int c));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
323 char *etags_strrchr PP ((char *sp, int c));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
324 char *etags_getcwd PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
325 char *relative_filename PP ((char *file, char *dir));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
326 char *absolute_filename PP ((char *file, char *dir));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
327 char *absolute_dirname PP ((char *file, char *dir));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
328 bool filename_is_absolute PP ((char *fn));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
329 void canonicalize_filename PP ((char *fn));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
330 void grow_linebuffer PP ((linebuffer *lbp, int toksize));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
331 long *xmalloc PP ((unsigned int size));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
332 long *xrealloc PP ((char *ptr, unsigned int size));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
333
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
334
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
335 char searchar = '/'; /* use /.../ searches */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
336
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
337 char *tagfile; /* output file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
338 char *progname; /* name this program was invoked with */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
339 char *cwd; /* current working directory */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
340 char *tagfiledir; /* directory of tagfile */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
341 FILE *tagf; /* ioptr for tags file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
342
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
343 char *curfile; /* current input file name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
344 language *curlang; /* current language */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
345
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
346 int lineno; /* line number of current line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
347 long charno; /* current character number */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
348 long linecharno; /* charno of start of current line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
349 char *dbp; /* pointer to start of current tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
350 node *head; /* the head of the binary tree of tags */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
351
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
352 linebuffer lb; /* the current line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
353 linebuffer token_name; /* used by C_entries as a temporary area */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
354 struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
355 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
356 long linepos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
357 linebuffer lb; /* used by C_entries instead of lb */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
358 } lbs[2];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
359
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
360 /* boolean "functions" (see init) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
361 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
362 char
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
363 /* white chars */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
364 *white = " \f\t\n\r",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
365 /* not in a name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
366 *nonam = " \f\t\n\r(=,[;",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
367 /* token ending chars */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
368 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
369 /* token starting chars */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
370 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
371 /* valid in-token chars */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
372 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
373
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
374 bool append_to_tagfile; /* -a: append to tags */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
375 /* The following four default to TRUE for etags, but to FALSE for ctags. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
376 bool typedefs; /* -t: create tags for C typedefs */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
377 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
378 /* 0 struct/enum/union decls, and C++ */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
379 /* member functions. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
380 bool constantypedefs; /* -d: create tags for C #define, enum */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
381 /* constants and variables. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
382 /* -D: opposite of -d. Default under ctags. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
383 bool globals; /* create tags for global variables */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
384 bool members; /* create tags for C member variables */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
385 bool update; /* -u: update tags */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
386 bool vgrind_style; /* -v: create vgrind style index output */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
387 bool no_warnings; /* -w: suppress warnings */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
388 bool cxref_style; /* -x: create cxref style output */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
389 bool cplusplus; /* .[hc] means C++, not C */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
390 bool noindentypedefs; /* -I: ignore indentation in C */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
391 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
392 bool oo_browser_format; /* -O: OO-Browser tags format */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
393 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
394
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
395 #ifdef LONG_OPTIONS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
396 struct option longopts[] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
397 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
398 { "append", no_argument, NULL, 'a' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
399 { "backward-search", no_argument, NULL, 'B' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
400 { "c++", no_argument, NULL, 'C' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
401 { "cxref", no_argument, NULL, 'x' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
402 { "defines", no_argument, NULL, 'd' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
403 { "no-defines", no_argument, NULL, 'D' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
404 { "globals", no_argument, &globals, TRUE },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
405 { "no-globals", no_argument, &globals, FALSE },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
406 { "help", no_argument, NULL, 'h' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
407 { "help", no_argument, NULL, 'H' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
408 { "ignore-indentation", no_argument, NULL, 'I' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
409 { "include", required_argument, NULL, 'i' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
410 { "language", required_argument, NULL, 'l' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
411 { "members", no_argument, &members, TRUE },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
412 { "no-members", no_argument, &members, FALSE },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
413 { "no-warn", no_argument, NULL, 'w' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
414 { "output", required_argument, NULL, 'o' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
415 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
416 { "oo-browser", no_argument, NULL, 'O' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
417 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
418 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
419 { "regex", required_argument, NULL, 'r' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
420 { "no-regex", no_argument, NULL, 'R' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
421 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
422 { "typedefs", no_argument, NULL, 't' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
423 { "typedefs-and-c++", no_argument, NULL, 'T' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
424 { "update", no_argument, NULL, 'u' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
425 { "version", no_argument, NULL, 'V' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
426 { "vgrind", no_argument, NULL, 'v' },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
427 { 0 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
428 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
429 #endif /* LONG_OPTIONS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
430
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
431 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
432 /* Structure defining a regular expression. Elements are
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
433 the compiled pattern, and the name string. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
434 typedef struct pattern
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
435 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
436 struct pattern *p_next;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
437 language *language;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
438 char *regex;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
439 struct re_pattern_buffer *pattern;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
440 struct re_registers regs;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
441 char *name_pattern;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
442 bool error_signaled;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
443 } pattern;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
444
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
445 /* Array of all regexps. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
446 pattern *p_head = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
447 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
448
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
449 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
450 * Language stuff.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
451 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
452
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
453 /* Non-NULL if language fixed. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
454 language *forced_lang = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
455
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
456 /* Assembly code */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
457 char *Asm_suffixes [] = { "a", /* Unix assembler */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
458 "asm", /* Microcontroller assembly */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
459 "def", /* BSO/Tasking definition includes */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
460 "inc", /* Microcontroller include files */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
461 "ins", /* Microcontroller include files */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
462 "s", "sa", /* Unix assembler */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
463 "src", /* BSO/Tasking C compiler output */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
464 NULL
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
465 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
466
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
467 /* Note that .c and .h can be considered C++, if the --c++ flag was
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
468 given. That is why default_C_entries is called here. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
469 char *default_C_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
470 { "c", "h", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
471
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
472 char *Cplusplus_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
473 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
474 "M", /* Objective C++ */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
475 "pdb", /* Postscript with C syntax */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
476 NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
477
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
478 char *Cjava_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
479 { "java", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
480
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
481 char *Cobol_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
482 { "COB", "cob", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
483
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
484 char *Cstar_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
485 { "cs", "hs", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
486
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
487 char *Erlang_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
488 { "erl", "hrl", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
489
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
490 char *Fortran_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
491 { "F", "f", "f90", "for", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
492
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
493 char *Lisp_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
494 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
495
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
496 char *Pascal_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
497 { "p", "pas", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
498
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
499 char *Perl_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
500 { "pl", "pm", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
501 char *Perl_interpreters [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
502 { "perl", "@PERL@", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
503
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
504 char *plain_C_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
505 { "pc", /* Pro*C file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
506 "m", /* Objective C file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
507 "lm", /* Objective lex file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
508 NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
509
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
510 char *Postscript_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
511 { "ps", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
512
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
513 char *Prolog_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
514 { "prolog", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
515
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
516 char *Python_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
517 { "py", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
518
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
519 /* Can't do the `SCM' or `scm' prefix with a version number. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
520 char *Scheme_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
521 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "ss", "t", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
522
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
523 char *TeX_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
524 { "TeX", "bib", "clo", "cls", "ltx", "sty", "tex", NULL };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
525
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
526 char *Yacc_suffixes [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
527 { "y", "ym", NULL }; /* .ym is Objective yacc file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
528
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
529 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
530 * Table of languages.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
531 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
532 * It is ok for a given function to be listed under more than one
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
533 * name. I just didn't.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
534 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
535
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
536 language lang_names [] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
537 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
538 { "asm", Asm_labels, Asm_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
539 { "c", default_C_entries, default_C_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
540 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
541 { "c*", Cstar_entries, Cstar_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
542 { "cobol", Cobol_paragraphs, Cobol_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
543 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
544 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
545 { "java", Cjava_entries, Cjava_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
546 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
547 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
548 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
549 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
550 { "proc", plain_C_entries, plain_C_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
551 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
552 { "python", Python_functions, Python_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
553 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
554 { "tex", TeX_functions, TeX_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
555 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
556 { "auto", NULL }, /* default guessing scheme */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
557 { "none", just_read_file }, /* regexp matching only */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
558 { NULL, NULL } /* end of list */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
559 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
560
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
561
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
562 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
563 print_language_names ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
564 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
565 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
566 char **ext;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
567
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
568 puts ("\nThese are the currently supported languages, along with the\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
569 default file name suffixes:");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
570 for (lang = lang_names; lang->name != NULL; lang++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
571 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
572 printf ("\t%s\t", lang->name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
573 if (lang->suffixes != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
574 for (ext = lang->suffixes; *ext != NULL; ext++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
575 printf (" .%s", *ext);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
576 puts ("");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
577 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
578 puts ("Where `auto' means use default language for files based on file\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
579 name suffix, and `none' means only do regexp processing on files.\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
580 If no language is specified and no matching suffix is found,\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
581 the first line of the file is read for a sharp-bang (#!) sequence\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
582 followed by the name of an interpreter. If no such sequence is found,\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
583 Fortran is tried first; if no tags are found, C is tried next.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
584 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
585
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
586 #ifndef VERSION
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
587 # define VERSION "20"
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
588 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
589 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
590 print_version ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
591 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
592 printf ("%s (GNU Emacs %s)\n", (CTAGS) ? "ctags" : "etags", VERSION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
593 puts ("Copyright (C) 1996 Free Software Foundation, Inc. and Ken Arnold");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
594 puts ("This program is distributed under the same terms as Emacs");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
595
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
596 exit (GOOD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
597 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
598
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
599 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
600 print_help ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
601 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
602 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
603 \n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
604 These are the options accepted by %s.\n", progname, progname);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
605 #ifdef LONG_OPTIONS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
606 puts ("You may use unambiguous abbreviations for the long option names.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
607 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
608 puts ("Long option names do not work with this executable, as it is not\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
609 linked with GNU getopt.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
610 #endif /* LONG_OPTIONS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
611 puts ("A - as file name means read names from stdin (one per line).");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
612 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
613 printf (" Absolute names are stored in the output file as they are.\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
614 Relative ones are stored relative to the output file's directory.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
615 puts ("\n");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
616
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
617 puts ("-a, --append\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
618 Append tag entries to existing tags file.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
619
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
620 if (CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
621 puts ("-B, --backward-search\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
622 Write the search commands for the tag entries using '?', the\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
623 backward-search command instead of '/', the forward-search command.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
624
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
625 puts ("-C, --c++\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
626 Treat files whose name suffix defaults to C language as C++ files.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
627
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
628 if (CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
629 puts ("-d, --defines\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
630 Create tag entries for C #define constants and enum constants, too.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
631 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
632 puts ("-D, --no-defines\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
633 Don't create tag entries for C #define constants and enum constants.\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
634 This makes the tags file smaller.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
635
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
636 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
637 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
638 puts ("-i FILE, --include=FILE\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
639 Include a note in tag file indicating that, when searching for\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
640 a tag, one should also consult the tags file FILE after\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
641 checking the current file.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
642 puts ("-l LANG, --language=LANG\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
643 Force the following files to be considered as written in the\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
644 named language up to the next --language=LANG option.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
645 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
646
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
647 if (CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
648 puts ("--globals\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
649 Create tag entries for global variables in some languages.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
650 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
651 puts ("--no-globals\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
652 Do not create tag entries for global variables in some\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
653 languages. This makes the tags file smaller.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
654 puts ("--members\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
655 Create tag entries for member variables in C and derived languages.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
656
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
657 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
658 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
659 Make a tag for each line matching pattern REGEXP in the\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
660 following files. regexfile is a file containing one REGEXP\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
661 per line. REGEXP is anchored (as if preceded by ^).\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
662 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
663 named tags can be created with:\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
664 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
665 puts ("-R, --no-regex\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
666 Don't create tags from regexps for the following files.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
667 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
668 puts ("-o FILE, --output=FILE\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
669 Write the tags to FILE.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
670 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
671 puts ("-O, --oo-browser\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
672 Generate a specialized tags format used only by the Altrasoft OO-Browser.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
673 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
674 puts ("-I, --ignore-indentation\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
675 Don't rely on indentation quite as much as normal. Currently,\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
676 this means not to assume that a closing brace in the first\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
677 column is the final brace of a function or structure\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
678 definition in C and C++.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
679
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
680 if (CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
681 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
682 puts ("-t, --typedefs\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
683 Generate tag entries for C typedefs.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
684 puts ("-T, --typedefs-and-c++\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
685 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
686 and C++ member functions.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
687 puts ("-u, --update\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
688 Update the tag entries for the given files, leaving tag\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
689 entries for other files in place. Currently, this is\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
690 implemented by deleting the existing entries for the given\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
691 files and then rewriting the new entries at the end of the\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
692 tags file. It is often faster to simply rebuild the entire\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
693 tag file than to use this.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
694 puts ("-v, --vgrind\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
695 Generates an index of items intended for human consumption,\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
696 similar to the output of vgrind. The index is sorted, and\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
697 gives the page number of each item.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
698 puts ("-w, --no-warn\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
699 Suppress warning messages about entries defined in multiple\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
700 files.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
701 puts ("-x, --cxref\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
702 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
703 The output uses line numbers instead of page numbers, but\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
704 beyond that the differences are cosmetic; try both to see\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
705 which you like.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
706 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
707
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
708 puts ("-V, --version\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
709 Print the version of the program.\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
710 -h, --help\n\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
711 Print this help message.");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
712
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
713 print_language_names ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
714
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
715 puts ("");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
716 puts ("Report bugs to bug-gnu-emacs@prep.ai.mit.edu");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
717
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
718 exit (GOOD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
719 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
720
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
721
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
722 enum argument_type
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
723 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
724 at_language,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
725 at_regexp,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
726 at_filename
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
727 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
728
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
729 /* This structure helps us allow mixing of --lang and file names. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
730 typedef struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
731 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
732 enum argument_type arg_type;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
733 char *what;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
734 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
735 } argument;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
736
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
737 #ifdef VMS /* VMS specific functions */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
738
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
739 #define EOS '\0'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
740
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
741 /* This is a BUG! ANY arbitrary limit is a BUG!
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
742 Won't someone please fix this? */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
743 #define MAX_FILE_SPEC_LEN 255
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
744 typedef struct {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
745 short curlen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
746 char body[MAX_FILE_SPEC_LEN + 1];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
747 } vspec;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
748
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
749 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
750 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
751 returning in each successive call the next file name matching the input
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
752 spec. The function expects that each in_spec passed
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
753 to it will be processed to completion; in particular, up to and
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
754 including the call following that in which the last matching name
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
755 is returned, the function ignores the value of in_spec, and will
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
756 only start processing a new spec with the following call.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
757 If an error occurs, on return out_spec contains the value
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
758 of in_spec when the error occurred.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
759
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
760 With each successive file name returned in out_spec, the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
761 function's return value is one. When there are no more matching
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
762 names the function returns zero. If on the first call no file
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
763 matches in_spec, or there is any other error, -1 is returned.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
764 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
765
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
766 #include <rmsdef.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
767 #include <descrip.h>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
768 #define OUTSIZE MAX_FILE_SPEC_LEN
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
769 short
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
770 fn_exp (out, in)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
771 vspec *out;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
772 char *in;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
773 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
774 static long context = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
775 static struct dsc$descriptor_s o;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
776 static struct dsc$descriptor_s i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
777 static bool pass1 = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
778 long status;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
779 short retval;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
780
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
781 if (pass1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
782 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
783 pass1 = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
784 o.dsc$a_pointer = (char *) out;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
785 o.dsc$w_length = (short)OUTSIZE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
786 i.dsc$a_pointer = in;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
787 i.dsc$w_length = (short)strlen(in);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
788 i.dsc$b_dtype = DSC$K_DTYPE_T;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
789 i.dsc$b_class = DSC$K_CLASS_S;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
790 o.dsc$b_dtype = DSC$K_DTYPE_VT;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
791 o.dsc$b_class = DSC$K_CLASS_VS;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
792 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
793 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
794 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
795 out->body[out->curlen] = EOS;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
796 return 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
797 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
798 else if (status == RMS$_NMF)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
799 retval = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
800 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
801 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
802 strcpy(out->body, in);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
803 retval = -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
804 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
805 lib$find_file_end(&context);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
806 pass1 = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
807 return retval;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
808 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
809
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
810 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
811 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
812 name of each file specified by the provided arg expanding wildcards.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
813 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
814 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
815 gfnames (arg, p_error)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
816 char *arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
817 bool *p_error;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
818 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
819 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
820
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
821 switch (fn_exp (&filename, arg))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
822 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
823 case 1:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
824 *p_error = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
825 return filename.body;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
826 case 0:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
827 *p_error = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
828 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
829 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
830 *p_error = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
831 return filename.body;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
832 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
833 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
834
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
835 #ifndef OLD /* Newer versions of VMS do provide `system'. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
836 system (cmd)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
837 char *cmd;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
838 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
839 error ("%s", "system() function not implemented under VMS");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
840 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
841 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
842
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
843 #define VERSION_DELIM ';'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
844 char *massage_name (s)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
845 char *s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
846 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
847 char *start = s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
848
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
849 for ( ; *s; s++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
850 if (*s == VERSION_DELIM)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
851 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
852 *s = EOS;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
853 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
854 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
855 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
856 *s = lowcase (*s);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
857 return start;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
858 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
859 #endif /* VMS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
860
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
861
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
862 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
863 main (argc, argv)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
864 int argc;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
865 char *argv[];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
866 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
867 int i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
868 unsigned int nincluded_files;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
869 char **included_files;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
870 char *this_file;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
871 argument *argbuffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
872 int current_arg, file_count;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
873 linebuffer filename_lb;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
874 #ifdef VMS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
875 bool got_err;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
876 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
877
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
878 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
879 _fmode = O_BINARY; /* all of files are treated as binary files */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
880 #endif /* DOS_NT */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
881
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
882 progname = argv[0];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
883 nincluded_files = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
884 included_files = xnew (argc, char *);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
885 current_arg = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
886 file_count = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
887
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
888 /* Allocate enough no matter what happens. Overkill, but each one
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
889 is small. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
890 argbuffer = xnew (argc, argument);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
891
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
892 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
893 /* Set syntax for regular expression routines. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
894 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
895 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
896
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
897 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
898 * If etags, always find typedefs and structure tags. Why not?
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
899 * Also default is to find macro constants, enum constants and
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
900 * global variables.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
901 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
902 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
903 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
904 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
905 globals = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
906 members = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
907 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
908
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
909 while (1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
910 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
911 int opt;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
912 char *optstring;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
913
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
914 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
915 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
916 optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
917 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
918 optstring = "-aCdDf:Il:o:r:RStTi:BOuvxwVhH";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
919 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
920 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
921 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
922 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
923 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
924 optstring = "-aCdDf:Il:o:StTi:BOuvxwVhH";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
925 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
926 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
927
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
928 #ifndef LONG_OPTIONS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
929 optstring = optstring + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
930 #endif /* LONG_OPTIONS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
931
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
932 opt = getopt_long (argc, argv, optstring, longopts, 0);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
933 if (opt == EOF)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
934 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
935
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
936 switch (opt)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
937 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
938 case 0:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
939 /* If getopt returns 0, then it has already processed a
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
940 long-named option. We should do nothing. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
941 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
942
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
943 case 1:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
944 /* This means that a file name has been seen. Record it. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
945 argbuffer[current_arg].arg_type = at_filename;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
946 argbuffer[current_arg].what = optarg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
947 ++current_arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
948 ++file_count;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
949 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
950
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
951 /* Common options. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
952 case 'a': append_to_tagfile = TRUE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
953 case 'C': cplusplus = TRUE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
954 case 'd': constantypedefs = TRUE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
955 case 'D': constantypedefs = FALSE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
956 case 'f': /* for compatibility with old makefiles */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
957 case 'o':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
958 if (tagfile)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
959 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
960 /* convert char to string, to call error with */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
961 char buf[2];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
962 sprintf (buf, "%c", opt);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
963 error ("-%s option may only be given once.", buf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
964 suggest_asking_for_help ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
965 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
966 tagfile = optarg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
967 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
968 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
969 case 'O':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
970 oo_browser_format = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
971 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
972 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
973 case 'I':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
974 case 'S': /* for backward compatibility */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
975 noindentypedefs = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
976 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
977 case 'l':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
978 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
979 language *lang = get_language_from_name (optarg);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
980 if (lang != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
981 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
982 argbuffer[current_arg].lang = lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
983 argbuffer[current_arg].arg_type = at_language;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
984 ++current_arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
985 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
986 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
987 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
988 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
989 case 'r':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
990 argbuffer[current_arg].arg_type = at_regexp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
991 argbuffer[current_arg].what = optarg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
992 ++current_arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
993 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
994 case 'R':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
995 argbuffer[current_arg].arg_type = at_regexp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
996 argbuffer[current_arg].what = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
997 ++current_arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
998 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
999 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1000 case 'V':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1001 print_version ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1002 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1003 case 'h':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1004 case 'H':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1005 print_help ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1006 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1007 case 't':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1008 typedefs = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1009 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1010 case 'T':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1011 typedefs = typedefs_and_cplusplus = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1012 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1013 #if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1014 /* Etags options */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1015 case 'i':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1016 included_files[nincluded_files++] = optarg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1017 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1018 #else /* CTAGS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1019 /* Ctags options. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1020 case 'B': searchar = '?'; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1021 case 'u': update = TRUE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1022 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1023 case 'x': cxref_style = TRUE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1024 case 'w': no_warnings = TRUE; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1025 #endif /* CTAGS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1026 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1027 suggest_asking_for_help ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1028 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1029 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1030
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1031 for (; optind < argc; ++optind)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1032 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1033 argbuffer[current_arg].arg_type = at_filename;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1034 argbuffer[current_arg].what = argv[optind];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1035 ++current_arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1036 ++file_count;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1037 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1038
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1039 if (nincluded_files == 0 && file_count == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1040 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1041 error ("no input files specified.", 0);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1042 suggest_asking_for_help ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1043 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1044
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1045 if (tagfile == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1046 tagfile = CTAGS ? "tags" : "TAGS";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1047 cwd = etags_getcwd (); /* the current working directory */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1048 if (cwd[strlen (cwd) - 1] != '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1049 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1050 char *oldcwd = cwd;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1051 cwd = concat (oldcwd, "/", "");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1052 free (oldcwd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1053 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1054 if (streq (tagfile, "-"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1055 tagfiledir = cwd;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1056 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1057 tagfiledir = absolute_dirname (tagfile, cwd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1058
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1059 init (); /* set up boolean "functions" */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1060
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1061 initbuffer (&lb);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1062 initbuffer (&token_name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1063 initbuffer (&lbs[0].lb);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1064 initbuffer (&lbs[1].lb);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1065 initbuffer (&filename_lb);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1066
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1067 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1068 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1069 if (streq (tagfile, "-"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1070 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1071 tagf = stdout;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1072 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1073 /* Switch redirected `stdout' to binary mode (setting `_fmode'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1074 doesn't take effect until after `stdout' is already open). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1075 if (!isatty (fileno (stdout)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1076 setmode (fileno (stdout), O_BINARY);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1077 #endif /* DOS_NT */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1078 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1079 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1080 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1081 if (tagf == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1082 pfatal (tagfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1083 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1084
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1085 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1086 * Loop through files finding functions.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1087 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1088 for (i = 0; i < current_arg; ++i)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1089 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1090 switch (argbuffer[i].arg_type)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1091 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1092 case at_language:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1093 forced_lang = argbuffer[i].lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1094 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1095 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1096 case at_regexp:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1097 analyse_regex (argbuffer[i].what);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1098 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1099 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1100 case at_filename:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1101 #ifdef VMS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1102 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1103 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1104 if (got_err)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1105 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1106 error ("can't find file %s\n", this_file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1107 argc--, argv++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1108 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1109 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1110 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1111 this_file = massage_name (this_file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1112 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1113 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1114 this_file = argbuffer[i].what;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1115 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1116 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1117 oo_browser_clear_all_globals();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1118 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1119 /* Input file named "-" means read file names from stdin
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1120 (one per line) and use them. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1121 if (streq (this_file, "-"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1122 while (readline_internal (&filename_lb, stdin) > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1123 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1124 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1125 oo_browser_clear_some_globals();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1126 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1127 process_file (filename_lb.buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1128 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1129 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1130 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1131 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1132 process_file (this_file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1133 #ifdef VMS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1134 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1135 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1136 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1137 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1138 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1139
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1140 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1141 free_patterns ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1142 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1143
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1144 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1145 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1146 while (nincluded_files-- > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1147 fprintf (tagf, "\f\n%s,include\n", *included_files++);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1148
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1149 fclose (tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1150 exit (GOOD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1151 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1152
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1153 /* If CTAGS, we are here. process_file did not write the tags yet,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1154 because we want them ordered. Let's do it now. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1155 if (cxref_style)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1156 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1157 put_entries (head);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1158 exit (GOOD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1159 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1160
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1161 if (update)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1162 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1163 char cmd[BUFSIZ];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1164 for (i = 0; i < current_arg; ++i)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1165 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1166 if (argbuffer[i].arg_type != at_filename)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1167 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1168 sprintf (cmd,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1169 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1170 tagfile, argbuffer[i].what, tagfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1171 if (system (cmd) != GOOD)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1172 fatal ("failed to execute shell command", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1173 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1174 append_to_tagfile = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1175 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1176
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1177 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1178 if (tagf == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1179 pfatal (tagfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1180 put_entries (head);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1181 fclose (tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1182
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1183 if (update)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1184 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1185 char cmd[BUFSIZ];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1186 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1187 exit (system (cmd));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1188 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1189 return GOOD;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1190 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1191
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1192
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1193 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1194 * Return a language given the name.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1195 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1196 language *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1197 get_language_from_name (name)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1198 char *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1199 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1200 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1201
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1202 if (name == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1203 error ("empty language name", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1204 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1205 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1206 for (lang = lang_names; lang->name != NULL; lang++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1207 if (streq (name, lang->name))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1208 return lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1209 error ("unknown language \"%s\"", name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1210 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1211
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1212 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1213 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1214
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1215
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1216 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1217 * Return a language given the interpreter name.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1218 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1219 language *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1220 get_language_from_interpreter (interpreter)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1221 char *interpreter;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1222 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1223 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1224 char **iname;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1225
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1226 if (interpreter == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1227 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1228 for (lang = lang_names; lang->name != NULL; lang++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1229 if (lang->interpreters != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1230 for (iname = lang->interpreters; *iname != NULL; iname++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1231 if (streq (*iname, interpreter))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1232 return lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1233
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1234 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1235 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1236
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1237
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1238
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1239 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1240 * Return a language given the file suffix.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1241 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1242 language *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1243 get_language_from_suffix (suffix)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1244 char *suffix;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1245 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1246 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1247 char **ext;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1248
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1249 if (suffix == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1250 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1251 for (lang = lang_names; lang->name != NULL; lang++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1252 if (lang->suffixes != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1253 for (ext = lang->suffixes; *ext != NULL; ext++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1254 if (streq (*ext, suffix))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1255 return lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1256
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1257 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1258 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1259
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1260
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1261 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1262 * This routine is called on each file argument.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1263 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1264 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1265 process_file (file)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1266 char *file;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1267 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1268 struct stat stat_buf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1269 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1270
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1271 canonicalize_filename (file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1272 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1273 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1274 error ("skipping %s: it is not a regular file.", file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1275 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1276 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1277 if (streq (file, tagfile) && !streq (tagfile, "-"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1278 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1279 error ("skipping inclusion of %s in self.", file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1280 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1281 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1282 inf = fopen (file, "r");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1283 if (inf == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1284 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1285 perror (file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1286 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1287 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1288
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1289 find_entries (file, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1290
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1291 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1292 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1293 char *filename;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1294
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1295 if (filename_is_absolute (file))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1296 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1297 /* file is an absolute file name. Canonicalise it. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1298 filename = absolute_filename (file, cwd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1299 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1300 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1301 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1302 /* file is a file name relative to cwd. Make it relative
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1303 to the directory of the tags file. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1304 filename = relative_filename (file, tagfiledir);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1305 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1306 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1307 if (oo_browser_format)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1308 fprintf (tagf, "\f\n%s\n", filename);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1309 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1310 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1311 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1312 free (filename);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1313 put_entries (head);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1314 free_tree (head);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1315 head = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1316 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1317 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1318
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1319 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1320 * This routine sets up the boolean pseudo-functions which work
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1321 * by setting boolean flags dependent upon the corresponding character.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1322 * Every char which is NOT in that string is not a white char. Therefore,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1323 * all of the array "_wht" is set to FALSE, and then the elements
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1324 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1325 * of a char is TRUE if it is the string "white", else FALSE.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1326 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1327 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1328 init ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1329 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1330 register char *sp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1331 register int i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1332
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1333 for (i = 0; i < CHARS; i++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1334 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1335 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1336 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1337 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1338 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1339 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1340 iswhite('\0') = iswhite('\n');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1341 notinname('\0') = notinname('\n');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1342 begtoken('\0') = begtoken('\n');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1343 intoken('\0') = intoken('\n');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1344 endtoken('\0') = endtoken('\n');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1345 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1346
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1347 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1348 * This routine opens the specified file and calls the function
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1349 * which finds the function and type definitions.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1350 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1351 node *last_node = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1352
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1353 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1354 find_entries (file, inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1355 char *file;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1356 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1357 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1358 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1359 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1360 node *old_last_node;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1361
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1362 curfile = savestr (file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1363
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1364 /* If user specified a language, use it. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1365 lang = forced_lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1366 if (lang != NULL && lang->function != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1367 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1368 curlang = lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1369 lang->function (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1370 free (curfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1371 fclose (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1372 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1373 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1374
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1375 cp = etags_strrchr (file, '.');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1376 if (cp != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1377 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1378 cp += 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1379 lang = get_language_from_suffix (cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1380 if (lang != NULL && lang->function != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1381 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1382 curlang = lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1383 lang->function (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1384 free (curfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1385 fclose (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1386 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1387 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1388 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1389
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1390 /* Look for sharp-bang as the first two characters. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1391 if (readline_internal (&lb, inf) > 0
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1392 && lb.len >= 2
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1393 && lb.buffer[0] == '#'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1394 && lb.buffer[1] == '!')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1395 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1396 char *lp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1397
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1398 /* Set lp to point at the first char after the last slash in the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1399 line or, if no slashes, at the first nonblank. Then set cp to
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1400 the first successive blank and terminate the string. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1401 lp = etags_strrchr (lb.buffer+2, '/');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1402 if (lp != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1403 lp += 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1404 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1405 lp = skip_spaces (lb.buffer + 2);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1406 cp = skip_non_spaces (lp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1407 *cp = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1408
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1409 if (strlen (lp) > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1410 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1411 lang = get_language_from_interpreter (lp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1412 if (lang != NULL && lang->function != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1413 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1414 curlang = lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1415 lang->function (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1416 fclose (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1417 free (curfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1418 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1419 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1420 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1421 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1422 rewind (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1423
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1424 /* Try Fortran. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1425 old_last_node = last_node;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1426 curlang = get_language_from_name ("fortran");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1427 Fortran_functions (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1428
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1429 /* No Fortran entries found. Try C. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1430 if (old_last_node == last_node)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1431 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1432 rewind (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1433 curlang = get_language_from_name (cplusplus ? "c++" : "c");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1434 default_C_entries (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1435 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1436 free (curfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1437 fclose (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1438 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1439 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1440
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1441 /* Record a tag. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1442 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1443 pfnote (name, is_func, linestart, linelen, lno, cno)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1444 char *name; /* tag name, or NULL if unnamed */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1445 bool is_func; /* tag is a function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1446 char *linestart; /* start of the line where tag is */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1447 int linelen; /* length of the line where tag is */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1448 int lno; /* line number */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1449 long cno; /* character number */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1450 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1451 register node *np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1452
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1453 if (CTAGS && name == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1454 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1455
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1456 np = xnew (1, node);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1457
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1458 /* If ctags mode, change name "main" to M<thisfilename>. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1459 if (CTAGS && !cxref_style && streq (name, "main"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1460 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1461 register char *fp = etags_strrchr (curfile, '/');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1462 np->name = concat ("M", fp == 0 ? curfile : fp + 1, "");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1463 fp = etags_strrchr (np->name, '.');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1464 if (fp && fp[1] != '\0' && fp[2] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1465 fp[0] = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1466 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1467 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1468 np->name = name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1469 np->been_warned = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1470 np->file = curfile;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1471 np->is_func = is_func;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1472 np->lno = lno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1473 /* Our char numbers are 0-base, because of C language tradition?
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1474 ctags compatibility? old versions compatibility? I don't know.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1475 Anyway, since emacs's are 1-base we expect etags.el to take care
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1476 of the difference. If we wanted to have 1-based numbers, we would
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1477 uncomment the +1 below. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1478 np->cno = cno /* + 1 */ ;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1479 np->left = np->right = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1480 if (CTAGS && !cxref_style)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1481 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1482 if (strlen (linestart) < 50)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1483 np->pat = concat (linestart, "$", "");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1484 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1485 np->pat = savenstr (linestart, 50);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1486 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1487 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1488 np->pat = savenstr (linestart, linelen);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1489
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1490 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1491 if (oo_browser_format)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1492 np->construct = oo_browser_construct;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1493 oo_browser_construct = C_NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1494 oo_browser_check_and_clear_structtype();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1495 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1496
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1497 add_node (np, &head);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1498 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1499
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1500 /* Date: Wed, 22 Jan 1997 02:56:31 -0500 [last amended 18 Sep 1997]
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1501 * From: Sam Kendall <kendall@mv.mv.com>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1502 * Subject: Proposal for firming up the TAGS format specification
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1503 * To: F.Potorti@cnuce.cnr.it
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1504 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1505 * pfnote should emit the optimized form [unnamed tag] only if:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1506 * 1. name does not contain any of the characters " \t\r\n(),;";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1507 * 2. linestart contains name as either a rightmost, or rightmost but
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1508 * one character, substring;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1509 * 3. the character, if any, immediately before name in linestart must
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1510 * be one of the characters " \t(),;";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1511 * 4. the character, if any, immediately after name in linestart must
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1512 * also be one of the characters " \t(),;".
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1513 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1514 * The real implementation uses the notinname() macro, which recognises
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1515 * characters slightly different form " \t\r\n(),;". See the variable
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1516 * `nonam'.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1517 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1518 #define traditional_tag_style TRUE
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1519 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1520 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1521 char *name; /* tag name, or NULL if unnamed */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1522 int namelen; /* tag length */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1523 bool is_func; /* tag is a function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1524 char *linestart; /* start of the line where tag is */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1525 int linelen; /* length of the line where tag is */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1526 int lno; /* line number */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1527 long cno; /* character number */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1528 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1529 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1530 bool named;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1531
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1532 named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1533 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1534 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1535 for (cp = name; !notinname (*cp); cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1536 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1537 if (*cp == '\0') /* rule #1 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1538 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1539 cp = linestart + linelen - namelen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1540 if (notinname (linestart[linelen-1]))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1541 cp -= 1; /* rule #4 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1542 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1543 if (!oo_browser_format
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1544 && cp >= linestart /* rule #2 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1545 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1546 if (cp >= linestart /* rule #2 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1547 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1548 && (cp == linestart
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1549 || notinname (cp[-1])) /* rule #3 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1550 && strneq (name, cp, namelen)) /* rule #2 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1551 named = FALSE; /* use unnamed tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1552 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1553 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1554
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1555 if (named)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1556 name = savenstr (name, namelen);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1557 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1558 name = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1559 pfnote (name, is_func, linestart, linelen, lno, cno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1560 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1561
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1562 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1563 * free_tree ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1564 * recurse on left children, iterate on right children.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1565 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1566 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1567 free_tree (np)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1568 register node *np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1569 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1570 while (np)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1571 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1572 register node *node_right = np->right;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1573 free_tree (np->left);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1574 if (np->name != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1575 free (np->name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1576 free (np->pat);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1577 free (np);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1578 np = node_right;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1579 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1580 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1581
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1582 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1583 * add_node ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1584 * Adds a node to the tree of nodes. In etags mode, we don't keep
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1585 * it sorted; we just keep a linear list. In ctags mode, maintain
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1586 * an ordered tree, with no attempt at balancing.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1587 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1588 * add_node is the only function allowed to add nodes, so it can
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1589 * maintain state.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1590 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1591 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1592 add_node (np, cur_node_p)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1593 node *np, **cur_node_p;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1594 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1595 register int dif;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1596 register node *cur_node = *cur_node_p;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1597
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1598 if (cur_node == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1599 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1600 *cur_node_p = np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1601 last_node = np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1602 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1603 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1604
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1605 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1606 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1607 /* Etags Mode */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1608 if (last_node == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1609 fatal ("internal error in add_node", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1610 last_node->right = np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1611 last_node = np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1612 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1613 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1614 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1615 /* Ctags Mode */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1616 dif = strcmp (np->name, cur_node->name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1617
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1618 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1619 * If this tag name matches an existing one, then
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1620 * do not add the node, but maybe print a warning.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1621 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1622 if (!dif)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1623 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1624 if (streq (np->file, cur_node->file))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1625 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1626 if (!no_warnings)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1627 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1628 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1629 np->file, lineno, np->name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1630 fprintf (stderr, "Second entry ignored\n");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1631 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1632 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1633 else if (!cur_node->been_warned && !no_warnings)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1634 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1635 fprintf
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1636 (stderr,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1637 "Duplicate entry in files %s and %s: %s (Warning only)\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1638 np->file, cur_node->file, np->name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1639 cur_node->been_warned = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1640 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1641 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1642 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1643
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1644 /* Actually add the node */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1645 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1646 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1647 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1648
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1649 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1650 /* Default class name for the current OO-Browser tag. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1651 static char *oo_browser_class;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1652 /* Prefix character to use in OO-Browser listings for the current tag. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1653 static char oo_browser_prefix;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1654 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1655
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1656 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1657 put_entries (np)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1658 register node *np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1659 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1660 register char *sp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1661
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1662 if (np == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1663 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1664
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1665 /* Output subentries that precede this one */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1666 put_entries (np->left);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1667
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1668 /* Output this entry */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1669
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1670 if (!CTAGS)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1671 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1672 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1673 if (oo_browser_format)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1674 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1675 /* Omit C++ `class' and `method' entries as well as Objective-C
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1676 entries from this OO-Browser tags file since the browser handles
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1677 them independently of this file. Omit `extern' variable declarations
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1678 as they are unused by the OO-Browser. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1679 if (np->construct != C_CLASS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1680 && np->construct != C_METHOD
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1681 && np->construct != C_EXTERN
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1682 && np->construct != C_OBJC)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1683 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1684 oo_browser_class = oo_browser_default_classes[np->construct];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1685 switch (np->construct)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1686 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1687 case C_CONSTANT:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1688 case C_ENUMERATION:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1689 case C_ENUM_LABEL:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1690 case C_STRUCTURE:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1691 case C_TYPE:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1692 case C_UNION:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1693 case C_VARIABLE:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1694 oo_browser_prefix = '=';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1695 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1696 case C_FUNCTION:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1697 case C_MACRO:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1698 oo_browser_prefix = '-';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1699 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1700 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1701 if (np->name != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1702 fprintf (tagf, "%s@%c %s@%s\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1703 oo_browser_class, oo_browser_prefix,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1704 np->name, np->pat);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1705 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1706 fprintf (tagf, "%s@%c ???@%s\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1707 oo_browser_class, oo_browser_prefix, np->pat);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1708 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1709 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1710 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1711 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1712 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1713 if (np->name != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1714 fprintf (tagf, "%s\177%s\001%d,%ld\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1715 np->pat, np->name, np->lno, np->cno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1716 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1717 fprintf (tagf, "%s\177%d,%ld\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1718 np->pat, np->lno, np->cno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1719 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1720 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1721 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1722 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1723 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1724 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1725 if (np->name == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1726 error ("internal error: NULL name in ctags mode.", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1727
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1728 if (cxref_style)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1729 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1730 if (vgrind_style)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1731 fprintf (stdout, "%s %s %d\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1732 np->name, np->file, (np->lno + 63) / 64);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1733 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1734 fprintf (stdout, "%-16s %3d %-16s %s\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1735 np->name, np->lno, np->file, np->pat);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1736 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1737 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1738 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1739 fprintf (tagf, "%s\t%s\t", np->name, np->file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1740
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1741 if (np->is_func)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1742 { /* a function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1743 putc (searchar, tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1744 putc ('^', tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1745
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1746 for (sp = np->pat; *sp; sp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1747 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1748 if (*sp == '\\' || *sp == searchar)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1749 putc ('\\', tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1750 putc (*sp, tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1751 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1752 putc (searchar, tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1753 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1754 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1755 { /* a typedef; text pattern inadequate */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1756 fprintf (tagf, "%d", np->lno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1757 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1758 putc ('\n', tagf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1759 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1760 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1761
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1762 /* Output subentries that follow this one */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1763 put_entries (np->right);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1764 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1765
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1766 /* Length of a number's decimal representation. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1767 int number_len PP ((long num));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1768 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1769 number_len (num)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1770 long num;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1771 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1772 int len = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1773 while ((num /= 10) > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1774 len += 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1775 return len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1776 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1777
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1778 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1779 * Return total number of characters that put_entries will output for
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1780 * the nodes in the subtree of the specified node. Works only if
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1781 * we are not ctags, but called only in that case. This count
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1782 * is irrelevant with the new tags.el, but is still supplied for
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1783 * backward compatibility.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1784 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1785 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1786 total_size_of_entries (np)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1787 register node *np;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1788 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1789 register int total;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1790
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1791 if (np == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1792 return 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1793
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1794 for (total = 0; np != NULL; np = np->right)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1795 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1796 /* Count left subentries. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1797 total += total_size_of_entries (np->left);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1798
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1799 /* Count this entry */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1800 total += strlen (np->pat) + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1801 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1802 if (np->name != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1803 total += 1 + strlen (np->name); /* \001name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1804 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1805
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1806 return total;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1807 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1808
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1809 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1810 * The C symbol tables.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1811 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1812 enum sym_type
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1813 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1814 st_none,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1815 st_C_objprot, st_C_objimpl, st_C_objend,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1816 st_C_gnumacro,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1817 st_C_ignore,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1818 st_C_javastruct,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1819 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1820 st_C_const
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1821 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1822 , st_C_union, st_C_class, st_C_extern, st_C_inline
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1823 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1824 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1825
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1826 /* Feed stuff between (but not including) %[ and %] lines to:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1827 gperf -c -k 1,3 -o -p -r -t
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1828 %[
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1829 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1830 %%
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1831 @interface, 0, st_C_objprot
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1832 @protocol, 0, st_C_objprot
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1833 @implementation,0, st_C_objimpl
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1834 @end, 0, st_C_objend
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1835 import, C_JAVA, st_C_ignore
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1836 package, C_JAVA, st_C_ignore
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1837 friend, C_PLPL, st_C_ignore
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1838 extends, C_JAVA, st_C_javastruct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1839 implements, C_JAVA, st_C_javastruct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1840 interface, C_JAVA, st_C_struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1841 class, C_PLPL, st_C_class
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1842 namespace, C_PLPL, st_C_struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1843 domain, C_STAR, st_C_struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1844 union, 0, st_C_union
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1845 struct, 0, st_C_struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1846 enum, 0, st_C_enum
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1847 typedef, 0, st_C_typedef
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1848 define, 0, st_C_define
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1849 inline, 0, st_C_inline
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1850 bool, C_PLPL, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1851 long, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1852 short, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1853 int, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1854 char, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1855 float, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1856 double, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1857 signed, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1858 unsigned, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1859 auto, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1860 void, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1861 extern, 0, st_C_extern
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1862 static, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1863 const, 0, st_C_const
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1864 volatile, 0, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1865 explicit, C_PLPL, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1866 mutable, C_PLPL, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1867 typename, C_PLPL, st_C_typespec
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1868 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1869 DEFUN, 0, st_C_gnumacro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1870 SYSCALL, 0, st_C_gnumacro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1871 ENTRY, 0, st_C_gnumacro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1872 PSEUDO, 0, st_C_gnumacro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1873 # These are defined inside C functions, so currently they are not met.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1874 # EXFUN used in glibc, DEFVAR_* in emacs.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1875 #EXFUN, 0, st_C_gnumacro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1876 #DEFVAR_, 0, st_C_gnumacro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1877 %]
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1878 and replace lines between %< and %> with its output. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1879 /*%<*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1880 /* C code produced by gperf version 2.5 (GNU C++ version) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1881 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1882 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1883
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1884 #define TOTAL_KEYWORDS 41
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1885 #define MIN_WORD_LENGTH 3
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1886 #define MAX_WORD_LENGTH 15
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1887 #define MIN_HASH_VALUE 13
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1888 #define MAX_HASH_VALUE 129
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1889 /* maximum key range = 117, duplicates = 0 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1890
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1891 static unsigned int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1892 hash (str, len)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1893 register char *str;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1894 register int unsigned len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1895 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1896 static unsigned char asso_values[] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1897 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1898 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1899 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1900 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1901 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1902 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1903 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1904 130, 130, 130, 130, 13, 130, 130, 130, 33, 32,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1905 47, 130, 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1906 5, 130, 130, 20, 32, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1907 130, 130, 130, 130, 130, 130, 130, 47, 55, 8,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1908 15, 33, 61, 38, 130, 60, 130, 130, 2, 9,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1909 10, 62, 59, 130, 28, 27, 50, 19, 3, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1910 130, 130, 130, 130, 130, 130, 130, 130,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1911 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1912 return len + asso_values[str[2]] + asso_values[str[0]];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1913 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1914
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1915 struct C_stab_entry *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1916 in_word_set (str, len)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1917 register char *str;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1918 register unsigned int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1919 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1920 static struct C_stab_entry wordlist[] =
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1921 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1922 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1923 {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1924 {"volatile", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1925 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1926 {"long", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1927 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1928 {"const", 0, st_C_const},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1929 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1930 {"@end", 0, st_C_objend},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1931 {"namespace", C_PLPL, st_C_struct},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1932 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1933 {"domain", C_STAR, st_C_struct},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1934 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1935 {"@interface", 0, st_C_objprot},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1936 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1937 {"@implementation", 0, st_C_objimpl},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1938 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1939 {"double", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1940 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1941 {"PSEUDO", 0, st_C_gnumacro},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1942 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1943 {"SYSCALL", 0, st_C_gnumacro},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1944 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1945 {"@protocol", 0, st_C_objprot},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1946 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1947 {"unsigned", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1948 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1949 {"enum", 0, st_C_enum},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1950 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1951 {"char", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1952 {"class", C_PLPL, st_C_class},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1953 {"struct", 0, st_C_struct},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1954 {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1955 {"mutable", C_PLPL, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1956 {"void", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1957 {"inline", 0, st_C_inline},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1958 {"ENTRY", 0, st_C_gnumacro},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1959 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1960 {"signed", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1961 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1962 {"package", C_JAVA, st_C_ignore},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1963 {"",}, {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1964 {"static", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1965 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1966 {"define", 0, st_C_define},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1967 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1968 {"union", 0, st_C_union},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1969 {"DEFUN", 0, st_C_gnumacro},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1970 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1971 {"extern", 0, st_C_extern},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1972 {"extends", C_JAVA, st_C_javastruct},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1973 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1974 {"short", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1975 {"",}, {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1976 {"explicit", C_PLPL, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1977 {"auto", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1978 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1979 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1980 {"int", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1981 {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1982 {"typedef", 0, st_C_typedef},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1983 {"typename", C_PLPL, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1984 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1985 {"interface", C_JAVA, st_C_struct},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1986 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1987 {"bool", C_PLPL, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1988 {"",}, {"",}, {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1989 {"import", C_JAVA, st_C_ignore},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1990 {"",},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1991 {"friend", C_PLPL, st_C_ignore},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1992 {"float", 0, st_C_typespec},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1993 {"implements", C_JAVA, st_C_javastruct},
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1994 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1995
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1996 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1997 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1998 register int key = hash (str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
1999
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2000 if (key <= MAX_HASH_VALUE && key >= 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2001 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2002 register char *s = wordlist[key].name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2003
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2004 if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2005 return &wordlist[key];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2006 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2007 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2008 return 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2009 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2010 /*%>*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2011
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2012 enum sym_type C_symtype PP ((char *str, int len, int c_ext));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2013 enum sym_type
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2014 C_symtype (str, len, c_ext)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2015 char *str;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2016 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2017 int c_ext;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2018 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2019 register struct C_stab_entry *se = in_word_set (str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2020
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2021 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2022 return st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2023 return se->type;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2024 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2025
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2026 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2027 * C functions and variables are recognized using a simple
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2028 * finite automaton. fvdef is its state variable.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2029 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2030 enum
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2031 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2032 fvnone, /* nothing seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2033 fvnameseen, /* function or variable name seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2034 fstartlist, /* func: just after open parenthesis */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2035 finlist, /* func: in parameter list */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2036 flistseen, /* func: after parameter list */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2037 fignore, /* func: before open brace */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2038 vignore /* var-like: ignore until ';' */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2039 } fvdef;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2040
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2041
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2042 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2043 * typedefs are recognized using a simple finite automaton.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2044 * typdef is its state variable.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2045 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2046 enum
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2047 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2048 tnone, /* nothing seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2049 ttypedseen, /* typedef keyword seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2050 tinbody, /* inside typedef body */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2051 tend, /* just before typedef tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2052 tignore /* junk after typedef tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2053 } typdef;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2054
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2055
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2056 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2057 * struct-like structures (enum, struct and union) are recognized
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2058 * using another simple finite automaton. `structdef' is its state
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2059 * variable.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2060 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2061 enum
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2062 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2063 snone, /* nothing seen yet */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2064 skeyseen, /* struct-like keyword seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2065 stagseen, /* struct-like tag seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2066 scolonseen, /* colon seen after struct-like tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2067 sinbody /* in struct body: recognize member func defs*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2068 } structdef;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2069
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2070 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2071 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2072 * struct tag, and structtype is the type of the preceding struct-like
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2073 * keyword.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2074 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2075 char *structtag = "<uninited>";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2076 enum sym_type structtype;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2077
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2078 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2079 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2080 oo_browser_check_and_clear_structtype()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2081 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2082 /* Allow for multiple enum_label tags. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2083 if (structtype != st_C_enum)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2084 structtype = st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2085 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2086 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2087
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2088 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2089 * When objdef is different from onone, objtag is the name of the class.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2090 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2091 char *objtag = "<uninited>";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2092
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2093 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2094 * Yet another little state machine to deal with preprocessor lines.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2095 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2096 enum
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2097 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2098 dnone, /* nothing seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2099 dsharpseen, /* '#' seen as first char on line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2100 ddefineseen, /* '#' and 'define' seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2101 dignorerest /* ignore rest of line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2102 } definedef;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2103
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2104 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2105 * State machine for Objective C protocols and implementations.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2106 * Tom R.Hageman <tom@basil.icce.rug.nl>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2107 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2108 enum
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2109 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2110 onone, /* nothing seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2111 oprotocol, /* @interface or @protocol seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2112 oimplementation, /* @implementations seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2113 otagseen, /* class name seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2114 oparenseen, /* parenthesis before category seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2115 ocatseen, /* category name seen */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2116 oinbody, /* in @implementation body */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2117 omethodsign, /* in @implementation body, after +/- */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2118 omethodtag, /* after method name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2119 omethodcolon, /* after method colon */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2120 omethodparm, /* after method parameter */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2121 oignore /* wait for @end */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2122 } objdef;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2123
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2124 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2125 * Use this structure to keep info about the token read, and how it
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2126 * should be tagged. Used by the make_C_tag function to build a tag.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2127 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2128 typedef struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2129 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2130 bool valid;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2131 char *str;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2132 bool named;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2133 int linelen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2134 int lineno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2135 long linepos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2136 char *buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2137 } token;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2138
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2139 token tok; /* latest token read */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2140
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2141 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2142 * Set this to TRUE, and the next token considered is called a function.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2143 * Used only for GNU emacs's function-defining macros.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2144 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2145 bool next_token_is_func;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2146
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2147 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2148 * TRUE in the rules part of a yacc file, FALSE outside (parse as C).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2149 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2150 bool yacc_rules;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2151
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2152 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2153 * methodlen is the length of the method name stored in token_name.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2154 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2155 int methodlen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2156
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2157 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2158 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2159 oo_browser_clear_all_globals()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2160 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2161 /* Initialize globals so there is no carry over between files. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2162 oo_browser_construct = C_NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2163 fvdef = fvnone; typdef = tnone; structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2164 definedef = dnone; objdef = onone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2165 structtype = st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2166 next_token_is_func = yacc_rules = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2167 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2168
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2169 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2170 oo_browser_clear_some_globals()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2171 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2172 oo_browser_construct = C_NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2173 structtype = st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2174 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2175 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2176
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2177 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2178 * consider_token ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2179 * checks to see if the current token is at the start of a
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2180 * function or variable, or corresponds to a typedef, or
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2181 * is a struct/union/enum tag, or #define, or an enum constant.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2182 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2183 * *IS_FUNC gets TRUE iff the token is a function or #define macro
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2184 * with args. C_EXT is which language we are looking at.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2185 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2186 * In the future we will need some way to adjust where the end of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2187 * the token is; for instance, implementing the C++ keyword
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2188 * `operator' properly will adjust the end of the token to be after
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2189 * whatever follows `operator'.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2190 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2191 * Globals
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2192 * fvdef IN OUT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2193 * structdef IN OUT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2194 * definedef IN OUT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2195 * typdef IN OUT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2196 * objdef IN OUT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2197 * next_token_is_func IN OUT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2198 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2199 bool consider_token PP ((char *str, int len, int c, int c_ext,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2200 int cblev, int parlev, bool *is_func_or_var));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2201 bool
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2202 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2203 register char *str; /* IN: token pointer */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2204 register int len; /* IN: token length */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2205 register int c; /* IN: first char after the token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2206 int c_ext; /* IN: C extensions mask */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2207 int cblev; /* IN: curly brace level */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2208 int parlev; /* IN: parenthesis level */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2209 bool *is_func_or_var; /* OUT: function or variable found */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2210 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2211 enum sym_type toktype = C_symtype (str, len, c_ext);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2212
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2213 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2214 switch (toktype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2215 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2216 case st_C_struct:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2217 set_construct(C_STRUCTURE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2218 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2219 case st_C_union:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2220 set_construct(C_UNION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2221 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2222 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2223 set_construct(C_CLASS);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2224 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2225 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2226 set_construct(C_ENUMERATION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2227 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2228 case st_C_typedef:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2229 set_construct(C_TYPE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2230 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2231 case st_C_extern:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2232 set_construct(C_EXTERN);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2233 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2234 case st_C_inline:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2235 set_construct(C_FUNCTION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2236 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2237 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2238 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2239
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2240 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2241 * Advance the definedef state machine.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2242 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2243 switch (definedef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2244 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2245 case dnone:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2246 /* We're not on a preprocessor line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2247 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2248 case dsharpseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2249 if (toktype == st_C_define)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2250 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2251 definedef = ddefineseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2252 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2253 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2254 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2255 definedef = dignorerest;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2256 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2257 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2258 case ddefineseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2259 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2260 * Make a tag for any macro, unless it is a constant
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2261 * and constantypedefs is FALSE.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2262 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2263 definedef = dignorerest;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2264 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2265 *is_func_or_var = (c == '(');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2266 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2267 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2268 char *p = str + len * sizeof(char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2269
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2270 if (*p == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2271 /* This must be a macro since there is no
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2272 whitespace between the opening parenthesis
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2273 and the definition name. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2274 *is_func_or_var = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2275 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2276 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2277 *is_func_or_var = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2278
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2279 /* Handle possible whitespace between macro tag and opening
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2280 parenthesis and ensure this is an actual macro.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2281 -- Bob Weiner, Altrasoft, 11/19/1997 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2282 while (*p && isspace(*p)) p++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2283 if (*p) c = *p;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2284
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2285 /* Skip over nested parentheses. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2286 if (c == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2287 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2288 short depth = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2289
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2290 while (*++p && depth > 0 && *p != '\n')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2291 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2292 switch (*p)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2293 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2294 case '(':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2295 depth++; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2296 case ')':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2297 depth--; break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2298 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2299 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2300
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2301 /* If this is a macro, we have just passed
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2302 the arguments and there will be more on
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2303 the line before the NULL character that marks
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2304 the end of the line token. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2305 while (*p == ' ' || *p == '\t') p++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2306 if (*p) *is_func_or_var = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2307 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2308 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2309 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2310
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2311 set_construct((*is_func_or_var) ? C_MACRO : C_CONSTANT);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2312 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2313 if (!*is_func_or_var && !constantypedefs)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2314 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2315 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2316 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2317 case dignorerest:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2318 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2319 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2320 error ("internal error: definedef value.", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2321 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2322
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2323 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2324 * Now typedefs
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2325 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2326 switch (typdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2327 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2328 case tnone:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2329 if (toktype == st_C_typedef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2330 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2331 if (typedefs)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2332 typdef = ttypedseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2333 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2334 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2335 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2336 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2337 case ttypedseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2338 switch (toktype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2339 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2340 case st_C_const:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2341 set_construct(C_CONSTANT);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2342 /* fall through */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2343 case st_none:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2344 case st_C_typespec:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2345 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2346 case st_C_extern:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2347 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2348 typdef = tend;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2349 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2350 case st_C_struct:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2351 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2352 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2353 case st_C_union:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2354 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2355 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2356 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2357 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2358 /* Do not return here, so the structdef stuff has a chance. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2359 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2360 case tend:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2361 switch (toktype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2362 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2363 case st_C_const:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2364 set_construct(C_CONSTANT);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2365 /* fall through */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2366 case st_C_typespec:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2367 case st_C_struct:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2368 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2369 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2370 case st_C_extern:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2371 case st_C_union:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2372 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2373 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2374 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2375 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2376 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2377 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2378
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2379 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2380 * This structdef business is currently only invoked when cblev==0.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2381 * It should be recursively invoked whatever the curly brace level,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2382 * and a stack of states kept, to allow for definitions of structs
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2383 * within structs.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2384 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2385 * This structdef business is NOT invoked when we are ctags and the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2386 * file is plain C. This is because a struct tag may have the same
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2387 * name as another tag, and this loses with ctags.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2388 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2389 switch (toktype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2390 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2391 case st_C_javastruct:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2392 if (structdef == stagseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2393 structdef = scolonseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2394 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2395 case st_C_struct:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2396 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2397 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2398 case st_C_union:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2399 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2400 case st_C_extern:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2401 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2402 if (typdef == ttypedseen
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2403 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2404 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2405 structdef = skeyseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2406 structtype = toktype;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2407 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2408 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2409 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2410
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2411 if (structdef == skeyseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2412 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2413 /* Save the tag for struct/union/class, for functions and variables
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2414 that may be defined inside. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2415 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2416 if (structtype == st_C_struct)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2417 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2418 if (structtype == st_C_struct
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2419 || structtype == st_C_union
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2420 || structtype == st_C_class)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2421 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2422 structtag = savenstr (str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2423 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2424 structtag = "<enum>";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2425 structdef = stagseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2426 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2427 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2428
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2429 /* Avoid entering fvdef stuff if typdef is going on. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2430 if (typdef != tnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2431 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2432 definedef = dnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2433 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2434 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2435
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2436 /* Detect GNU macros.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2437
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2438 DEFUN note for writers of emacs C code:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2439 The DEFUN macro, used in emacs C source code, has a first arg
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2440 that is a string (the lisp function name), and a second arg that
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2441 is a C function name. Since etags skips strings, the second arg
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2442 is tagged. This is unfortunate, as it would be better to tag the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2443 first arg. The simplest way to deal with this problem would be
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2444 to name the tag with a name built from the function name, by
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2445 removing the initial 'F' character and substituting '-' for '_'.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2446 Anyway, this assumes that the conventions of naming lisp
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2447 functions will never change. Currently, this method is not
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2448 implemented, so writers of emacs code are recommended to put the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2449 first two args of a DEFUN on the same line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2450 if (definedef == dnone && toktype == st_C_gnumacro)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2451 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2452 next_token_is_func = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2453 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2454 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2455 if (next_token_is_func)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2456 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2457 next_token_is_func = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2458 fvdef = fignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2459 *is_func_or_var = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2460 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2461 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2462
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2463 /* Detect Objective C constructs. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2464 switch (objdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2465 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2466 case onone:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2467 switch (toktype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2468 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2469 case st_C_objprot:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2470 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2471 set_construct(C_OBJC);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2472 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2473 objdef = oprotocol;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2474 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2475 case st_C_objimpl:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2476 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2477 set_construct(C_OBJC);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2478 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2479 objdef = oimplementation;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2480 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2481 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2482 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2483 case oimplementation:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2484 /* Save the class tag for functions or variables defined inside. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2485 objtag = savenstr (str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2486 objdef = oinbody;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2487 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2488 case oprotocol:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2489 /* Save the class tag for categories. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2490 objtag = savenstr (str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2491 objdef = otagseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2492 *is_func_or_var = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2493 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2494 case oparenseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2495 objdef = ocatseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2496 *is_func_or_var = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2497 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2498 case oinbody:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2499 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2500 case omethodsign:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2501 if (parlev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2502 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2503 objdef = omethodtag;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2504 methodlen = len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2505 grow_linebuffer (&token_name, methodlen + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2506 strncpy (token_name.buffer, str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2507 token_name.buffer[methodlen] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2508 token_name.len = methodlen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2509 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2510 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2511 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2512 case omethodcolon:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2513 if (parlev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2514 objdef = omethodparm;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2515 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2516 case omethodparm:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2517 if (parlev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2518 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2519 objdef = omethodtag;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2520 methodlen += len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2521 grow_linebuffer (&token_name, methodlen + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2522 strncat (token_name.buffer, str, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2523 token_name.len = methodlen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2524 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2525 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2526 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2527 case oignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2528 if (toktype == st_C_objend)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2529 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2530 /* Memory leakage here: the string pointed by objtag is
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2531 never released, because many tests would be needed to
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2532 avoid breaking on incorrect input code. The amount of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2533 memory leaked here is the sum of the lengths of the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2534 class tags.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2535 free (objtag); */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2536 objdef = onone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2537 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2538 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2539 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2540
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2541 /* A function, variable or enum constant? */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2542 switch (toktype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2543 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2544 case st_C_const:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2545 set_construct(C_CONSTANT);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2546 /* fall through */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2547 case st_C_typespec:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2548 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2549 case st_C_extern:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2550 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2551 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2552 fvdef = fvnone; /* should be useless */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2553 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2554 case st_C_ignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2555 fvdef = vignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2556 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2557 case st_none:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2558 if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2559 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2560 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2561 oo_browser_construct = C_ENUM_LABEL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2562 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2563 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2564 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2565 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2566 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2567 if (fvdef == fvnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2568 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2569 fvdef = fvnameseen; /* function or variable */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2570 *is_func_or_var = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2571 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2572 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2573 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2574
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2575 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2576 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2577
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2578 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2579 * C_entries ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2580 * This routine finds functions, variables, typedefs,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2581 * #define's, enum constants and struct/union/enum definitions in
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2582 * #C syntax and adds them to the list.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2583 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2584 #define current_lb_is_new (newndx == curndx)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2585 #define switch_line_buffers() (curndx = 1 - curndx)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2586
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2587 #define curlb (lbs[curndx].lb)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2588 #define othlb (lbs[1-curndx].lb)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2589 #define newlb (lbs[newndx].lb)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2590 #define curlinepos (lbs[curndx].linepos)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2591 #define othlinepos (lbs[1-curndx].linepos)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2592 #define newlinepos (lbs[newndx].linepos)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2593
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2594 #define CNL_SAVE_DEFINEDEF() \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2595 do { \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2596 curlinepos = charno; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2597 lineno++; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2598 linecharno = charno; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2599 charno += readline (&curlb, inf); \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2600 lp = curlb.buffer; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2601 quotednl = FALSE; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2602 newndx = curndx; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2603 } while (0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2604
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2605 #define CNL() \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2606 do { \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2607 CNL_SAVE_DEFINEDEF(); \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2608 if (savetok.valid) \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2609 { \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2610 tok = savetok; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2611 savetok.valid = FALSE; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2612 } \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2613 definedef = dnone; \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2614 } while (0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2615
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2616
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2617 void make_C_tag PP ((bool isfun));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2618 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2619 make_C_tag (isfun)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2620 bool isfun;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2621 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2622 /* This function should never be called when tok.valid is FALSE, but
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2623 we must protect against invalid input or internal errors. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2624 if (tok.valid)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2625 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2626 if (traditional_tag_style)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2627 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2628 /* This was the original code. Now we call new_pfnote instead,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2629 which uses the new method for naming tags (see new_pfnote). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2630 char *name = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2631
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2632 if (CTAGS || tok.named)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2633 name = savestr (token_name.buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2634 pfnote (name, isfun,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2635 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2636 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2637 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2638 new_pfnote (token_name.buffer, token_name.len, isfun,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2639 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2640 tok.valid = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2641 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2642 else if (DEBUG)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2643 abort ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2644 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2645
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2646
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2647 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2648 C_entries (c_ext, inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2649 int c_ext; /* extension of C */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2650 FILE *inf; /* input file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2651 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2652 register char c; /* latest char read; '\0' for end of line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2653 register char *lp; /* pointer one beyond the character `c' */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2654 int curndx, newndx; /* indices for current and new lb */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2655 register int tokoff; /* offset in line of start of current token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2656 register int toklen; /* length of current token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2657 char *qualifier; /* string used to qualify names */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2658 int qlen; /* length of qualifier */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2659 int cblev; /* current curly brace level */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2660 int parlev; /* current parenthesis level */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2661 bool incomm, inquote, inchar, quotednl, midtoken;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2662 bool cplpl, cjava;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2663 token savetok; /* token saved during preprocessor handling */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2664
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2665
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2666 tokoff = toklen = 0; /* keep compiler quiet */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2667 curndx = newndx = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2668 lineno = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2669 charno = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2670 lp = curlb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2671 *lp = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2672
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2673 fvdef = fvnone; typdef = tnone; structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2674 definedef = dnone; objdef = onone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2675 next_token_is_func = yacc_rules = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2676 midtoken = inquote = inchar = incomm = quotednl = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2677 tok.valid = savetok.valid = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2678 cblev = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2679 parlev = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2680 cplpl = (c_ext & C_PLPL) == C_PLPL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2681 cjava = (c_ext & C_JAVA) == C_JAVA;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2682 if (cjava)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2683 { qualifier = "."; qlen = 1; }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2684 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2685 { qualifier = "::"; qlen = 2; }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2686
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2687 while (!feof (inf))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2688 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2689 c = *lp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2690 if (c == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2691 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2692 /* If we're at the end of the line, the next character is a
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2693 '\0'; don't skip it, because it's the thing that tells us
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2694 to read the next line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2695 if (*lp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2696 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2697 quotednl = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2698 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2699 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2700 lp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2701 c = ' ';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2702 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2703 else if (incomm)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2704 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2705 switch (c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2706 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2707 case '*':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2708 if (*lp == '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2709 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2710 c = *lp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2711 incomm = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2712 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2713 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2714 case '\0':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2715 /* Newlines inside comments do not end macro definitions in
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2716 traditional cpp. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2717 CNL_SAVE_DEFINEDEF ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2718 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2719 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2720 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2721 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2722 else if (inquote)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2723 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2724 switch (c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2725 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2726 case '"':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2727 inquote = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2728 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2729 case '\0':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2730 /* Newlines inside strings do not end macro definitions
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2731 in traditional cpp, even though compilers don't
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2732 usually accept them. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2733 CNL_SAVE_DEFINEDEF ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2734 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2735 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2736 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2737 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2738 else if (inchar)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2739 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2740 switch (c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2741 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2742 case '\0':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2743 /* Hmmm, something went wrong. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2744 CNL ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2745 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2746 case '\'':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2747 inchar = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2748 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2749 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2750 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2751 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2752 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2753 switch (c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2754 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2755 case '"':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2756 inquote = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2757 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2758 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2759 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2760 case '\'':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2761 inchar = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2762 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2763 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2764 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2765 case '/':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2766 if (*lp == '*')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2767 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2768 lp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2769 incomm = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2770 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2771 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2772 else if (/* cplpl && */ *lp == '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2773 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2774 c = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2775 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2776 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2777 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2778 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2779 case '%':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2780 if ((c_ext & YACC) && *lp == '%')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2781 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2782 /* entering or exiting rules section in yacc file */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2783 lp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2784 definedef = dnone; fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2785 typdef = tnone; structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2786 next_token_is_func = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2787 midtoken = inquote = inchar = incomm = quotednl = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2788 cblev = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2789 yacc_rules = !yacc_rules;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2790 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2791 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2792 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2793 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2794 case '#':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2795 if (definedef == dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2796 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2797 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2798 bool cpptoken = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2799
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2800 /* Look back on this line. If all blanks, or nonblanks
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2801 followed by an end of comment, this is a preprocessor
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2802 token. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2803 for (cp = newlb.buffer; cp < lp-1; cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2804 if (!iswhite (*cp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2805 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2806 if (*cp == '*' && *(cp+1) == '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2807 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2808 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2809 cpptoken = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2810 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2811 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2812 cpptoken = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2813 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2814 if (cpptoken)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2815 definedef = dsharpseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2816 } /* if (definedef == dnone) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2817
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2818 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2819 } /* switch (c) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2820
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2821
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2822 /* Consider token only if some complicated conditions are satisfied. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2823 if ((definedef != dnone
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2824 || (cblev == 0 && structdef != scolonseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2825 || (cblev == 1 && cplpl && structdef == sinbody)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2826 || (structdef == sinbody && structtype == st_C_enum))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2827 && typdef != tignore
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2828 && definedef != dignorerest
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2829 && fvdef != finlist)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2830 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2831 if (midtoken)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2832 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2833 if (endtoken (c))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2834 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2835 if (c == ':' && cplpl && *lp == ':' && begtoken(*(lp + 1)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2836 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2837 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2838 * This handles :: in the middle, but not at the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2839 * beginning of an identifier.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2840 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2841 lp += 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2842 toklen += 3;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2843 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2844 set_construct(C_METHOD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2845 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2846 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2847 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2848 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2849 bool funorvar = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2850
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2851 if (yacc_rules
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2852 || consider_token (newlb.buffer + tokoff, toklen, c,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2853 c_ext, cblev, parlev, &funorvar))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2854 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2855 tok.named = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2856 if (structdef == sinbody
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2857 && definedef == dnone
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2858 && funorvar)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2859 /* function or var defined in C++ class body */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2860 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2861 int len = strlen (structtag) + qlen + toklen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2862 grow_linebuffer (&token_name, len + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2863 strcpy (token_name.buffer, structtag);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2864 strcat (token_name.buffer, qualifier);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2865 strncat (token_name.buffer,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2866 newlb.buffer + tokoff, toklen);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2867 token_name.len = len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2868 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2869 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2870 oo_browser_construct = C_METHOD;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2871 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2872 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2873 else if (objdef == ocatseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2874 /* Objective C category */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2875 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2876 int len = strlen (objtag) + 2 + toklen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2877 grow_linebuffer (&token_name, len + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2878 strcpy (token_name.buffer, objtag);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2879 strcat (token_name.buffer, "(");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2880 strncat (token_name.buffer,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2881 newlb.buffer + tokoff, toklen);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2882 strcat (token_name.buffer, ")");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2883 token_name.len = len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2884 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2885 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2886 oo_browser_construct = C_OBJC;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2887 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2888 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2889 else if (objdef == omethodtag
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2890 || objdef == omethodparm)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2891 /* Objective C method */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2892 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2893 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2894 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2895 oo_browser_construct = C_OBJC;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2896 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2897 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2898 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2899 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2900 grow_linebuffer (&token_name, toklen + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2901 strncpy (token_name.buffer,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2902 newlb.buffer + tokoff, toklen);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2903 token_name.buffer[toklen] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2904 token_name.len = toklen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2905 /* Name macros. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2906 tok.named
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2907 = (structdef == stagseen
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2908 || typdef == tend
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2909 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2910 /* Also name #define constants,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2911 enumerations and enum_labels.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2912 Conditionalize `funorvar' reference
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2913 here or #defines will appear without
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2914 their #names.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2915 -- Bob Weiner, Altrasoft, 4/25/1998 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2916 || ((oo_browser_format || funorvar)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2917 && definedef == dignorerest)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2918 || (oo_browser_format
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2919 && (oo_browser_construct == C_ENUMERATION
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2920 || oo_browser_construct == C_ENUM_LABEL))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2921 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2922 || (funorvar
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2923 && definedef == dignorerest)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2924 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2925 );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2926 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2927 tok.lineno = lineno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2928 tok.linelen = tokoff + toklen + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2929 tok.buffer = newlb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2930 tok.linepos = newlinepos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2931 tok.valid = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2932
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2933 if (definedef == dnone
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2934 && (fvdef == fvnameseen
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2935 || structdef == stagseen
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2936 || typdef == tend
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2937 || objdef != onone))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2938 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2939 if (current_lb_is_new)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2940 switch_line_buffers ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2941 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2942 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2943 make_C_tag (funorvar);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2944 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2945 midtoken = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2946 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2947 } /* if (endtoken (c)) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2948 else if (intoken (c))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2949 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2950 toklen++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2951 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2952 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2953 } /* if (midtoken) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2954 else if (begtoken (c))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2955 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2956 switch (definedef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2957 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2958 case dnone:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2959 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2960 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2961 case fstartlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2962 fvdef = finlist;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2963 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2964 case flistseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2965 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2966 set_construct(C_MACRO);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2967 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2968 make_C_tag (TRUE); /* a function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2969 fvdef = fignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2970 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2971 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2972 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2973 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2974 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2975 if (structdef == stagseen && !cjava)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2976 structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2977 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2978 case dsharpseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2979 savetok = tok;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2980 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2981 if (!yacc_rules || lp == newlb.buffer + 1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2982 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2983 tokoff = lp - 1 - newlb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2984 toklen = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2985 midtoken = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2986 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2987 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2988 } /* if (begtoken) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2989 } /* if must look at token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2990
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2991
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2992 /* Detect end of line, colon, comma, semicolon and various braces
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2993 after having handled a token.*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2994 switch (c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2995 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2996 case ':':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2997 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2998 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
2999 switch (objdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3000 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3001 case otagseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3002 objdef = oignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3003 make_C_tag (TRUE); /* an Objective C class */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3004 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3005 case omethodtag:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3006 case omethodparm:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3007 objdef = omethodcolon;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3008 methodlen += 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3009 grow_linebuffer (&token_name, methodlen + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3010 strcat (token_name.buffer, ":");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3011 token_name.len = methodlen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3012 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3013 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3014 if (structdef == stagseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3015 structdef = scolonseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3016 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3017 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3018 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3019 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3020 if (yacc_rules)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3021 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3022 make_C_tag (FALSE); /* a yacc function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3023 fvdef = fignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3024 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3025 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3026 case fstartlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3027 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3028 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3029 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3030 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3031 case ';':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3032 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3033 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3034 if (cblev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3035 switch (typdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3036 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3037 case tend:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3038 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3039 set_construct(C_TYPE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3040 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3041 make_C_tag (FALSE); /* a typedef */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3042 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3043 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3044 typdef = tnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3045 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3046 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3047 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3048 case fignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3049 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3050 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3051 if ((globals && cblev == 0) || (members && cblev == 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3052 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3053 make_C_tag (FALSE); /* a variable */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3054 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3055 /* if (constantypedefs && structdef == snone)*/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3056 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3057 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3058 switch (structtype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3059 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3060 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3061 set_construct(C_ENUMERATION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3062 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3063 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3064 set_construct(C_CLASS);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3065 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3066 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3067 set_construct(C_VARIABLE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3068 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3069 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3070 make_C_tag (FALSE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3071 /* Force reset of st_C_enum structtype value. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3072 structtype = st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3073 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3074 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3075 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3076 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3077 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3078 /* The following instruction invalidates the token.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3079 Probably the token should be invalidated in all
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3080 other cases where some state machine is reset. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3081 tok.valid = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3082 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3083 if (structdef == stagseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3084 structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3085 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3086 case ',':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3087 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3088 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3089 switch (objdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3090 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3091 case omethodtag:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3092 case omethodparm:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3093 make_C_tag (TRUE); /* an Objective C method */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3094 objdef = oinbody;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3095 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3096 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3097 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3098 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3099 case finlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3100 case fignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3101 case vignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3102 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3103 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3104 if ((globals && cblev == 0) || (members && cblev == 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3105 make_C_tag (FALSE); /* a variable */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3106 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3107 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3108 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3109 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3110 if (structdef == stagseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3111 structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3112 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3113 case '[':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3114 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3115 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3116 if (cblev == 0 && typdef == tend)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3117 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3118 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3119 set_construct(C_TYPE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3120 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3121 typdef = tignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3122 make_C_tag (FALSE); /* a typedef */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3123 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3124 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3125 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3126 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3127 case finlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3128 case fignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3129 case vignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3130 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3131 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3132 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3133 if ((globals && cblev == 0) || (members && cblev == 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3134 make_C_tag (FALSE); /* a variable */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3135 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3136 if (constantypedefs && structdef == snone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3137 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3138 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3139 switch (structtype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3140 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3141 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3142 set_construct(C_ENUMERATION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3143 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3144 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3145 set_construct(C_CLASS);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3146 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3147 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3148 set_construct(C_VARIABLE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3149 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3150 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3151 make_C_tag (FALSE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3152 /* Force reset of st_C_enum structtype value. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3153 structtype = st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3154 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3155 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3156 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3157 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3158 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3159 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3160 if (structdef == stagseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3161 structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3162 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3163 case '(':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3164 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3165 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3166 if (objdef == otagseen && parlev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3167 objdef = oparenseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3168 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3169 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3170 case fvnone:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3171 switch (typdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3172 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3173 case ttypedseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3174 case tend:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3175 if (tok.valid && *lp != '*')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3176 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3177 /* This handles constructs like:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3178 typedef void OperatorFun (int fun); */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3179 typdef = tignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3180 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3181 set_construct(C_TYPE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3182 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3183 make_C_tag (FALSE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3184 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3185 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3186 } /* switch (typdef) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3187 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3188 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3189 fvdef = fstartlist;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3190 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3191 case flistseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3192 fvdef = finlist;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3193 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3194 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3195 parlev++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3196 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3197 case ')':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3198 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3199 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3200 if (objdef == ocatseen && parlev == 1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3201 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3202 make_C_tag (TRUE); /* an Objective C category */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3203 objdef = oignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3204 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3205 if (--parlev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3206 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3207 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3208 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3209 case fstartlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3210 case finlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3211 fvdef = flistseen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3212 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3213 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3214 if (cblev == 0 && typdef == tend)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3215 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3216 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3217 set_construct(C_TYPE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3218 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3219 typdef = tignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3220 make_C_tag (FALSE); /* a typedef */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3221 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3222 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3223 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3224 parlev = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3225 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3226 case '{':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3227 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3228 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3229 if (typdef == ttypedseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3230 typdef = tinbody;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3231 switch (structdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3232 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3233 case skeyseen: /* unnamed struct */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3234 structdef = sinbody;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3235 structtag = "_anonymous_";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3236 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3237 case stagseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3238 case scolonseen: /* named struct */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3239 structdef = sinbody;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3240 make_C_tag (FALSE); /* a struct */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3241 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3242 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3243 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3244 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3245 case flistseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3246 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3247 set_construct(C_FUNCTION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3248 /* Ensure function name is recorded.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3249 -- Bob Weiner, Altrasoft */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3250 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3251 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3252 make_C_tag (TRUE); /* a function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3253 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3254 case fignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3255 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3256 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3257 case fvnone:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3258 switch (objdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3259 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3260 case otagseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3261 make_C_tag (TRUE); /* an Objective C class */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3262 objdef = oignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3263 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3264 case omethodtag:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3265 case omethodparm:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3266 make_C_tag (TRUE); /* an Objective C method */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3267 objdef = oinbody;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3268 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3269 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3270 /* Neutralize `extern "C" {' grot. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3271 if (cblev == 0 && structdef == snone && typdef == tnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3272 cblev = -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3273 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3274 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3275 cblev++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3276 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3277 case '*':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3278 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3279 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3280 if (fvdef == fstartlist)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3281 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3282 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3283 case '}':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3284 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3285 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3286 if (!noindentypedefs && lp == newlb.buffer + 1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3287 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3288 cblev = 0; /* reset curly brace level if first column */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3289 parlev = 0; /* also reset paren level, just in case... */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3290 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3291 else if (cblev > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3292 cblev--;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3293 if (cblev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3294 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3295 if (typdef == tinbody)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3296 typdef = tend;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3297 /* Memory leakage here: the string pointed by structtag is
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3298 never released, because I fear to miss something and
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3299 break things while freeing the area. The amount of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3300 memory leaked here is the sum of the lengths of the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3301 struct tags.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3302 if (structdef == sinbody)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3303 free (structtag); */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3304
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3305 structdef = snone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3306 structtag = "<error>";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3307 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3308 /* Next line added to avoid any state carryover between
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3309 functions. -- Bob Weiner, Altrasoft, 11/19/1997 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3310 fvdef = fvnone; oo_browser_construct = C_NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3311 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3312 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3313 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3314 case '=':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3315 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3316 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3317 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3318 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3319 int is_method = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3320 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3321 switch (fvdef)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3322 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3323 case finlist:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3324 case fignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3325 case vignore:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3326 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3327 case fvnameseen:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3328 if ((globals && cblev == 0) || (members && cblev == 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3329 #ifndef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3330 make_C_tag (FALSE); /* a variable */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3331 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3332 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3333 tok.named = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3334 switch (structtype)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3335 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3336 case st_C_enum:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3337 set_construct(C_ENUMERATION);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3338 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3339 case st_C_class:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3340 set_construct(C_CLASS);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3341 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3342 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3343 /* a global variable */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3344 set_construct(C_VARIABLE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3345 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3346 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3347
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3348 /* ootags categorizes each tag found whereas etags doesn't.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3349 Set the is_method flag if this tag has been marked as
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3350 such by an earlier section of code.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3351 -- Steve Baur, Altrasoft, 5/7/1998 */
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3352 is_method = (oo_browser_construct == C_METHOD);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3353
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3354 make_C_tag (FALSE);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3355 /* Force reset of st_C_enum structtype value. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3356 structtype = st_none;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3357 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3358 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3359 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3360 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3361 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3362 fvdef = is_method ? fignore : vignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3363 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3364 fvdef = vignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3365 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3366 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3367 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3368 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3369 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3370 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3371 case '+':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3372 case '-':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3373 if (objdef == oinbody && cblev == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3374 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3375 objdef = omethodsign;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3376 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3377 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3378 /* FALLTHRU */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3379 case '#': case '~': case '&': case '%': case '/': case '|':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3380 case '^': case '!': case '<': case '>': case '.': case '?': case ']':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3381 if (definedef != dnone)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3382 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3383 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3384 if (!cplpl)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3385 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3386 #endif
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3387 /* The above characters cannot follow a function tag in C, so
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3388 unmark this as a function entry. For C++, these characters
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3389 may follow an `operator' function construct, so skip the
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3390 unmarking conditional below.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3391 -- Steve Baur, Altrasoft, 5/7/1998 */
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3392 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3393 fvdef = fvnone;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3394 #ifdef OO_BROWSER
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3395 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3396 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3397 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3398 case '\0':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3399 if (objdef == otagseen)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3400 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3401 make_C_tag (TRUE); /* an Objective C class */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3402 objdef = oignore;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3403 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3404 /* If a macro spans multiple lines don't reset its state. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3405 if (quotednl)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3406 CNL_SAVE_DEFINEDEF ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3407 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3408 CNL ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3409 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3410 } /* switch (c) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3411
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3412 } /* while not eof */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3413 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3414
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3415 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3416 * Process either a C++ file or a C file depending on the setting
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3417 * of a global flag.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3418 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3419 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3420 default_C_entries (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3421 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3422 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3423 C_entries (cplusplus ? C_PLPL : 0, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3424 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3425
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3426 /* Always do plain ANSI C. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3427 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3428 plain_C_entries (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3429 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3430 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3431 C_entries (0, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3432 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3433
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3434 /* Always do C++. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3435 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3436 Cplusplus_entries (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3437 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3438 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3439 C_entries (C_PLPL, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3440 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3441
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3442 /* Always do Java. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3443 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3444 Cjava_entries (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3445 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3446 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3447 C_entries (C_JAVA, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3448 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3449
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3450 /* Always do C*. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3451 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3452 Cstar_entries (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3453 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3454 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3455 C_entries (C_STAR, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3456 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3457
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3458 /* Always do Yacc. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3459 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3460 Yacc_entries (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3461 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3462 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3463 C_entries (YACC, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3464 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3465
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3466 /* A useful macro. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3467 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3468 for (lineno = charno = 0; /* loop initialization */ \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3469 !feof (file_pointer) /* loop test */ \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3470 && (lineno++, /* instructions at start of loop */ \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3471 linecharno = charno, \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3472 charno += readline (&line_buffer, file_pointer), \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3473 char_pointer = lb.buffer, \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3474 TRUE); \
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3475 )
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3476
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3477
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3478 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3479 * Read a file, but do no processing. This is used to do regexp
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3480 * matching on files that have no language defined.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3481 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3482 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3483 just_read_file (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3484 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3485 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3486 register char *dummy;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3487
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3488 LOOP_ON_INPUT_LINES (inf, lb, dummy)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3489 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3490 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3491
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3492 /* Fortran parsing */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3493
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3494 bool tail PP ((char *cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3495 bool
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3496 tail (cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3497 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3498 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3499 register int len = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3500
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3501 while (*cp && lowcase(*cp) == lowcase(dbp[len]))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3502 cp++, len++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3503 if (*cp == '\0' && !intoken(dbp[len]))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3504 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3505 dbp += len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3506 return TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3507 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3508 return FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3509 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3510
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3511 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3512 takeprec ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3513 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3514 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3515 if (*dbp != '*')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3516 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3517 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3518 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3519 if (strneq (dbp, "(*)", 3))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3520 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3521 dbp += 3;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3522 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3523 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3524 if (!isdigit (*dbp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3525 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3526 --dbp; /* force failure */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3527 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3528 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3529 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3530 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3531 while (isdigit (*dbp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3532 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3533
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3534 void getit PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3535 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3536 getit (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3537 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3538 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3539 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3540
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3541 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3542 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3543 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3544 lineno++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3545 linecharno = charno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3546 charno += readline (&lb, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3547 dbp = lb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3548 if (dbp[5] != '&')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3549 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3550 dbp += 6;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3551 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3552 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3553 if (!isalpha (*dbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3554 && *dbp != '_'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3555 && *dbp != '$')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3556 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3557 for (cp = dbp + 1; *cp && intoken (*cp); cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3558 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3559 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3560 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3561 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3562
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3563
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3564 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3565 Fortran_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3566 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3567 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3568 LOOP_ON_INPUT_LINES (inf, lb, dbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3569 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3570 if (*dbp == '%')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3571 dbp++; /* Ratfor escape to fortran */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3572 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3573 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3574 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3575 switch (lowcase (*dbp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3576 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3577 case 'i':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3578 if (tail ("integer"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3579 takeprec ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3580 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3581 case 'r':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3582 if (tail ("real"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3583 takeprec ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3584 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3585 case 'l':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3586 if (tail ("logical"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3587 takeprec ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3588 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3589 case 'c':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3590 if (tail ("complex") || tail ("character"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3591 takeprec ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3592 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3593 case 'd':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3594 if (tail ("double"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3595 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3596 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3597 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3598 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3599 if (tail ("precision"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3600 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3601 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3602 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3603 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3604 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3605 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3606 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3607 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3608 switch (lowcase (*dbp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3609 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3610 case 'f':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3611 if (tail ("function"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3612 getit (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3613 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3614 case 's':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3615 if (tail ("subroutine"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3616 getit (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3617 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3618 case 'e':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3619 if (tail ("entry"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3620 getit (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3621 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3622 case 'p':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3623 if (tail ("program"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3624 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3625 getit (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3626 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3627 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3628 if (tail ("procedure"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3629 getit (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3630 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3631 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3632 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3633 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3634
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3635 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3636 * Bob Weiner, Motorola Inc., 4/3/94
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3637 * Unix and microcontroller assembly tag handling
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3638 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3639 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3640 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3641 Asm_labels (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3642 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3643 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3644 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3645
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3646 LOOP_ON_INPUT_LINES (inf, lb, cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3647 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3648 /* If first char is alphabetic or one of [_.$], test for colon
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3649 following identifier. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3650 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3651 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3652 /* Read past label. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3653 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3654 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3655 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3656 if (*cp == ':' || isspace (*cp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3657 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3658 /* Found end of label, so copy it and add it to the table. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3659 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3660 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3661 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3662 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3663 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3664 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3665
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3666 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3667 * Perl support by Bart Robinson <lomew@cs.utah.edu>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3668 * enhanced by Michael Ernst <mernst@alum.mit.edu>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3669 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3670 * Perl variable names: /^(my|local).../
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3671 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3672 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3673 Perl_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3674 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3675 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3676 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3677
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3678 LOOP_ON_INPUT_LINES (inf, lb, cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3679 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3680 if (*cp++ == 's'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3681 && *cp++ == 'u'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3682 && *cp++ == 'b' && isspace (*cp++))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3683 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3684 cp = skip_spaces (cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3685 if (*cp != '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3686 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3687 while (*cp != '\0'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3688 && !isspace (*cp) && *cp != '{' && *cp != '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3689 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3690 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3691 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3692 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3693 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3694 else if (globals /* only if tagging global vars is enabled */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3695 && ((cp = lb.buffer,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3696 *cp++ == 'm'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3697 && *cp++ == 'y')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3698 || (cp = lb.buffer,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3699 *cp++ == 'l'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3700 && *cp++ == 'o'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3701 && *cp++ == 'c'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3702 && *cp++ == 'a'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3703 && *cp++ == 'l'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3704 && (*cp == '(' || isspace (*cp)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3705 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3706 /* After "my" or "local", but before any following paren or space. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3707 char *varname = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3708
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3709 cp = skip_spaces (cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3710 if (*cp == '$' || *cp == '@' || *cp == '%')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3711 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3712 char* varstart = ++cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3713 while (isalnum (*cp) || *cp == '_')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3714 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3715 varname = savenstr (varstart, cp-varstart);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3716 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3717 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3718 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3719 /* Should be examining a variable list at this point;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3720 could insist on seeing an open parenthesis. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3721 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3722 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3723 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3724
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3725 /* Perhaps I should back cp up one character, so the TAGS table
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3726 doesn't mention (and so depend upon) the following char. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3727 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3728 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3729 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3730 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3731 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3732
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3733 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3734 * Python support by Eric S. Raymond <esr@thyrsus.com>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3735 * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3736 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3737 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3738 Python_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3739 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3740 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3741 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3742
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3743 LOOP_ON_INPUT_LINES (inf, lb, cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3744 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3745 if (*cp++ == 'd'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3746 && *cp++ == 'e'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3747 && *cp++ == 'f' && isspace (*cp++))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3748 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3749 cp = skip_spaces (cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3750 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3751 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3752 pfnote ((char *) NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3753 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3754 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3755
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3756 cp = lb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3757 if (*cp++ == 'c'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3758 && *cp++ == 'l'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3759 && *cp++ == 'a'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3760 && *cp++ == 's'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3761 && *cp++ == 's' && isspace (*cp++))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3762 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3763 cp = skip_spaces (cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3764 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3765 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3766 pfnote ((char *) NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3767 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3768 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3769 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3770 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3771
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3772 /* Idea by Corny de Souza
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3773 * Cobol tag functions
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3774 * We could look for anything that could be a paragraph name.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3775 * i.e. anything that starts in column 8 is one word and ends in a full stop.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3776 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3777 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3778 Cobol_paragraphs (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3779 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3780 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3781 register char *bp, *ep;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3782
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3783 LOOP_ON_INPUT_LINES (inf, lb, bp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3784 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3785 if (lb.len < 9)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3786 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3787 bp += 8;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3788
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3789 /* If eoln, compiler option or comment ignore whole line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3790 if (bp[-1] != ' ' || !isalnum (bp[0]))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3791 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3792
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3793 for (ep = bp; isalnum (*ep) || *ep == '-'; ep++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3794 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3795 if (*ep++ == '.')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3796 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3797 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3798 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3799 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3800
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3801 /* Added by Mosur Mohan, 4/22/88 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3802 /* Pascal parsing */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3803
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3804 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3805 * Locates tags for procedures & functions. Doesn't do any type- or
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3806 * var-definitions. It does look for the keyword "extern" or
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3807 * "forward" immediately following the procedure statement; if found,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3808 * the tag is skipped.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3809 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3810 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3811 Pascal_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3812 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3813 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3814 linebuffer tline; /* mostly copied from C_entries */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3815 long save_lcno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3816 int save_lineno, save_len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3817 char c, *cp, *namebuf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3818
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3819 bool /* each of these flags is TRUE iff: */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3820 incomment, /* point is inside a comment */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3821 inquote, /* point is inside '..' string */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3822 get_tagname, /* point is after PROCEDURE/FUNCTION
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3823 keyword, so next item = potential tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3824 found_tag, /* point is after a potential tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3825 inparms, /* point is within parameter-list */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3826 verify_tag; /* point has passed the parm-list, so the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3827 next token will determine whether this
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3828 is a FORWARD/EXTERN to be ignored, or
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3829 whether it is a real tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3830
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3831 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3832 namebuf = NULL; /* keep compiler quiet */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3833 lineno = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3834 charno = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3835 dbp = lb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3836 *dbp = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3837 initbuffer (&tline);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3838
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3839 incomment = inquote = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3840 found_tag = FALSE; /* have a proc name; check if extern */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3841 get_tagname = FALSE; /* have found "procedure" keyword */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3842 inparms = FALSE; /* found '(' after "proc" */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3843 verify_tag = FALSE; /* check if "extern" is ahead */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3844
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3845
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3846 while (!feof (inf)) /* long main loop to get next char */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3847 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3848 c = *dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3849 if (c == '\0') /* if end of line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3850 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3851 lineno++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3852 linecharno = charno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3853 charno += readline (&lb, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3854 dbp = lb.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3855 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3856 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3857 if (!((found_tag && verify_tag)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3858 || get_tagname))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3859 c = *dbp++; /* only if don't need *dbp pointing
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3860 to the beginning of the name of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3861 the procedure or function */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3862 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3863 if (incomment)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3864 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3865 if (c == '}') /* within { } comments */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3866 incomment = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3867 else if (c == '*' && *dbp == ')') /* within (* *) comments */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3868 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3869 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3870 incomment = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3871 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3872 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3873 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3874 else if (inquote)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3875 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3876 if (c == '\'')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3877 inquote = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3878 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3879 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3880 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3881 switch (c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3882 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3883 case '\'':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3884 inquote = TRUE; /* found first quote */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3885 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3886 case '{': /* found open { comment */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3887 incomment = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3888 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3889 case '(':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3890 if (*dbp == '*') /* found open (* comment */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3891 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3892 incomment = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3893 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3894 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3895 else if (found_tag) /* found '(' after tag, i.e., parm-list */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3896 inparms = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3897 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3898 case ')': /* end of parms list */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3899 if (inparms)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3900 inparms = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3901 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3902 case ';':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3903 if (found_tag && !inparms) /* end of proc or fn stmt */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3904 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3905 verify_tag = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3906 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3907 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3908 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3909 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3910 if (found_tag && verify_tag && (*dbp != ' '))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3911 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3912 /* check if this is an "extern" declaration */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3913 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3914 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3915 if (lowcase (*dbp == 'e'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3916 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3917 if (tail ("extern")) /* superfluous, really! */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3918 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3919 found_tag = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3920 verify_tag = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3921 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3922 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3923 else if (lowcase (*dbp) == 'f')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3924 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3925 if (tail ("forward")) /* check for forward reference */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3926 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3927 found_tag = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3928 verify_tag = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3929 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3930 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3931 if (found_tag && verify_tag) /* not external proc, so make tag */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3932 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3933 found_tag = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3934 verify_tag = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3935 pfnote (namebuf, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3936 tline.buffer, save_len, save_lineno, save_lcno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3937 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3938 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3939 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3940 if (get_tagname) /* grab name of proc or fn */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3941 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3942 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3943 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3944
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3945 /* save all values for later tagging */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3946 grow_linebuffer (&tline, lb.len + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3947 strcpy (tline.buffer, lb.buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3948 save_lineno = lineno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3949 save_lcno = linecharno;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3950
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3951 /* grab block name */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3952 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3953 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3954 namebuf = (CTAGS) ? savenstr (dbp, cp-dbp) : NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3955 dbp = cp; /* set dbp to e-o-token */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3956 save_len = dbp - lb.buffer + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3957 get_tagname = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3958 found_tag = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3959 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3960
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3961 /* and proceed to check for "extern" */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3962 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3963 else if (!incomment && !inquote && !found_tag)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3964 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3965 /* check for proc/fn keywords */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3966 switch (lowcase (c))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3967 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3968 case 'p':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3969 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3970 get_tagname = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3971 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3972 case 'f':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3973 if (tail ("unction"))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3974 get_tagname = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3975 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3976 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3977 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3978 } /* while not eof */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3979
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3980 free (tline.buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3981 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3982
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3983 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3984 * lisp tag functions
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3985 * look for (def or (DEF, quote or QUOTE
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3986 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3987 int L_isdef PP ((char *strp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3988 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3989 L_isdef (strp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3990 register char *strp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3991 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3992 return ((strp[1] == 'd' || strp[1] == 'D')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3993 && (strp[2] == 'e' || strp[2] == 'E')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3994 && (strp[3] == 'f' || strp[3] == 'F'));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3995 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3996 int L_isquote PP ((char *strp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3997 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3998 L_isquote (strp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
3999 register char *strp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4000 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4001 return ((*++strp == 'q' || *strp == 'Q')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4002 && (*++strp == 'u' || *strp == 'U')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4003 && (*++strp == 'o' || *strp == 'O')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4004 && (*++strp == 't' || *strp == 'T')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4005 && (*++strp == 'e' || *strp == 'E')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4006 && isspace (*++strp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4007 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4008
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4009 void L_getit PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4010 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4011 L_getit ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4012 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4013 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4014
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4015 if (*dbp == '\'') /* Skip prefix quote */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4016 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4017 else if (*dbp == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4018 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4019 if (L_isquote (dbp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4020 dbp += 7; /* Skip "(quote " */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4021 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4022 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4023 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4024 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4025
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4026 for (cp = dbp /*+1*/;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4027 *cp != '\0' && *cp != '(' && *cp != ' ' && *cp != ')';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4028 cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4029 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4030 if (cp == dbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4031 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4032
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4033 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4034 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4035 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4036
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4037 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4038 Lisp_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4039 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4040 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4041 LOOP_ON_INPUT_LINES (inf, lb, dbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4042 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4043 if (dbp[0] == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4044 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4045 if (L_isdef (dbp))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4046 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4047 dbp = skip_non_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4048 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4049 L_getit ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4050 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4051 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4052 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4053 /* Check for (foo::defmumble name-defined ... */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4054 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4055 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4056 while (*dbp != '\0' && !isspace (*dbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4057 && *dbp != ':' && *dbp != '(' && *dbp != ')');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4058 if (*dbp == ':')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4059 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4060 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4061 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4062 while (*dbp == ':');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4063
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4064 if (L_isdef (dbp - 1))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4065 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4066 dbp = skip_non_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4067 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4068 L_getit ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4069 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4070 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4071 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4072 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4073 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4074 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4075
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4076 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4077 * Postscript tag functions
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4078 * Just look for lines where the first character is '/'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4079 * Richard Mlynarik <mly@adoc.xerox.com>
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4080 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4081 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4082 Postscript_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4083 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4084 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4085 register char *bp, *ep;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4086
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4087 LOOP_ON_INPUT_LINES (inf, lb, bp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4088 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4089 if (bp[0] == '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4090 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4091 for (ep = bp+1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4092 *ep != '\0' && *ep != ' ' && *ep != '{';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4093 ep++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4094 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4095 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4096 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4097 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4098 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4099 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4100
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4101
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4102 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4103 * Scheme tag functions
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4104 * look for (def... xyzzy
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4105 * look for (def... (xyzzy
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4106 * look for (def ... ((...(xyzzy ....
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4107 * look for (set! xyzzy
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4108 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4109
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4110 void get_scheme PP ((void));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4111
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4112 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4113 Scheme_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4114 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4115 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4116 LOOP_ON_INPUT_LINES (inf, lb, dbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4117 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4118 if (dbp[0] == '('
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4119 && (dbp[1] == 'D' || dbp[1] == 'd')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4120 && (dbp[2] == 'E' || dbp[2] == 'e')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4121 && (dbp[3] == 'F' || dbp[3] == 'f'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4122 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4123 dbp = skip_non_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4124 /* Skip over open parens and white space */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4125 while (isspace (*dbp) || *dbp == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4126 dbp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4127 get_scheme ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4128 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4129 if (dbp[0] == '('
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4130 && (dbp[1] == 'S' || dbp[1] == 's')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4131 && (dbp[2] == 'E' || dbp[2] == 'e')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4132 && (dbp[3] == 'T' || dbp[3] == 't')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4133 && (dbp[4] == '!' || dbp[4] == '!')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4134 && (isspace (dbp[5])))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4135 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4136 dbp = skip_non_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4137 dbp = skip_spaces (dbp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4138 get_scheme ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4139 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4140 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4141 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4142
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4143 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4144 get_scheme ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4145 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4146 register char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4147
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4148 if (*dbp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4149 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4150 /* Go till you get to white space or a syntactic break */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4151 for (cp = dbp + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4152 *cp != '\0' && *cp != '(' && *cp != ')' && !isspace (*cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4153 cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4154 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4155 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4156 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4157 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4158
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4159 /* Find tags in TeX and LaTeX input files. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4160
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4161 /* TEX_toktab is a table of TeX control sequences that define tags.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4162 Each TEX_tabent records one such control sequence.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4163 CONVERT THIS TO USE THE Stab TYPE!! */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4164 struct TEX_tabent
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4165 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4166 char *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4167 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4168 };
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4169
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4170 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4171
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4172 /* Default set of control sequences to put into TEX_toktab.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4173 The value of environment var TEXTAGS is prepended to this. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4174
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4175 char *TEX_defenv = "\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4176 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4177 :part:appendix:entry:index";
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4178
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4179 void TEX_mode PP ((FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4180 struct TEX_tabent *TEX_decode_env PP ((char *evarname, char *defenv));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4181 int TEX_Token PP ((char *cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4182
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4183 char TEX_esc = '\\';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4184 char TEX_opgrp = '{';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4185 char TEX_clgrp = '}';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4186
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4187 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4188 * TeX/LaTeX scanning loop.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4189 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4190 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4191 TeX_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4192 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4193 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4194 char *cp, *lasthit;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4195 register int i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4196
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4197 /* Select either \ or ! as escape character. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4198 TEX_mode (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4199
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4200 /* Initialize token table once from environment. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4201 if (!TEX_toktab)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4202 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4203
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4204 LOOP_ON_INPUT_LINES (inf, lb, cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4205 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4206 lasthit = cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4207 /* Look at each esc in line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4208 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4209 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4210 if (*++cp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4211 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4212 linecharno += cp - lasthit;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4213 lasthit = cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4214 i = TEX_Token (lasthit);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4215 if (i >= 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4216 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4217 /* We seem to include the TeX command in the tag name.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4218 register char *p;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4219 for (p = lasthit + TEX_toktab[i].len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4220 *p != '\0' && *p != TEX_clgrp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4221 p++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4222 continue; */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4223 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4224 lb.buffer, lb.len, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4225 break; /* We only tag a line once */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4226 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4227 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4228 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4229 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4230
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4231 #define TEX_LESC '\\'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4232 #define TEX_SESC '!'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4233 #define TEX_cmt '%'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4234
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4235 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4236 chars accordingly. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4237 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4238 TEX_mode (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4239 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4240 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4241 int c;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4242
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4243 while ((c = getc (inf)) != EOF)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4244 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4245 /* Skip to next line if we hit the TeX comment char. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4246 if (c == TEX_cmt)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4247 while (c != '\n')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4248 c = getc (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4249 else if (c == TEX_LESC || c == TEX_SESC )
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4250 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4251 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4252
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4253 if (c == TEX_LESC)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4254 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4255 TEX_esc = TEX_LESC;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4256 TEX_opgrp = '{';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4257 TEX_clgrp = '}';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4258 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4259 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4260 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4261 TEX_esc = TEX_SESC;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4262 TEX_opgrp = '<';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4263 TEX_clgrp = '>';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4264 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4265 rewind (inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4266 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4267
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4268 /* Read environment and prepend it to the default string.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4269 Build token table. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4270 struct TEX_tabent *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4271 TEX_decode_env (evarname, defenv)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4272 char *evarname;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4273 char *defenv;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4274 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4275 register char *env, *p;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4276
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4277 struct TEX_tabent *tab;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4278 int size, i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4279
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4280 /* Append default string to environment. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4281 env = getenv (evarname);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4282 if (!env)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4283 env = defenv;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4284 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4285 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4286 char *oldenv = env;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4287 env = concat (oldenv, defenv, "");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4288 free (oldenv);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4289 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4290
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4291 /* Allocate a token table */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4292 for (size = 1, p = env; p;)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4293 if ((p = etags_strchr (p, ':')) && *++p != '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4294 size++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4295 /* Add 1 to leave room for null terminator. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4296 tab = xnew (size + 1, struct TEX_tabent);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4297
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4298 /* Unpack environment string into token table. Be careful about */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4299 /* zero-length strings (leading ':', "::" and trailing ':') */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4300 for (i = 0; *env;)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4301 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4302 p = etags_strchr (env, ':');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4303 if (!p) /* End of environment string. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4304 p = env + strlen (env);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4305 if (p - env > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4306 { /* Only non-zero strings. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4307 tab[i].name = savenstr (env, p - env);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4308 tab[i].len = strlen (tab[i].name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4309 i++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4310 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4311 if (*p)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4312 env = p + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4313 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4314 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4315 tab[i].name = NULL; /* Mark end of table. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4316 tab[i].len = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4317 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4318 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4319 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4320 return tab;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4321 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4322
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4323 /* If the text at CP matches one of the tag-defining TeX command names,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4324 return the pointer to the first occurrence of that command in TEX_toktab.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4325 Otherwise return -1.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4326 Keep the capital `T' in `token' for dumb truncating compilers
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4327 (this distinguishes it from `TEX_toktab' */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4328 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4329 TEX_Token (cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4330 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4331 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4332 int i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4333
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4334 for (i = 0; TEX_toktab[i].len > 0; i++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4335 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4336 return i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4337 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4338 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4339
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4340 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4341 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4342 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4343 * Assumes that the predicate starts at column 0.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4344 * Only the first clause of a predicate is added.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4345 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4346 int prolog_pred PP ((char *s, char *last));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4347 void prolog_skip_comment PP ((linebuffer *plb, FILE *inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4348 int prolog_atom PP ((char *s, int pos));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4349
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4350 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4351 Prolog_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4352 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4353 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4354 char *cp, *last;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4355 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4356 int allocated;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4357
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4358 allocated = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4359 len = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4360 last = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4361
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4362 LOOP_ON_INPUT_LINES (inf, lb, cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4363 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4364 if (cp[0] == '\0') /* Empty line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4365 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4366 else if (isspace (cp[0])) /* Not a predicate */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4367 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4368 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4369 prolog_skip_comment (&lb, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4370 else if ((len = prolog_pred (cp, last)) > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4371 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4372 /* Predicate. Store the function name so that we only
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4373 generate a tag for the first clause. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4374 if (last == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4375 last = xnew(len + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4376 else if (len + 1 > allocated)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4377 last = xrnew (last, len + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4378 allocated = len + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4379 strncpy (last, cp, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4380 last[len] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4381 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4382 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4383 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4384
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4385
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4386 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4387 prolog_skip_comment (plb, inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4388 linebuffer *plb;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4389 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4390 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4391 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4392
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4393 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4394 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4395 for (cp = plb->buffer; *cp != '\0'; cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4396 if (cp[0] == '*' && cp[1] == '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4397 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4398 lineno++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4399 linecharno += readline (plb, inf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4400 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4401 while (!feof(inf));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4402 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4403
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4404 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4405 * A predicate definition is added if it matches:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4406 * <beginning of line><Prolog Atom><whitespace>(
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4407 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4408 * It is added to the tags database if it doesn't match the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4409 * name of the previous clause header.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4410 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4411 * Return the size of the name of the predicate, or 0 if no header
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4412 * was found.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4413 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4414 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4415 prolog_pred (s, last)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4416 char *s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4417 char *last; /* Name of last clause. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4418 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4419 int pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4420 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4421
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4422 pos = prolog_atom (s, 0);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4423 if (pos < 1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4424 return 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4425
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4426 len = pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4427 pos = skip_spaces (s + pos) - s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4428
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4429 if ((s[pos] == '(') || (s[pos] == '.'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4430 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4431 if (s[pos] == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4432 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4433
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4434 /* Save only the first clause. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4435 if (last == NULL
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4436 || len != strlen (last)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4437 || !strneq (s, last, len))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4438 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4439 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4440 s, pos, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4441 return len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4442 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4443 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4444 return 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4445 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4446
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4447 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4448 * Consume a Prolog atom.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4449 * Return the number of bytes consumed, or -1 if there was an error.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4450 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4451 * A prolog atom, in this context, could be one of:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4452 * - An alphanumeric sequence, starting with a lower case letter.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4453 * - A quoted arbitrary string. Single quotes can escape themselves.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4454 * Backslash quotes everything.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4455 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4456 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4457 prolog_atom (s, pos)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4458 char *s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4459 int pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4460 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4461 int origpos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4462
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4463 origpos = pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4464
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4465 if (islower(s[pos]) || (s[pos] == '_'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4466 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4467 /* The atom is unquoted. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4468 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4469 while (isalnum(s[pos]) || (s[pos] == '_'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4470 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4471 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4472 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4473 return pos - origpos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4474 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4475 else if (s[pos] == '\'')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4476 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4477 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4478
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4479 while (1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4480 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4481 if (s[pos] == '\'')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4482 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4483 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4484 if (s[pos] != '\'')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4485 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4486 pos++; /* A double quote */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4487 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4488 else if (s[pos] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4489 /* Multiline quoted atoms are ignored. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4490 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4491 else if (s[pos] == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4492 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4493 if (s[pos+1] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4494 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4495 pos += 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4496 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4497 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4498 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4499 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4500 return pos - origpos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4501 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4502 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4503 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4504 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4505
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4506 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4507 * Support for Erlang -- Anders Lindgren, Feb 1996.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4508 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4509 * Generates tags for functions, defines, and records.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4510 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4511 * Assumes that Erlang functions start at column 0.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4512 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4513 int erlang_func PP ((char *s, char *last));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4514 void erlang_attribute PP ((char *s));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4515 int erlang_atom PP ((char *s, int pos));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4516
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4517 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4518 Erlang_functions (inf)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4519 FILE *inf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4520 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4521 char *cp, *last;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4522 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4523 int allocated;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4524
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4525 allocated = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4526 len = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4527 last = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4528
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4529 LOOP_ON_INPUT_LINES (inf, lb, cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4530 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4531 if (cp[0] == '\0') /* Empty line */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4532 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4533 else if (isspace (cp[0])) /* Not function nor attribute */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4534 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4535 else if (cp[0] == '%') /* comment */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4536 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4537 else if (cp[0] == '"') /* Sometimes, strings start in column one */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4538 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4539 else if (cp[0] == '-') /* attribute, e.g. "-define" */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4540 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4541 erlang_attribute (cp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4542 last = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4543 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4544 else if ((len = erlang_func (cp, last)) > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4545 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4546 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4547 * Function. Store the function name so that we only
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4548 * generates a tag for the first clause.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4549 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4550 if (last == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4551 last = xnew (len + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4552 else if (len + 1 > allocated)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4553 last = xrnew (last, len + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4554 allocated = len + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4555 strncpy (last, cp, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4556 last[len] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4557 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4558 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4559 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4560
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4561
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4562 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4563 * A function definition is added if it matches:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4564 * <beginning of line><Erlang Atom><whitespace>(
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4565 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4566 * It is added to the tags database if it doesn't match the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4567 * name of the previous clause header.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4568 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4569 * Return the size of the name of the function, or 0 if no function
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4570 * was found.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4571 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4572 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4573 erlang_func (s, last)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4574 char *s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4575 char *last; /* Name of last clause. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4576 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4577 int pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4578 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4579
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4580 pos = erlang_atom (s, 0);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4581 if (pos < 1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4582 return 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4583
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4584 len = pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4585 pos = skip_spaces (s + pos) - s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4586
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4587 /* Save only the first clause. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4588 if (s[pos++] == '('
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4589 && (last == NULL
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4590 || len != strlen (last)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4591 || !strneq (s, last, len)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4592 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4593 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4594 s, pos, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4595 return len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4596 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4597
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4598 return 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4599 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4600
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4601
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4602 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4603 * Handle attributes. Currently, tags are generated for defines
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4604 * and records.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4605 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4606 * They are on the form:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4607 * -define(foo, bar).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4608 * -define(Foo(M, N), M+N).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4609 * -record(graph, {vtab = notable, cyclic = true}).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4610 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4611 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4612 erlang_attribute (s)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4613 char *s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4614 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4615 int pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4616 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4617
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4618 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4619 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4620 pos = skip_spaces (s + 7) - s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4621 if (s[pos++] == '(')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4622 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4623 pos = skip_spaces (s + pos) - s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4624 len = erlang_atom (s, pos);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4625 if (len != 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4626 pfnote ((CTAGS) ? savenstr (& s[pos], len) : NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4627 s, pos + len, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4628 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4629 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4630 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4631 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4632
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4633
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4634 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4635 * Consume an Erlang atom (or variable).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4636 * Return the number of bytes consumed, or -1 if there was an error.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4637 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4638 int
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4639 erlang_atom (s, pos)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4640 char *s;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4641 int pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4642 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4643 int origpos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4644
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4645 origpos = pos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4646
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4647 if (isalpha (s[pos]) || s[pos] == '_')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4648 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4649 /* The atom is unquoted. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4650 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4651 while (isalnum (s[pos]) || s[pos] == '_')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4652 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4653 return pos - origpos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4654 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4655 else if (s[pos] == '\'')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4656 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4657 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4658
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4659 while (1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4660 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4661 if (s[pos] == '\'')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4662 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4663 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4664 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4665 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4666 else if (s[pos] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4667 /* Multiline quoted atoms are ignored. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4668 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4669 else if (s[pos] == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4670 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4671 if (s[pos+1] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4672 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4673 pos += 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4674 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4675 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4676 pos++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4677 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4678 return pos - origpos;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4679 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4680 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4681 return -1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4682 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4683
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4684 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4685
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4686 /* Take a string like "/blah/" and turn it into "blah", making sure
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4687 that the first and last characters are the same, and handling
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4688 quoted separator characters. Actually, stops on the occurrence of
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4689 an unquoted separator. Also turns "\t" into a Tab character.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4690 Returns pointer to terminating separator. Works in place. Null
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4691 terminates name string. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4692 char * scan_separators PP ((char *name));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4693 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4694 scan_separators (name)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4695 char *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4696 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4697 char sep = name[0];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4698 char *copyto = name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4699 bool quoted = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4700
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4701 for (++name; *name != '\0'; ++name)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4702 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4703 if (quoted)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4704 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4705 if (*name == 't')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4706 *copyto++ = '\t';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4707 else if (*name == sep)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4708 *copyto++ = sep;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4709 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4710 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4711 /* Something else is quoted, so preserve the quote. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4712 *copyto++ = '\\';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4713 *copyto++ = *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4714 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4715 quoted = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4716 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4717 else if (*name == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4718 quoted = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4719 else if (*name == sep)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4720 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4721 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4722 *copyto++ = *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4723 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4724
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4725 /* Terminate copied string. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4726 *copyto = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4727 return name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4728 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4729
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4730 /* Look at the argument of --regex or --no-regex and do the right
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4731 thing. Same for each line of a regexp file. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4732 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4733 analyse_regex (regex_arg)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4734 char *regex_arg;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4735 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4736 if (regex_arg == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4737 free_patterns (); /* --no-regex: remove existing regexps */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4738
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4739 /* A real --regexp option or a line in a regexp file. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4740 switch (regex_arg[0])
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4741 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4742 /* Comments in regexp file or null arg to --regex. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4743 case '\0':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4744 case ' ':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4745 case '\t':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4746 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4747
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4748 /* Read a regex file. This is recursive and may result in a
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4749 loop, which will stop when the file descriptors are exhausted. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4750 case '@':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4751 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4752 FILE *regexfp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4753 linebuffer regexbuf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4754 char *regexfile = regex_arg + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4755
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4756 /* regexfile is a file containing regexps, one per line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4757 regexfp = fopen (regexfile, "r");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4758 if (regexfp == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4759 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4760 pfatal (regexfile);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4761 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4762 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4763 initbuffer (&regexbuf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4764 while (readline_internal (&regexbuf, regexfp) > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4765 analyse_regex (regexbuf.buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4766 free (regexbuf.buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4767 fclose (regexfp);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4768 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4769 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4770
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4771 /* Regexp to be used for a specific language only. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4772 case '{':
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4773 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4774 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4775 char *lang_name = regex_arg + 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4776 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4777
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4778 for (cp = lang_name; *cp != '}'; cp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4779 if (*cp == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4780 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4781 error ("unterminated language name in regex: %s", regex_arg);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4782 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4783 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4784 *cp = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4785 lang = get_language_from_name (lang_name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4786 if (lang == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4787 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4788 add_regex (cp + 1, lang);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4789 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4790 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4791
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4792 /* Regexp to be used for any language. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4793 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4794 add_regex (regex_arg, NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4795 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4796 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4797 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4798
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4799 /* Turn a name, which is an ed-style (but Emacs syntax) regular
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4800 expression, into a real regular expression by compiling it. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4801 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4802 add_regex (regexp_pattern, lang)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4803 char *regexp_pattern;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4804 language *lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4805 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4806 char *name;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4807 const char *err;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4808 struct re_pattern_buffer *patbuf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4809 pattern *pp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4810
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4811
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4812 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4813 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4814 error ("%s: unterminated regexp", regexp_pattern);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4815 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4816 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4817 name = scan_separators (regexp_pattern);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4818 if (regexp_pattern[0] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4819 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4820 error ("null regexp", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4821 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4822 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4823 (void) scan_separators (name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4824
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4825 patbuf = xnew (1, struct re_pattern_buffer);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4826 patbuf->translate = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4827 patbuf->fastmap = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4828 patbuf->buffer = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4829 patbuf->allocated = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4830
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4831 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4832 if (err != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4833 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4834 error ("%s while compiling pattern", err);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4835 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4836 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4837
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4838 pp = p_head;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4839 p_head = xnew (1, pattern);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4840 p_head->regex = savestr (regexp_pattern);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4841 p_head->p_next = pp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4842 p_head->language = lang;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4843 p_head->pattern = patbuf;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4844 p_head->name_pattern = savestr (name);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4845 p_head->error_signaled = FALSE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4846 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4847
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4848 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4849 * Do the substitutions indicated by the regular expression and
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4850 * arguments.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4851 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4852 char * substitute PP ((char *in, char *out, struct re_registers *regs));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4853 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4854 substitute (in, out, regs)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4855 char *in, *out;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4856 struct re_registers *regs;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4857 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4858 char *result, *t;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4859 int size, dig, diglen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4860
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4861 result = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4862 size = strlen (out);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4863
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4864 /* Pass 1: figure out how much to allocate by finding all \N strings. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4865 if (out[size - 1] == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4866 fatal ("pattern error in \"%s\"", out);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4867 for (t = etags_strchr (out, '\\');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4868 t != NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4869 t = etags_strchr (t + 2, '\\'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4870 if (isdigit (t[1]))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4871 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4872 dig = t[1] - '0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4873 diglen = regs->end[dig] - regs->start[dig];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4874 size += diglen - 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4875 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4876 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4877 size -= 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4878
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4879 /* Allocate space and do the substitutions. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4880 result = xnew (size + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4881
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4882 for (t = result; *out != '\0'; out++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4883 if (*out == '\\' && isdigit (*++out))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4884 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4885 /* Using "dig2" satisfies my debugger. Bleah. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4886 dig = *out - '0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4887 diglen = regs->end[dig] - regs->start[dig];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4888 strncpy (t, in + regs->start[dig], diglen);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4889 t += diglen;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4890 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4891 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4892 *t++ = *out;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4893 *t = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4894
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4895 if (DEBUG && (t > result + size || t - result != strlen (result)))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4896 abort ();
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4897
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4898 return result;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4899 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4900
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4901 /* Deallocate all patterns. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4902 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4903 free_patterns ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4904 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4905 pattern *pp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4906 while (p_head != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4907 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4908 pp = p_head->p_next;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4909 free (p_head->regex);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4910 free (p_head->name_pattern);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4911 free (p_head);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4912 p_head = pp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4913 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4914 return;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4915 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4916
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4917 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4918 /* Initialize a linebuffer for use */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4919 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4920 initbuffer (lbp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4921 linebuffer *lbp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4922 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4923 lbp->size = 200;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4924 lbp->buffer = xnew (200, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4925 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4926
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4927 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4928 * Read a line of text from `stream' into `lbp', excluding the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4929 * newline or CR-NL, if any. Return the number of characters read from
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4930 * `stream', which is the length of the line including the newline.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4931 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4932 * On DOS or Windows we do not count the CR character, if any, before the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4933 * NL, in the returned length; this mirrors the behavior of emacs on those
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4934 * platforms (for text files, it translates CR-NL to NL as it reads in the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4935 * file).
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4936 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4937 long
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4938 readline_internal (lbp, stream)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4939 linebuffer *lbp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4940 register FILE *stream;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4941 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4942 char *buffer = lbp->buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4943 register char *p = lbp->buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4944 register char *pend;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4945 int chars_deleted;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4946
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4947 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4948
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4949 while (1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4950 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4951 register int c = getc (stream);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4952 if (p == pend)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4953 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4954 /* We're at the end of linebuffer: expand it. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4955 lbp->size *= 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4956 buffer = xrnew (buffer, lbp->size, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4957 p += buffer - lbp->buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4958 pend = buffer + lbp->size;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4959 lbp->buffer = buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4960 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4961 if (c == EOF)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4962 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4963 *p = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4964 chars_deleted = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4965 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4966 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4967 if (c == '\n')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4968 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4969 if (p > buffer && p[-1] == '\r')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4970 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4971 p -= 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4972 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4973 /* Assume CRLF->LF translation will be performed by Emacs
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4974 when loading this file, so CRs won't appear in the buffer.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4975 It would be cleaner to compensate within Emacs;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4976 however, Emacs does not know how many CRs were deleted
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4977 before any given point in the file. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4978 chars_deleted = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4979 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4980 chars_deleted = 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4981 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4982 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4983 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4984 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4985 chars_deleted = 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4986 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4987 *p = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4988 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4989 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4990 *p++ = c;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4991 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4992 lbp->len = p - buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4993
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4994 return lbp->len + chars_deleted;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4995 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4996
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4997 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4998 * Like readline_internal, above, but in addition try to match the
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
4999 * input line against relevant regular expressions.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5000 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5001 long
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5002 readline (lbp, stream)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5003 linebuffer *lbp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5004 FILE *stream;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5005 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5006 /* Read new line. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5007 long result = readline_internal (lbp, stream);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5008 #ifdef ETAGS_REGEXPS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5009 int match;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5010 pattern *pp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5011
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5012 /* Match against relevant patterns. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5013 if (lbp->len > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5014 for (pp = p_head; pp != NULL; pp = pp->p_next)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5015 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5016 /* Only use generic regexps or those for the current language. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5017 if (pp->language != NULL && pp->language != curlang)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5018 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5019
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5020 match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5021 switch (match)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5022 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5023 case -2:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5024 /* Some error. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5025 if (!pp->error_signaled)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5026 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5027 error ("error while matching \"%s\"", pp->regex);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5028 pp->error_signaled = TRUE;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5029 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5030 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5031 case -1:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5032 /* No match. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5033 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5034 default:
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5035 /* Match occurred. Construct a tag. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5036 if (pp->name_pattern[0] != '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5037 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5038 /* Make a named tag. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5039 char *name = substitute (lbp->buffer,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5040 pp->name_pattern, &pp->regs);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5041 if (name != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5042 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5043 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5044 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5045 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5046 /* Make an unnamed tag. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5047 pfnote ((char *)NULL, TRUE,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5048 lbp->buffer, match, lineno, linecharno);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5049 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5050 break;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5051 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5052 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5053 #endif /* ETAGS_REGEXPS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5054
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5055 return result;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5056 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5057
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5058 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5059 * Return a pointer to a space of size strlen(cp)+1 allocated
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5060 * with xnew where the string CP has been copied.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5061 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5062 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5063 savestr (cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5064 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5065 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5066 return savenstr (cp, strlen (cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5067 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5068
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5069 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5070 * Return a pointer to a space of size LEN+1 allocated with xnew where
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5071 * the string CP has been copied for at most the first LEN characters.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5072 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5073 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5074 savenstr (cp, len)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5075 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5076 int len;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5077 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5078 register char *dp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5079
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5080 dp = xnew (len + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5081 strncpy (dp, cp, len);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5082 dp[len] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5083 return dp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5084 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5085
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5086 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5087 * Return the ptr in sp at which the character c last
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5088 * appears; NULL if not found
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5089 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5090 * Identical to System V strrchr, included for portability.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5091 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5092 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5093 etags_strrchr (sp, c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5094 register char *sp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5095 register int c;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5096 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5097 register char *r;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5098
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5099 r = NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5100 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5101 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5102 if (*sp == c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5103 r = sp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5104 } while (*sp++);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5105 return r;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5106 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5107
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5108
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5109 /*
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5110 * Return the ptr in sp at which the character c first
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5111 * appears; NULL if not found
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5112 *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5113 * Identical to System V strchr, included for portability.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5114 */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5115 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5116 etags_strchr (sp, c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5117 register char *sp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5118 register int c;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5119 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5120 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5121 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5122 if (*sp == c)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5123 return sp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5124 } while (*sp++);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5125 return NULL;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5126 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5127
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5128 /* Skip spaces, return new pointer. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5129 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5130 skip_spaces (cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5131 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5132 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5133 while (isspace (*cp)) /* isspace('\0')==FALSE */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5134 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5135 return cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5136 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5137
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5138 /* Skip non spaces, return new pointer. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5139 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5140 skip_non_spaces (cp)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5141 char *cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5142 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5143 while (!iswhite (*cp)) /* iswhite('\0')==TRUE */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5144 cp++;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5145 return cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5146 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5147
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5148 /* Print error message and exit. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5149 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5150 fatal (s1, s2)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5151 char *s1, *s2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5152 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5153 error (s1, s2);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5154 exit (BAD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5155 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5156
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5157 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5158 pfatal (s1)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5159 char *s1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5160 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5161 perror (s1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5162 exit (BAD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5163 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5164
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5165 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5166 suggest_asking_for_help ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5167 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5168 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5169 progname,
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5170 #ifdef LONG_OPTIONS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5171 "--help"
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5172 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5173 "-h"
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5174 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5175 );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5176 exit (BAD);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5177 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5178
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5179 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5180 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5181 error (s1, s2)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5182 const char *s1, *s2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5183 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5184 fprintf (stderr, "%s: ", progname);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5185 fprintf (stderr, s1, s2);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5186 fprintf (stderr, "\n");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5187 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5188
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5189 /* Return a newly-allocated string whose contents
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5190 concatenate those of s1, s2, s3. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5191 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5192 concat (s1, s2, s3)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5193 char *s1, *s2, *s3;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5194 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5195 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5196 char *result = xnew (len1 + len2 + len3 + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5197
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5198 strcpy (result, s1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5199 strcpy (result + len1, s2);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5200 strcpy (result + len1 + len2, s3);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5201 result[len1 + len2 + len3] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5202
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5203 return result;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5204 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5205
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5206 /* Does the same work as the system V getcwd, but does not need to
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5207 guess the buffer size in advance. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5208 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5209 etags_getcwd ()
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5210 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5211 #ifdef HAVE_GETCWD
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5212 int bufsize = 200;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5213 char *path = xnew (bufsize, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5214
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5215 while (getcwd (path, bufsize) == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5216 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5217 if (errno != ERANGE)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5218 pfatal ("getcwd");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5219 bufsize *= 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5220 free (path);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5221 path = xnew (bufsize, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5222 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5223
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5224 canonicalize_filename (path);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5225 return path;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5226
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5227 #else /* not HAVE_GETCWD */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5228 #ifdef MSDOS
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5229 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5230
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5231 getwd (path);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5232
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5233 for (p = path; *p != '\0'; p++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5234 if (*p == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5235 *p = '/';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5236 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5237 *p = lowcase (*p);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5238
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5239 return strdup (path);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5240 #else /* not MSDOS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5241 linebuffer path;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5242 FILE *pipe;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5243
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5244 initbuffer (&path);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5245 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5246 if (pipe == NULL || readline_internal (&path, pipe) == 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5247 pfatal ("pwd");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5248 pclose (pipe);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5249
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5250 return path.buffer;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5251 #endif /* not MSDOS */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5252 #endif /* not HAVE_GETCWD */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5253 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5254
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5255 /* Return a newly allocated string containing the file name of FILE
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5256 relative to the absolute directory DIR (which should end with a slash). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5257 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5258 relative_filename (file, dir)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5259 char *file, *dir;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5260 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5261 char *fp, *dp, *afn, *res;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5262 int i;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5263
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5264 /* Find the common root of file and dir (with a trailing slash). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5265 afn = absolute_filename (file, cwd);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5266 fp = afn;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5267 dp = dir;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5268 while (*fp++ == *dp++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5269 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5270 fp--, dp--; /* back to the first differing char */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5271 do /* look at the equal chars until '/' */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5272 fp--, dp--;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5273 while (*fp != '/');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5274
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5275 /* Build a sequence of "../" strings for the resulting relative file name. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5276 i = 0;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5277 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5278 i += 1;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5279 res = xnew (3*i + strlen (fp + 1) + 1, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5280 res[0] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5281 while (i-- > 0)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5282 strcat (res, "../");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5283
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5284 /* Add the file name relative to the common root of file and dir. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5285 strcat (res, fp + 1);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5286 free (afn);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5287
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5288 return res;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5289 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5290
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5291 /* Return a newly allocated string containing the absolute file name
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5292 of FILE given DIR (which should end with a slash). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5293 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5294 absolute_filename (file, dir)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5295 char *file, *dir;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5296 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5297 char *slashp, *cp, *res;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5298
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5299 if (filename_is_absolute (file))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5300 res = savestr (file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5301 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5302 /* We don't support non-absolute file names with a drive
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5303 letter, like `d:NAME' (it's too much hassle). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5304 else if (file[1] == ':')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5305 fatal ("%s: relative file names with drive letters not supported", file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5306 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5307 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5308 res = concat (dir, file, "");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5309
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5310 /* Delete the "/dirname/.." and "/." substrings. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5311 slashp = etags_strchr (res, '/');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5312 while (slashp != NULL && slashp[0] != '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5313 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5314 if (slashp[1] == '.')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5315 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5316 if (slashp[2] == '.'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5317 && (slashp[3] == '/' || slashp[3] == '\0'))
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5318 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5319 cp = slashp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5320 do
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5321 cp--;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5322 while (cp >= res && !filename_is_absolute (cp));
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5323 if (cp < res)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5324 cp = slashp; /* the absolute name begins with "/.." */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5325 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5326 /* Under MSDOS and NT we get `d:/NAME' as absolute
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5327 file name, so the luser could say `d:/../NAME'.
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5328 We silently treat this as `d:/NAME'. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5329 else if (cp[0] != '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5330 cp = slashp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5331 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5332 strcpy (cp, slashp + 3);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5333 slashp = cp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5334 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5335 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5336 else if (slashp[2] == '/' || slashp[2] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5337 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5338 strcpy (slashp, slashp + 2);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5339 continue;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5340 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5341 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5342
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5343 slashp = etags_strchr (slashp + 1, '/');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5344 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5345
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5346 if (res[0] == '\0')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5347 return savestr ("/");
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5348 else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5349 return res;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5350 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5351
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5352 /* Return a newly allocated string containing the absolute
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5353 file name of dir where FILE resides given DIR (which should
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5354 end with a slash). */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5355 char *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5356 absolute_dirname (file, dir)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5357 char *file, *dir;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5358 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5359 char *slashp, *res;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5360 char save;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5361
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5362 canonicalize_filename (file);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5363 slashp = etags_strrchr (file, '/');
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5364 if (slashp == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5365 return savestr (dir);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5366 save = slashp[1];
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5367 slashp[1] = '\0';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5368 res = absolute_filename (file, dir);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5369 slashp[1] = save;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5370
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5371 return res;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5372 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5373
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5374 /* Whether the argument string is an absolute file name. The argument
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5375 string must have been canonicalized with canonicalize_filename. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5376 bool
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5377 filename_is_absolute (fn)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5378 char *fn;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5379 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5380 return (fn[0] == '/'
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5381 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5382 || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5383 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5384 );
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5385 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5386
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5387 /* Translate backslashes into slashes. Works in place. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5388 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5389 canonicalize_filename (fn)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5390 register char *fn;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5391 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5392 #ifdef DOS_NT
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5393 for (; *fn != '\0'; fn++)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5394 if (*fn == '\\')
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5395 *fn = '/';
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5396 #else
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5397 /* No action. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5398 #endif
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5399 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5400
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5401 /* Increase the size of a linebuffer. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5402 void
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5403 grow_linebuffer (lbp, toksize)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5404 linebuffer *lbp;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5405 int toksize;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5406 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5407 while (lbp->size < toksize)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5408 lbp->size *= 2;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5409 lbp->buffer = xrnew (lbp->buffer, lbp->size, char);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5410 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5411
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5412 /* Like malloc but get fatal error if memory is exhausted. */
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5413 long *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5414 xmalloc (size)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5415 unsigned int size;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5416 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5417 long *result = (long *) malloc (size);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5418 if (result == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5419 fatal ("virtual memory exhausted", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5420 return result;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5421 }
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5422
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5423 long *
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5424 xrealloc (ptr, size)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5425 char *ptr;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5426 unsigned int size;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5427 {
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5428 long *result = (long *) realloc (ptr, size);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5429 if (result == NULL)
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5430 fatal ("virtual memory exhausted", (char *)NULL);
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5431 return result;
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents:
diff changeset
5432 }