annotate lib-src/ootags.c @ 5935:d5eb0914ca1f cygwin

trial of E1 and UE1
author Henry Thompson <ht@markup.co.uk>
date Sat, 12 Dec 2015 21:49:31 +0000
parents b3824b7f5627
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Tags file maker to go with GNU Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Free Software Foundation, Inc. and Ken Arnold
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is not considered part of GNU Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
7 This program is free software: you can redistribute it and/or modify it
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
8 under the terms of the GNU General Public License as published by the
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
9 Free Software Foundation, either version 3 of the License, or (at your
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
10 option) any later version.
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
11
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
12 This program is distributed in the hope that it will be useful, but WITHOUT
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
15 for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
5406
061f4f90f874 Convert lib-src/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents: 4932
diff changeset
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 * Authors:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 * Ctags originally by Ken Arnold.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 * Fortran added by Jim Kleckner.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * Ed Pelegri-Llopart added C typedefs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 * Gnu Emacs TAGS format and modifications by RMS?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Sam Kendall added C++.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * Francesco Potorti` reorganised C and C++ based on work by Joe Wells.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 * Regexp tags by Tom Tromey.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 char pot_etags_version[] = "@(#) pot revision number is 12.28";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 /* Prototyping magic snarfed from gmalloc.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 #if defined (__cplusplus) || defined (__STDC__)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #undef PP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #define PP(args) args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #undef __ptr_t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #define __ptr_t void *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #else /* Not C++ or ANSI C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #undef PP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #define PP(args) ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #undef const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #define const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #undef __ptr_t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #define __ptr_t char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #endif /* C++ or ANSI C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 # include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 /* On some systems, Emacs defines static as nothing for the sake
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 of unexec. We don't want that here since we don't use unexec. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 # undef static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 # define ETAGS_REGEXPS /* use the regexp features */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 # define LONG_OPTIONS /* accept long options */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 #endif /* HAVE_CONFIG_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 #define TRUE 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #define FALSE 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 #ifndef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 # define DEBUG FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
66 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 # include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 # include <fcntl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 # include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 # include <io.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 # define MAXPATHLEN _MAX_PATH
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
72 # ifndef HAVE_CONFIG_H
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 # define HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 # endif /* not HAVE_CONFIG_H */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
75 #endif /* WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
76
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
77 #if !defined (WIN32_NATIVE) && defined (STDC_HEADERS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 # include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 # ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 extern char *getcwd ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 # endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 #endif /* HAVE_UNISTD_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #include <errno.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #include <sys/stat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 #if !defined (S_ISREG) && defined (S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 # include <getopt.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 extern char *optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 extern int optind, opterr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 # include <regex.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 /* Define CTAGS to make the program "ctags" compatible with the usual one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 Leave it undefined to make the program "etags", which makes emacs-style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 tag tables and tags typedefs, #defines and struct/union/enum by default. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 #ifdef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 # undef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 # define CTAGS TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 # define CTAGS FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 /* Exit codes for success and failure. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 # define GOOD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 # define BAD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 # define GOOD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 # define BAD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 /* C extensions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 #define C_PLPL 0x00001 /* C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 #define C_STAR 0x00003 /* C* */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 #define C_JAVA 0x00005 /* JAVA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 #define YACC 0x10000 /* yacc file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 #define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 && (abort (), 1)) || !strcmp (s, t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 && (abort (), 1)) || !strncmp (s, t, n))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 #define lowcase(c) tolower ((char)c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 #define CHARS 256 /* 2^sizeof(char) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 #define CHAR(x) ((unsigned int)x & (CHARS - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 /*#ifdef INFODOCK*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 /*#undef OO_BROWSER*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /* Due to the way this file is constructed, this unfortunately doesn't */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 /* work except for documentation purposes. -slb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 #define OO_BROWSER 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 /*#endif*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 #define set_construct(construct) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 if (!oo_browser_construct) oo_browser_construct = construct
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
162 void oo_browser_clear_all_globals(void);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
163 void oo_browser_clear_some_globals(void);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
164 void oo_browser_check_and_clear_structtype(void);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 * xnew, xrnew -- allocate, reallocate storage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 * SYNOPSIS: Type *xnew (int n, Type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 * Type *xrnew (OldPointer, int n, Type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 #ifdef chkmalloc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 # include "chkmalloc.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 # define xrnew(op,n,Type) ((Type *) trace_realloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (op), (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 typedef int bool;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
186 typedef void Lang_function (FILE *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 Lang_function *function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 char **suffixes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 char **interpreters;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 } language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 typedef struct node_st
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 { /* sorting structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 char *name; /* function or type name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 short int construct; /* Construct type for the OO-Browser */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 char *file; /* file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 bool is_func; /* use pattern or line no */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 bool been_warned; /* set if noticed dup */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 int lno; /* line number tag is on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 long cno; /* character number line starts on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 char *pat; /* search pattern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 struct node_st *left, *right; /* left and right sons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 } node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 /* If you add to this array, you must add a corresponding entry to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 following enum. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 static char *oo_browser_default_classes[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 /* Lack of square brackets around some of these entries are intentional. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 {"null", "class", "method", "[constant]", "[enumeration]", "[enum_label]",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 "extern", "[function]", "[macro]", "objc", "[structure]", "[type]",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 "[union]", "[variable]"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 /* If you add to this enum, you must add a corresponding entry to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 preceding array. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 enum oo_browser_constructs {C_NULL, C_CLASS, C_METHOD, C_CONSTANT, C_ENUMERATION,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 C_ENUM_LABEL, C_EXTERN, C_FUNCTION, C_MACRO,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 C_OBJC, C_STRUCTURE, C_TYPE, C_UNION, C_VARIABLE};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 enum oo_browser_constructs oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 * A `linebuffer' is a structure which holds a line of text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 * `readline_internal' reads a line from a stream into a linebuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 * and works regardless of the length of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 * SIZE is the size of BUFFER, LEN is the length of the string in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 * BUFFER after readline reads it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 long size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 } linebuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 extern char *getenv PP ((const char *envvar));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 /* Many compilers barf on this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 Lang_function Asm_labels;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 so let's write it this way */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 void Asm_labels PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 void C_entries PP ((int c_ext, FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 void default_C_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 void plain_C_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 void Cjava_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 void Cplusplus_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 void Yacc_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 void Cobol_paragraphs PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 void Cstar_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 void Erlang_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 void Fortran_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 void Lisp_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 void Pascal_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 void Perl_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 void Postscript_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 void Prolog_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 void Python_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 void Scheme_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 void TeX_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 void just_read_file PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 void print_language_names PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 void print_version PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 void print_help PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273 language *get_language_from_name PP ((char *name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 language *get_language_from_interpreter PP ((char *interpreter));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 language *get_language_from_suffix PP ((char *suffix));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 int total_size_of_entries PP ((node *np));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 long readline PP ((linebuffer *lbp, FILE *stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 long readline_internal PP ((linebuffer *lbp, FILE *stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 void analyse_regex PP ((char *regex_arg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 void add_regex PP ((char *regexp_pattern, language *lang));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 void free_patterns PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 void error PP ((const char *s1, const char *s2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 void suggest_asking_for_help PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 void fatal PP ((char *s1, char *s2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 void pfatal PP ((char *s1));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 void add_node PP ((node *np, node **cur_node_p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 void init PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 void initbuffer PP ((linebuffer *lbp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 void find_entries PP ((char *file, FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 void free_tree PP ((node *np));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 void pfnote PP ((char *name, bool is_func, char *linestart, int linelen, int lno, long cno));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 void new_pfnote PP ((char *name, int namelen, bool is_func, char *linestart, int linelen, int lno, long cno));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 void process_file PP ((char *file));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 void put_entries PP ((node *np));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 void takeprec PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 char *concat PP ((char *s1, char *s2, char *s3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 char *skip_spaces PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 char *skip_non_spaces PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 char *savenstr PP ((char *cp, int len));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 char *savestr PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 char *etags_strchr PP ((char *sp, int c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 char *etags_strrchr PP ((char *sp, int c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 char *etags_getcwd PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 char *relative_filename PP ((char *file, char *dir));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 char *absolute_filename PP ((char *file, char *dir));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 char *absolute_dirname PP ((char *file, char *dir));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 bool filename_is_absolute PP ((char *fn));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 void canonicalize_filename PP ((char *fn));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 void grow_linebuffer PP ((linebuffer *lbp, int toksize));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 long *xmalloc PP ((unsigned int size));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 long *xrealloc PP ((char *ptr, unsigned int size));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 char searchar = '/'; /* use /.../ searches */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320 char *tagfile; /* output file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 char *progname; /* name this program was invoked with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 char *cwd; /* current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 char *tagfiledir; /* directory of tagfile */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 FILE *tagf; /* ioptr for tags file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 char *curfile; /* current input file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 language *curlang; /* current language */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 int lineno; /* line number of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 long charno; /* current character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 long linecharno; /* charno of start of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 char *dbp; /* pointer to start of current tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 node *head; /* the head of the binary tree of tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 linebuffer lb; /* the current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 linebuffer token_name; /* used by C_entries as a temporary area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 long linepos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 linebuffer lb; /* used by C_entries instead of lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 } lbs[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 /* boolean "functions" (see init) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 /* white chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 *white = " \f\t\n\r",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 /* not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 *nonam = " \f\t\n\r(=,[;",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 /* token ending chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 /* token starting chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 /* valid in-token chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 bool append_to_tagfile; /* -a: append to tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 /* The following four default to TRUE for etags, but to FALSE for ctags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 bool typedefs; /* -t: create tags for C typedefs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 /* 0 struct/enum/union decls, and C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* member functions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 bool constantypedefs; /* -d: create tags for C #define, enum */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 /* constants and variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* -D: opposite of -d. Default under ctags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 bool globals; /* create tags for global variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 bool members; /* create tags for C member variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 bool update; /* -u: update tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 bool vgrind_style; /* -v: create vgrind style index output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 bool no_warnings; /* -w: suppress warnings */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 bool cxref_style; /* -x: create cxref style output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 bool cplusplus; /* .[hc] means C++, not C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 bool noindentypedefs; /* -I: ignore indentation in C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 bool oo_browser_format; /* -O: OO-Browser tags format */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 struct option longopts[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 { "append", no_argument, NULL, 'a' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 { "backward-search", no_argument, NULL, 'B' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 { "c++", no_argument, NULL, 'C' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 { "cxref", no_argument, NULL, 'x' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 { "defines", no_argument, NULL, 'd' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 { "no-defines", no_argument, NULL, 'D' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 { "globals", no_argument, &globals, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 { "no-globals", no_argument, &globals, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 { "help", no_argument, NULL, 'h' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 { "help", no_argument, NULL, 'H' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 { "ignore-indentation", no_argument, NULL, 'I' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 { "include", required_argument, NULL, 'i' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 { "language", required_argument, NULL, 'l' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 { "members", no_argument, &members, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 { "no-members", no_argument, &members, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 { "no-warn", no_argument, NULL, 'w' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 { "output", required_argument, NULL, 'o' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 { "oo-browser", no_argument, NULL, 'O' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 { "regex", required_argument, NULL, 'r' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 { "no-regex", no_argument, NULL, 'R' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 { "typedefs", no_argument, NULL, 't' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 { "typedefs-and-c++", no_argument, NULL, 'T' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 { "update", no_argument, NULL, 'u' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 { "version", no_argument, NULL, 'V' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 { "vgrind", no_argument, NULL, 'v' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 { 0 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 /* Structure defining a regular expression. Elements are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 the compiled pattern, and the name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 typedef struct pattern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 struct pattern *p_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 language *language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 char *regex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 struct re_pattern_buffer *pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 struct re_registers regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 char *name_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 bool error_signaled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 } pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 /* Array of all regexps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 pattern *p_head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 * Language stuff.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 /* Non-NULL if language fixed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 language *forced_lang = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 /* Assembly code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 char *Asm_suffixes [] = { "a", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 "asm", /* Microcontroller assembly */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 "def", /* BSO/Tasking definition includes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 "inc", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 "ins", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 "s", "sa", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 "src", /* BSO/Tasking C compiler output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 /* Note that .c and .h can be considered C++, if the --c++ flag was
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 given. That is why default_C_entries is called here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 char *default_C_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 { "c", "h", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 char *Cplusplus_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 "M", /* Objective C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 "pdb", /* Postscript with C syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 char *Cjava_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 { "java", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 char *Cobol_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 { "COB", "cob", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 char *Cstar_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 { "cs", "hs", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470 char *Erlang_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 { "erl", "hrl", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 char *Fortran_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 { "F", "f", "f90", "for", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 char *Lisp_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 char *Pascal_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 { "p", "pas", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 char *Perl_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 { "pl", "pm", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 char *Perl_interpreters [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 { "perl", "@PERL@", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 char *plain_C_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 { "pc", /* Pro*C file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 "m", /* Objective C file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 "lm", /* Objective lex file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 char *Postscript_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 { "ps", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 char *Prolog_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 { "prolog", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 char *Python_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 { "py", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 /* Can't do the `SCM' or `scm' prefix with a version number. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 char *Scheme_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "ss", "t", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 char *TeX_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 { "TeX", "bib", "clo", "cls", "ltx", "sty", "tex", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 char *Yacc_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 { "y", "ym", NULL }; /* .ym is Objective yacc file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 * Table of languages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 * It is ok for a given function to be listed under more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 * name. I just didn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 language lang_names [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 { "asm", Asm_labels, Asm_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 { "c", default_C_entries, default_C_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 { "c*", Cstar_entries, Cstar_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 { "cobol", Cobol_paragraphs, Cobol_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 { "java", Cjava_entries, Cjava_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 { "proc", plain_C_entries, plain_C_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 { "python", Python_functions, Python_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 { "tex", TeX_functions, TeX_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 { "auto", NULL }, /* default guessing scheme */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 { "none", just_read_file }, /* regexp matching only */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 { NULL, NULL } /* end of list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 print_language_names ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 char **ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 puts ("\nThese are the currently supported languages, along with the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 default file name suffixes:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 printf ("\t%s\t", lang->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 printf (" .%s", *ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 puts ("Where `auto' means use default language for files based on file\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 name suffix, and `none' means only do regexp processing on files.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 If no language is specified and no matching suffix is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 the first line of the file is read for a sharp-bang (#!) sequence\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 followed by the name of an interpreter. If no such sequence is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 Fortran is tried first; if no tags are found, C is tried next.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 #ifndef VERSION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 # define VERSION "20"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 print_version ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 printf ("%s (GNU Emacs %s)\n", (CTAGS) ? "ctags" : "etags", VERSION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 puts ("Copyright (C) 1996 Free Software Foundation, Inc. and Ken Arnold");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 puts ("This program is distributed under the same terms as Emacs");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 print_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 These are the options accepted by %s.\n", progname, progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 puts ("You may use unambiguous abbreviations for the long option names.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 puts ("Long option names do not work with this executable, as it is not\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 linked with GNU getopt.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 puts ("A - as file name means read names from stdin (one per line).");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 printf (" Absolute names are stored in the output file as they are.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 Relative ones are stored relative to the output file's directory.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 puts ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 puts ("-a, --append\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 Append tag entries to existing tags file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 puts ("-B, --backward-search\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 Write the search commands for the tag entries using '?', the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 backward-search command instead of '/', the forward-search command.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 puts ("-C, --c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 Treat files whose name suffix defaults to C language as C++ files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 puts ("-d, --defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 Create tag entries for C #define constants and enum constants, too.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 puts ("-D, --no-defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 Don't create tag entries for C #define constants and enum constants.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 puts ("-i FILE, --include=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 Include a note in tag file indicating that, when searching for\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 a tag, one should also consult the tags file FILE after\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 checking the current file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 puts ("-l LANG, --language=LANG\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 Force the following files to be considered as written in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 named language up to the next --language=LANG option.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 puts ("--globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 Create tag entries for global variables in some languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 puts ("--no-globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 Do not create tag entries for global variables in some\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 languages. This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 puts ("--members\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 Create tag entries for member variables in C and derived languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 Make a tag for each line matching pattern REGEXP in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 following files. regexfile is a file containing one REGEXP\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 per line. REGEXP is anchored (as if preceded by ^).\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 named tags can be created with:\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 puts ("-R, --no-regex\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 Don't create tags from regexps for the following files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 puts ("-o FILE, --output=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 Write the tags to FILE.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 puts ("-O, --oo-browser\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 Generate a specialized tags format used only by the Altrasoft OO-Browser.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 puts ("-I, --ignore-indentation\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 Don't rely on indentation quite as much as normal. Currently,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 this means not to assume that a closing brace in the first\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 column is the final brace of a function or structure\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 definition in C and C++.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 puts ("-t, --typedefs\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 Generate tag entries for C typedefs.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 puts ("-T, --typedefs-and-c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 and C++ member functions.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 puts ("-u, --update\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 Update the tag entries for the given files, leaving tag\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 entries for other files in place. Currently, this is\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 implemented by deleting the existing entries for the given\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 files and then rewriting the new entries at the end of the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 tags file. It is often faster to simply rebuild the entire\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 tag file than to use this.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 puts ("-v, --vgrind\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 Generates an index of items intended for human consumption,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 similar to the output of vgrind. The index is sorted, and\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 gives the page number of each item.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 puts ("-w, --no-warn\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 Suppress warning messages about entries defined in multiple\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 puts ("-x, --cxref\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 The output uses line numbers instead of page numbers, but\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 beyond that the differences are cosmetic; try both to see\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 which you like.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 puts ("-V, --version\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 Print the version of the program.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 -h, --help\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 Print this help message.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 print_language_names ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 puts ("Report bugs to bug-gnu-emacs@prep.ai.mit.edu");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 enum argument_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 at_language,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 at_regexp,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 at_filename
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 /* This structure helps us allow mixing of --lang and file names. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 enum argument_type arg_type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 char *what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 } argument;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 #ifdef VMS /* VMS specific functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 #define EOS '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 /* This is a BUG! ANY arbitrary limit is a BUG!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 Won't someone please fix this? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 #define MAX_FILE_SPEC_LEN 255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 typedef struct {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 short curlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 char body[MAX_FILE_SPEC_LEN + 1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 } vspec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 returning in each successive call the next file name matching the input
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 spec. The function expects that each in_spec passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 to it will be processed to completion; in particular, up to and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 including the call following that in which the last matching name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 is returned, the function ignores the value of in_spec, and will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 only start processing a new spec with the following call.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 If an error occurs, on return out_spec contains the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 of in_spec when the error occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 With each successive file name returned in out_spec, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 function's return value is one. When there are no more matching
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 names the function returns zero. If on the first call no file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 matches in_spec, or there is any other error, -1 is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 #include <rmsdef.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 #include <descrip.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 #define OUTSIZE MAX_FILE_SPEC_LEN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 short
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 fn_exp (out, in)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 vspec *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 char *in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 static long context = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 static struct dsc$descriptor_s o;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 static struct dsc$descriptor_s i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 static bool pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 long status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 short retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 if (pass1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 pass1 = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 o.dsc$a_pointer = (char *) out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 o.dsc$w_length = (short)OUTSIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 i.dsc$a_pointer = in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 i.dsc$w_length = (short)strlen(in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 i.dsc$b_dtype = DSC$K_DTYPE_T;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 i.dsc$b_class = DSC$K_CLASS_S;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 o.dsc$b_dtype = DSC$K_DTYPE_VT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 o.dsc$b_class = DSC$K_CLASS_VS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 out->body[out->curlen] = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 else if (status == RMS$_NMF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 retval = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 strcpy(out->body, in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 retval = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 lib$find_file_end(&context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 name of each file specified by the provided arg expanding wildcards.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 gfnames (arg, p_error)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 char *arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 bool *p_error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 switch (fn_exp (&filename, arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 *p_error = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 #ifndef OLD /* Newer versions of VMS do provide `system'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 system (cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 char *cmd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 error ("%s", "system() function not implemented under VMS");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 #define VERSION_DELIM ';'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 char *massage_name (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 char *start = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 for ( ; *s; s++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 if (*s == VERSION_DELIM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 *s = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 *s = lowcase (*s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 return start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 #endif /* VMS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845 int
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
846 main (int argc, char *argv[])
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 unsigned int nincluded_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 char **included_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 char *this_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 argument *argbuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 int current_arg, file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 linebuffer filename_lb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 bool got_err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
859 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 _fmode = O_BINARY; /* all of files are treated as binary files */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
861 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 nincluded_files = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 included_files = xnew (argc, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 current_arg = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 file_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 /* Allocate enough no matter what happens. Overkill, but each one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 is small. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 argbuffer = xnew (argc, argument);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 /* Set syntax for regular expression routines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 * If etags, always find typedefs and structure tags. Why not?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 * Also default is to find macro constants, enum constants and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 * global variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 globals = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 members = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 int opt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 char *optstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 optstring = "-aCdDf:Il:o:r:RStTi:BOuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 optstring = "-aCdDf:Il:o:StTi:BOuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 #ifndef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 optstring = optstring + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 opt = getopt_long (argc, argv, optstring, longopts, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 if (opt == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 switch (opt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 /* If getopt returns 0, then it has already processed a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 long-named option. We should do nothing. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 /* This means that a file name has been seen. Record it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 /* Common options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 case 'a': append_to_tagfile = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 case 'C': cplusplus = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 case 'd': constantypedefs = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 case 'D': constantypedefs = FALSE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 case 'f': /* for compatibility with old makefiles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 case 'o':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 if (tagfile)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 /* convert char to string, to call error with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 char buf[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 sprintf (buf, "%c", opt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 error ("-%s option may only be given once.", buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 tagfile = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 case 'O':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 oo_browser_format = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 case 'I':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 case 'S': /* for backward compatibility */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 noindentypedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 language *lang = get_language_from_name (optarg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 if (lang != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 argbuffer[current_arg].lang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 argbuffer[current_arg].arg_type = at_language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 case 'R':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 argbuffer[current_arg].what = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 case 'V':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 print_version ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 print_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 typedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 typedefs = typedefs_and_cplusplus = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 #if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 /* Etags options */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 included_files[nincluded_files++] = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 #else /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 /* Ctags options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 case 'B': searchar = '?'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 case 'u': update = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 case 'x': cxref_style = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 case 'w': no_warnings = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 #endif /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 for (; optind < argc; ++optind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 argbuffer[current_arg].what = argv[optind];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 if (nincluded_files == 0 && file_count == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 error ("no input files specified.", 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 if (tagfile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 tagfile = CTAGS ? "tags" : "TAGS";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 cwd = etags_getcwd (); /* the current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 if (cwd[strlen (cwd) - 1] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 char *oldcwd = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 cwd = concat (oldcwd, "/", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 free (oldcwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 tagfiledir = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 tagfiledir = absolute_dirname (tagfile, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 init (); /* set up boolean "functions" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 initbuffer (&lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 initbuffer (&token_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 initbuffer (&lbs[0].lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 initbuffer (&lbs[1].lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 initbuffer (&filename_lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 tagf = stdout;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1053 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 /* Switch redirected `stdout' to binary mode (setting `_fmode'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 doesn't take effect until after `stdout' is already open). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 if (!isatty (fileno (stdout)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 setmode (fileno (stdout), O_BINARY);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1058 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 * Loop through files finding functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 switch (argbuffer[i].arg_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 case at_language:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 forced_lang = argbuffer[i].lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 case at_regexp:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 analyse_regex (argbuffer[i].what);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 case at_filename:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 if (got_err)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 error ("can't find file %s\n", this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 argc--, argv++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 this_file = massage_name (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 this_file = argbuffer[i].what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 oo_browser_clear_all_globals();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 /* Input file named "-" means read file names from stdin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 (one per line) and use them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 if (streq (this_file, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 while (readline_internal (&filename_lb, stdin) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 oo_browser_clear_some_globals();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 process_file (filename_lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 process_file (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 free_patterns ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 while (nincluded_files-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 fprintf (tagf, "\f\n%s,include\n", *included_files++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 /* If CTAGS, we are here. process_file did not write the tags yet,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 because we want them ordered. Let's do it now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 if (argbuffer[i].arg_type != at_filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 sprintf (cmd,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 tagfile, argbuffer[i].what, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 if (system (cmd) != GOOD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 fatal ("failed to execute shell command", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 append_to_tagfile = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 exit (system (cmd));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 return GOOD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 * Return a language given the name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 language *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 get_language_from_name (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 if (name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 error ("empty language name", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 if (streq (name, lang->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 error ("unknown language \"%s\"", name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 * Return a language given the interpreter name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 language *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 get_language_from_interpreter (interpreter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 char *interpreter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 char **iname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 if (interpreter == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 if (lang->interpreters != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 for (iname = lang->interpreters; *iname != NULL; iname++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 if (streq (*iname, interpreter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 * Return a language given the file suffix.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 language *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 get_language_from_suffix (suffix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 char *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 char **ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 if (suffix == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 if (streq (*ext, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243 * This routine is called on each file argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 process_file (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 struct stat stat_buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 error ("skipping %s: it is not a regular file.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 if (streq (file, tagfile) && !streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 error ("skipping inclusion of %s in self.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 inf = fopen (file, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 if (inf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 perror (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 find_entries (file, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 /* file is an absolute file name. Canonicalise it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 filename = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 /* file is a file name relative to cwd. Make it relative
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 to the directory of the tags file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 filename = relative_filename (file, tagfiledir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 if (oo_browser_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 fprintf (tagf, "\f\n%s\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 free (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 * This routine sets up the boolean pseudo-functions which work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 * by setting boolean flags dependent upon the corresponding character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 * Every char which is NOT in that string is not a white char. Therefore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 * all of the array "_wht" is set to FALSE, and then the elements
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306 * of a char is TRUE if it is the string "white", else FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 init ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314 for (i = 0; i < CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 iswhite('\0') = iswhite('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 notinname('\0') = notinname('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 begtoken('\0') = begtoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 intoken('\0') = intoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 endtoken('\0') = endtoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 * This routine opens the specified file and calls the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 * which finds the function and type definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 node *last_node = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 find_entries (file, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 node *old_last_node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343 curfile = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345 /* If user specified a language, use it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 lang = forced_lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 cp = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 if (cp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 cp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 lang = get_language_from_suffix (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1369 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 /* Look for sharp-bang as the first two characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 if (readline_internal (&lb, inf) > 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 && lb.len >= 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 && lb.buffer[0] == '#'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 && lb.buffer[1] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 char *lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379 /* Set lp to point at the first char after the last slash in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 line or, if no slashes, at the first nonblank. Then set cp to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 the first successive blank and terminate the string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 lp = etags_strrchr (lb.buffer+2, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 if (lp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 lp = skip_spaces (lb.buffer + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 cp = skip_non_spaces (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 if (strlen (lp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 lang = get_language_from_interpreter (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 /* Try Fortran. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 old_last_node = last_node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 curlang = get_language_from_name ("fortran");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 Fortran_functions (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 /* No Fortran entries found. Try C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 if (old_last_node == last_node)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 curlang = get_language_from_name (cplusplus ? "c++" : "c");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 default_C_entries (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 /* Record a tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 pfnote (name, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434 if (CTAGS && name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437 np = xnew (1, node);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439 /* If ctags mode, change name "main" to M<thisfilename>. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 if (CTAGS && !cxref_style && streq (name, "main"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 register char *fp = etags_strrchr (curfile, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 np->name = concat ("M", fp == 0 ? curfile : fp + 1, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 fp = etags_strrchr (np->name, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 if (fp && fp[1] != '\0' && fp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 fp[0] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 np->name = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 np->been_warned = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 np->file = curfile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 np->is_func = is_func;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 np->lno = lno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 /* Our char numbers are 0-base, because of C language tradition?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 ctags compatibility? old versions compatibility? I don't know.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 Anyway, since emacs's are 1-base we expect etags.el to take care
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 of the difference. If we wanted to have 1-based numbers, we would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 uncomment the +1 below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 np->cno = cno /* + 1 */ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 np->left = np->right = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 if (CTAGS && !cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 if (strlen (linestart) < 50)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 np->pat = concat (linestart, "$", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 np->pat = savenstr (linestart, 50);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 np->pat = savenstr (linestart, linelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 if (oo_browser_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 np->construct = oo_browser_construct;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 oo_browser_check_and_clear_structtype();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 add_node (np, &head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 /* Date: Wed, 22 Jan 1997 02:56:31 -0500 [last amended 18 Sep 1997]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 * From: Sam Kendall <kendall@mv.mv.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 * Subject: Proposal for firming up the TAGS format specification
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 * To: F.Potorti@cnuce.cnr.it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 * pfnote should emit the optimized form [unnamed tag] only if:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 * 1. name does not contain any of the characters " \t\r\n(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 * 2. linestart contains name as either a rightmost, or rightmost but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 * one character, substring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 * 3. the character, if any, immediately before name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 * be one of the characters " \t(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 * 4. the character, if any, immediately after name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 * also be one of the characters " \t(),;".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 * The real implementation uses the notinname() macro, which recognises
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 * characters slightly different form " \t\r\n(),;". See the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 * `nonam'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 #define traditional_tag_style TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 int namelen; /* tag length */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 bool named;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513 named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 for (cp = name; !notinname (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 if (*cp == '\0') /* rule #1 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 cp = linestart + linelen - namelen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 if (notinname (linestart[linelen-1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 cp -= 1; /* rule #4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 if (!oo_browser_format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 && cp >= linestart /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 if (cp >= linestart /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 && (cp == linestart
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 || notinname (cp[-1])) /* rule #3 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 && strneq (name, cp, namelen)) /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 named = FALSE; /* use unnamed tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 if (named)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 name = savenstr (name, namelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 pfnote (name, is_func, linestart, linelen, lno, cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1542
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 * free_tree ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 * recurse on left children, iterate on right children.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 free_tree (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 while (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 register node *node_right = np->right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 free_tree (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 free (np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 free (np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 free (np);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 np = node_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 * add_node ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 * Adds a node to the tree of nodes. In etags mode, we don't keep
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 * it sorted; we just keep a linear list. In ctags mode, maintain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 * an ordered tree, with no attempt at balancing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 * add_node is the only function allowed to add nodes, so it can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 * maintain state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 add_node (np, cur_node_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 node *np, **cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 register int dif;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 register node *cur_node = *cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579 if (cur_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 *cur_node_p = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 /* Etags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 if (last_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 fatal ("internal error in add_node", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 last_node->right = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 /* Ctags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 dif = strcmp (np->name, cur_node->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 * If this tag name matches an existing one, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 * do not add the node, but maybe print a warning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 if (!dif)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 if (streq (np->file, cur_node->file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 if (!no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 np->file, lineno, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 fprintf (stderr, "Second entry ignored\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 else if (!cur_node->been_warned && !no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 fprintf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 "Duplicate entry in files %s and %s: %s (Warning only)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 np->file, cur_node->file, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 cur_node->been_warned = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 /* Actually add the node */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 /* Default class name for the current OO-Browser tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 static char *oo_browser_class;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 /* Prefix character to use in OO-Browser listings for the current tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 static char oo_browser_prefix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1638 put_entries (node *np)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 /* Output subentries that precede this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 put_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 /* Output this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 if (oo_browser_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 /* Omit C++ `class' and `method' entries as well as Objective-C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 entries from this OO-Browser tags file since the browser handles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 them independently of this file. Omit `extern' variable declarations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 as they are unused by the OO-Browser. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 if (np->construct != C_CLASS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 && np->construct != C_METHOD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 && np->construct != C_EXTERN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 && np->construct != C_OBJC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 oo_browser_class = oo_browser_default_classes[np->construct];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 switch (np->construct)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 case C_CONSTANT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 case C_ENUMERATION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 case C_ENUM_LABEL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 case C_STRUCTURE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 case C_TYPE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 case C_UNION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 case C_VARIABLE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 oo_browser_prefix = '=';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 case C_FUNCTION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 case C_MACRO:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 oo_browser_prefix = '-';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 fprintf (tagf, "%s@%c %s@%s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 oo_browser_class, oo_browser_prefix,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 np->name, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 fprintf (tagf, "%s@%c ???@%s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 oo_browser_class, oo_browser_prefix, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 fprintf (tagf, "%s\177%s\001%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 np->pat, np->name, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 fprintf (tagf, "%s\177%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 np->pat, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 if (np->name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 error ("internal error: NULL name in ctags mode.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 if (vgrind_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 fprintf (stdout, "%s %s %d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 np->name, np->file, (np->lno + 63) / 64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 fprintf (stdout, "%-16s %3d %-16s %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 np->name, np->lno, np->file, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 fprintf (tagf, "%s\t%s\t", np->name, np->file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 if (np->is_func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 { /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 putc ('^', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 for (sp = np->pat; *sp; sp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 if (*sp == '\\' || *sp == searchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 putc ('\\', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 putc (*sp, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 { /* a typedef; text pattern inadequate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 fprintf (tagf, "%d", np->lno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 putc ('\n', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 /* Output subentries that follow this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 put_entries (np->right);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 /* Length of a number's decimal representation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 int number_len PP ((long num));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 number_len (num)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 long num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 int len = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 while ((num /= 10) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 len += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 * Return total number of characters that put_entries will output for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 * the nodes in the subtree of the specified node. Works only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 * we are not ctags, but called only in that case. This count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 * is irrelevant with the new tags.el, but is still supplied for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 * backward compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 total_size_of_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 register int total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 for (total = 0; np != NULL; np = np->right)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 /* Count left subentries. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 total += total_size_of_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 /* Count this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 total += strlen (np->pat) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 total += 1 + strlen (np->name); /* \001name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 return total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790 * The C symbol tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 st_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 st_C_objprot, st_C_objimpl, st_C_objend,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 st_C_gnumacro,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 st_C_ignore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 st_C_javastruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 st_C_const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 , st_C_union, st_C_class, st_C_extern, st_C_inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 /* Feed stuff between (but not including) %[ and %] lines to:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 gperf -c -k 1,3 -o -p -r -t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 %[
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 %%
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 @interface, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 @protocol, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 @implementation,0, st_C_objimpl
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 @end, 0, st_C_objend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 import, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 package, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 friend, C_PLPL, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 extends, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 implements, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 interface, C_JAVA, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 class, C_PLPL, st_C_class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 namespace, C_PLPL, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 domain, C_STAR, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 union, 0, st_C_union
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 struct, 0, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 enum, 0, st_C_enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 typedef, 0, st_C_typedef
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 define, 0, st_C_define
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 inline, 0, st_C_inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 bool, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 long, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 short, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 int, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 char, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 float, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 double, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 signed, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 unsigned, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 auto, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 void, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 extern, 0, st_C_extern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 static, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 const, 0, st_C_const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 volatile, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 explicit, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 mutable, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 typename, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 DEFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 SYSCALL, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 ENTRY, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 PSEUDO, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 # These are defined inside C functions, so currently they are not met.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 # EXFUN used in glibc, DEFVAR_* in emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 #EXFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 #DEFVAR_, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 %]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 and replace lines between %< and %> with its output. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 /*%<*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 /* C code produced by gperf version 2.5 (GNU C++ version) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 #define TOTAL_KEYWORDS 41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 #define MIN_WORD_LENGTH 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 #define MAX_WORD_LENGTH 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 #define MIN_HASH_VALUE 13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 #define MAX_HASH_VALUE 129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 /* maximum key range = 117, duplicates = 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 static unsigned int
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1872 hash (char *str, unsigned int len)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 static unsigned char asso_values[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881 130, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 130, 130, 130, 130, 13, 130, 130, 130, 33, 32,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 47, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 5, 130, 130, 20, 32, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 130, 130, 130, 130, 130, 130, 130, 47, 55, 8,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 15, 33, 61, 38, 130, 60, 130, 130, 2, 9,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 10, 62, 59, 130, 28, 27, 50, 19, 3, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 };
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1890 return len +
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1891 asso_values[(unsigned char) str[2]] +
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1892 asso_values[(unsigned char) str[0]];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1895 static struct C_stab_entry *
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1896 in_word_set (char *str, unsigned int len)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 static struct C_stab_entry wordlist[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901 {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 {"volatile", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 {"long", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 {"const", 0, st_C_const},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 {"@end", 0, st_C_objend},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 {"namespace", C_PLPL, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 {"domain", C_STAR, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 {"@interface", 0, st_C_objprot},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 {"@implementation", 0, st_C_objimpl},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 {"double", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 {"PSEUDO", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 {"SYSCALL", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 {"@protocol", 0, st_C_objprot},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 {"unsigned", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 {"enum", 0, st_C_enum},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 {"char", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 {"class", C_PLPL, st_C_class},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 {"struct", 0, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 {"mutable", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 {"void", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 {"inline", 0, st_C_inline},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 {"ENTRY", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 {"signed", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 {"package", C_JAVA, st_C_ignore},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 {"static", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 {"define", 0, st_C_define},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946 {"union", 0, st_C_union},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 {"DEFUN", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 {"extern", 0, st_C_extern},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 {"extends", C_JAVA, st_C_javastruct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 {"short", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 {"explicit", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 {"auto", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 {"int", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 {"typedef", 0, st_C_typedef},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 {"typename", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 {"interface", C_JAVA, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 {"bool", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 {"import", C_JAVA, st_C_ignore},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 {"friend", C_PLPL, st_C_ignore},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 {"float", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 {"implements", C_JAVA, st_C_javastruct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 register int key = hash (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 if (key <= MAX_HASH_VALUE && key >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 register char *s = wordlist[key].name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 return &wordlist[key];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 /*%>*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 enum sym_type C_symtype PP ((char *str, int len, int c_ext));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 C_symtype (str, len, c_ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 int c_ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 register struct C_stab_entry *se = in_word_set (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 return st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 return se->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2003
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 * C functions and variables are recognized using a simple
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 * finite automaton. fvdef is its state variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 fvnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 fvnameseen, /* function or variable name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 fstartlist, /* func: just after open parenthesis */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 finlist, /* func: in parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 flistseen, /* func: after parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 fignore, /* func: before open brace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 vignore /* var-like: ignore until ';' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 } fvdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 * typedefs are recognized using a simple finite automaton.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 * typdef is its state variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 tnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 ttypedseen, /* typedef keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 tinbody, /* inside typedef body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 tend, /* just before typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 tignore /* junk after typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 } typdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 * struct-like structures (enum, struct and union) are recognized
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 * using another simple finite automaton. `structdef' is its state
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 * variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 snone, /* nothing seen yet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 skeyseen, /* struct-like keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 stagseen, /* struct-like tag seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 scolonseen, /* colon seen after struct-like tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 sinbody /* in struct body: recognize member func defs*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 } structdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 * struct tag, and structtype is the type of the preceding struct-like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 * keyword.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 char *structtag = "<uninited>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 enum sym_type structtype;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
2058 oo_browser_check_and_clear_structtype(void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2059 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 /* Allow for multiple enum_label tags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061 if (structtype != st_C_enum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2066 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2067 * When objdef is different from onone, objtag is the name of the class.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2069 char *objtag = "<uninited>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2071 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2072 * Yet another little state machine to deal with preprocessor lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 dnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 dsharpseen, /* '#' seen as first char on line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 ddefineseen, /* '#' and 'define' seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 dignorerest /* ignore rest of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 } definedef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083 * State machine for Objective C protocols and implementations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 * Tom R.Hageman <tom@basil.icce.rug.nl>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 onone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 oprotocol, /* @interface or @protocol seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 oimplementation, /* @implementations seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 otagseen, /* class name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 oparenseen, /* parenthesis before category seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 ocatseen, /* category name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 oinbody, /* in @implementation body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 omethodsign, /* in @implementation body, after +/- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096 omethodtag, /* after method name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 omethodcolon, /* after method colon */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 omethodparm, /* after method parameter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 oignore /* wait for @end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 } objdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 * Use this structure to keep info about the token read, and how it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 * should be tagged. Used by the make_C_tag function to build a tag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 bool valid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 bool named;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 int linelen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 int lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 long linepos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 } token;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117 token tok; /* latest token read */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2119 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2120 * Set this to TRUE, and the next token considered is called a function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 * Used only for GNU emacs's function-defining macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2122 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 bool next_token_is_func;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2125 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2126 * TRUE in the rules part of a yacc file, FALSE outside (parse as C).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2128 bool yacc_rules;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2130 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2131 * methodlen is the length of the method name stored in token_name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 int methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
2137 oo_browser_clear_all_globals(void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2138 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 /* Initialize globals so there is no carry over between files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 fvdef = fvnone; typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 definedef = dnone; objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 next_token_is_func = yacc_rules = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2147 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
2148 oo_browser_clear_some_globals(void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2149 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2156 * consider_token ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 * checks to see if the current token is at the start of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 * function or variable, or corresponds to a typedef, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2159 * is a struct/union/enum tag, or #define, or an enum constant.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161 * *IS_FUNC gets TRUE iff the token is a function or #define macro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 * with args. C_EXT is which language we are looking at.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2163 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164 * In the future we will need some way to adjust where the end of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 * the token is; for instance, implementing the C++ keyword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2166 * `operator' properly will adjust the end of the token to be after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 * whatever follows `operator'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2168 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 * Globals
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170 * fvdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 * structdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 * definedef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 * typdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 * objdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 * next_token_is_func IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 bool consider_token PP ((char *str, int len, int c, int c_ext,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2178 int cblev, int parlev, bool *is_func_or_var));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2179 bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 register char *str; /* IN: token pointer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182 register int len; /* IN: token length */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 register int c; /* IN: first char after the token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 int c_ext; /* IN: C extensions mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 int cblev; /* IN: curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 int parlev; /* IN: parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 bool *is_func_or_var; /* OUT: function or variable found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 enum sym_type toktype = C_symtype (str, len, c_ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 set_construct(C_STRUCTURE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 set_construct(C_UNION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 case st_C_typedef:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 set_construct(C_EXTERN);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212 case st_C_inline:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 set_construct(C_FUNCTION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2219 * Advance the definedef state machine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 /* We're not on a preprocessor line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 case dsharpseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 if (toktype == st_C_define)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 definedef = ddefineseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 case ddefineseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 * Make a tag for any macro, unless it is a constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 * and constantypedefs is FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 *is_func_or_var = (c == '(');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 char *p = str + len * sizeof(char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248 if (*p == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249 /* This must be a macro since there is no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 whitespace between the opening parenthesis
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2251 and the definition name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2255 *is_func_or_var = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257 /* Handle possible whitespace between macro tag and opening
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 parenthesis and ensure this is an actual macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 -- Bob Weiner, Altrasoft, 11/19/1997 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 while (*p && isspace(*p)) p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 if (*p) c = *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 /* Skip over nested parentheses. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264 if (c == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 short depth = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 while (*++p && depth > 0 && *p != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270 switch (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 depth++; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 depth--; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 /* If this is a macro, we have just passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280 the arguments and there will be more on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 the line before the NULL character that marks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 the end of the line token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 while (*p == ' ' || *p == '\t') p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 if (*p) *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 set_construct((*is_func_or_var) ? C_MACRO : C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 if (!*is_func_or_var && !constantypedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 case dignorerest:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 error ("internal error: definedef value.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 * Now typedefs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 case tnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 if (toktype == st_C_typedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 if (typedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310 typdef = ttypedseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 case ttypedseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 case st_C_const:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 set_construct(C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 /* fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 case st_none:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 typdef = tend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2328 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2329 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2330 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2331 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2332 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2334 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2335 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2336 /* Do not return here, so the structdef stuff has a chance. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2338 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2339 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2341 case st_C_const:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2342 set_construct(C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2343 /* fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2344 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2347 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2352 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2357 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2358 * This structdef business is currently only invoked when cblev==0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 * It should be recursively invoked whatever the curly brace level,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 * and a stack of states kept, to allow for definitions of structs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361 * within structs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 * This structdef business is NOT invoked when we are ctags and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364 * file is plain C. This is because a struct tag may have the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365 * name as another tag, and this loses with ctags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2366 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 case st_C_javastruct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2371 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380 if (typdef == ttypedseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 structdef = skeyseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 structtype = toktype;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2388
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2389 if (structdef == skeyseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391 /* Save the tag for struct/union/class, for functions and variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 that may be defined inside. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 if (structtype == st_C_struct)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 if (structtype == st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2397 || structtype == st_C_union
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398 || structtype == st_C_class)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 structtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 structtag = "<enum>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 structdef = stagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2407 /* Avoid entering fvdef stuff if typdef is going on. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 if (typdef != tnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 definedef = dnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2411 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414 /* Detect GNU macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416 DEFUN note for writers of emacs C code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 The DEFUN macro, used in emacs C source code, has a first arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 that is a string (the lisp function name), and a second arg that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 is a C function name. Since etags skips strings, the second arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2420 is tagged. This is unfortunate, as it would be better to tag the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 first arg. The simplest way to deal with this problem would be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 to name the tag with a name built from the function name, by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 removing the initial 'F' character and substituting '-' for '_'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 Anyway, this assumes that the conventions of naming lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 functions will never change. Currently, this method is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 implemented, so writers of emacs code are recommended to put the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 first two args of a DEFUN on the same line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 if (definedef == dnone && toktype == st_C_gnumacro)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 next_token_is_func = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 if (next_token_is_func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435 next_token_is_func = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2441 /* Detect Objective C constructs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444 case onone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2446 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2447 case st_C_objprot:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2448 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449 set_construct(C_OBJC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 objdef = oprotocol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 case st_C_objimpl:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 set_construct(C_OBJC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 objdef = oimplementation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2460 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 case oimplementation:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 /* Save the class tag for functions or variables defined inside. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 case oprotocol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 /* Save the class tag for categories. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 objdef = otagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 case oparenseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 objdef = ocatseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 case oinbody:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 case omethodsign:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 objdef = omethodtag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 methodlen = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 grow_linebuffer (&token_name, methodlen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 strncpy (token_name.buffer, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 token_name.buffer[methodlen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 token_name.len = methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 case omethodcolon:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 objdef = omethodparm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 objdef = omethodtag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 methodlen += len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 grow_linebuffer (&token_name, methodlen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500 strncat (token_name.buffer, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 token_name.len = methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 case oignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 if (toktype == st_C_objend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508 /* Memory leakage here: the string pointed by objtag is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 never released, because many tests would be needed to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 avoid breaking on incorrect input code. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 class tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2513 free (objtag); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514 objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2519 /* A function, variable or enum constant? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2522 case st_C_const:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2523 set_construct(C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2524 /* fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2526 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2528 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2529 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2530 fvdef = fvnone; /* should be useless */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2531 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2532 case st_C_ignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 case st_none:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 oo_browser_construct = C_ENUM_LABEL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2542 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 if (fvdef == fvnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2546 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2547 fvdef = fvnameseen; /* function or variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2548 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2550 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2551 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2553 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2554 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2555
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2556 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2557 * C_entries ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2558 * This routine finds functions, variables, typedefs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2559 * #define's, enum constants and struct/union/enum definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2560 * #C syntax and adds them to the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2561 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2562 #define current_lb_is_new (newndx == curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563 #define switch_line_buffers() (curndx = 1 - curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2565 #define curlb (lbs[curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2566 #define othlb (lbs[1-curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567 #define newlb (lbs[newndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568 #define curlinepos (lbs[curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2569 #define othlinepos (lbs[1-curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2570 #define newlinepos (lbs[newndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2572 #define CNL_SAVE_DEFINEDEF() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2573 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 curlinepos = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2575 lineno++; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2576 linecharno = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2577 charno += readline (&curlb, inf); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2578 lp = curlb.buffer; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2579 quotednl = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2580 newndx = curndx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2583 #define CNL() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2585 CNL_SAVE_DEFINEDEF(); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2586 if (savetok.valid) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2588 tok = savetok; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2589 savetok.valid = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2590 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2591 definedef = dnone; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2592 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2593
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2595 void make_C_tag PP ((bool isfun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2596 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2597 make_C_tag (isfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 bool isfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2599 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2600 /* This function should never be called when tok.valid is FALSE, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2601 we must protect against invalid input or internal errors. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2602 if (tok.valid)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2603 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2604 if (traditional_tag_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2605 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2606 /* This was the original code. Now we call new_pfnote instead,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2607 which uses the new method for naming tags (see new_pfnote). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 char *name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2610 if (CTAGS || tok.named)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2611 name = savestr (token_name.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2612 pfnote (name, isfun,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2613 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2615 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616 new_pfnote (token_name.buffer, token_name.len, isfun,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2617 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2618 tok.valid = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2620 else if (DEBUG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2622 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2625 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2626 C_entries (c_ext, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2627 int c_ext; /* extension of C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2628 FILE *inf; /* input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2629 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630 register char c; /* latest char read; '\0' for end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2631 register char *lp; /* pointer one beyond the character `c' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2632 int curndx, newndx; /* indices for current and new lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633 register int tokoff; /* offset in line of start of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 register int toklen; /* length of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 char *qualifier; /* string used to qualify names */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 int qlen; /* length of qualifier */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 int cblev; /* current curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638 int parlev; /* current parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 bool incomm, inquote, inchar, quotednl, midtoken;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 bool cplpl, cjava;
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 647
diff changeset
2641 token savetok = {0}; /* token saved during preprocessor handling */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2643
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 tokoff = toklen = 0; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 curndx = newndx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2647 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 lp = curlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 *lp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651 fvdef = fvnone; typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 definedef = dnone; objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 next_token_is_func = yacc_rules = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 midtoken = inquote = inchar = incomm = quotednl = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 tok.valid = savetok.valid = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658 cplpl = (c_ext & C_PLPL) == C_PLPL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 cjava = (c_ext & C_JAVA) == C_JAVA;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 if (cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 { qualifier = "."; qlen = 1; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2663 { qualifier = "::"; qlen = 2; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2667 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2668 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2669 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2670 /* If we're at the end of the line, the next character is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2671 '\0'; don't skip it, because it's the thing that tells us
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2672 to read the next line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2673 if (*lp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2674 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675 quotednl = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2676 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2677 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2678 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2679 c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2680 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2681 else if (incomm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2682 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2683 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2684 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2685 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2686 if (*lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2687 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2688 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2689 incomm = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2690 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2691 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2692 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2693 /* Newlines inside comments do not end macro definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2694 traditional cpp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2695 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2696 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2700 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2703 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2704 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2705 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2706 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2707 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2708 /* Newlines inside strings do not end macro definitions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2709 in traditional cpp, even though compilers don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2710 usually accept them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2711 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2712 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2713 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2714 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2715 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 else if (inchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2717 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2718 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721 /* Hmmm, something went wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 inchar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 inquote = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2735 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2738 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2739 inchar = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2740 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2741 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2743 case '/':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 if (*lp == '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2745 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 incomm = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 else if (/* cplpl && */ *lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 c = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2754 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2755 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 if ((c_ext & YACC) && *lp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 /* entering or exiting rules section in yacc file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2761 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 definedef = dnone; fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2763 typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2764 next_token_is_func = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2765 midtoken = inquote = inchar = incomm = quotednl = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2766 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2767 yacc_rules = !yacc_rules;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2768 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2769 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2770 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2771 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2772 case '#':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2773 if (definedef == dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2774 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2775 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2776 bool cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778 /* Look back on this line. If all blanks, or nonblanks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2779 followed by an end of comment, this is a preprocessor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2780 token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 for (cp = newlb.buffer; cp < lp-1; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2782 if (!iswhite (*cp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2784 if (*cp == '*' && *(cp+1) == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2785 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2786 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2787 cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2788 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790 cpptoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792 if (cpptoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 definedef = dsharpseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 } /* if (definedef == dnone) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2799
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2800 /* Consider token only if some complicated conditions are satisfied. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2801 if ((definedef != dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 || (cblev == 0 && structdef != scolonseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2803 || (cblev == 1 && cplpl && structdef == sinbody)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2804 || (structdef == sinbody && structtype == st_C_enum))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2805 && typdef != tignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2806 && definedef != dignorerest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2807 && fvdef != finlist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2808 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2809 if (midtoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2810 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2811 if (endtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2812 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2813 if (c == ':' && cplpl && *lp == ':' && begtoken(*(lp + 1)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2814 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2815 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2816 * This handles :: in the middle, but not at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2817 * beginning of an identifier.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2818 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2819 lp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2820 toklen += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2822 set_construct(C_METHOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2823 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2825 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2826 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827 bool funorvar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829 if (yacc_rules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2830 || consider_token (newlb.buffer + tokoff, toklen, c,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2831 c_ext, cblev, parlev, &funorvar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2833 tok.named = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 if (structdef == sinbody
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 && definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 && funorvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 /* function or var defined in C++ class body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839 int len = strlen (structtag) + qlen + toklen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2840 grow_linebuffer (&token_name, len + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841 strcpy (token_name.buffer, structtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2842 strcat (token_name.buffer, qualifier);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2843 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2844 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2845 token_name.len = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2846 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2847 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2848 oo_browser_construct = C_METHOD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2849 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2851 else if (objdef == ocatseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2852 /* Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2853 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2854 int len = strlen (objtag) + 2 + toklen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2855 grow_linebuffer (&token_name, len + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2856 strcpy (token_name.buffer, objtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2857 strcat (token_name.buffer, "(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2858 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2859 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2860 strcat (token_name.buffer, ")");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2861 token_name.len = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2862 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2863 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2864 oo_browser_construct = C_OBJC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2865 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2866 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2867 else if (objdef == omethodtag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2868 || objdef == omethodparm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2869 /* Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2870 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2871 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2872 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873 oo_browser_construct = C_OBJC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2874 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 grow_linebuffer (&token_name, toklen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 strncpy (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881 token_name.buffer[toklen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 token_name.len = toklen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2883 /* Name macros. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 tok.named
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 = (structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 || typdef == tend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 /* Also name #define constants,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 enumerations and enum_labels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890 Conditionalize `funorvar' reference
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 here or #defines will appear without
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892 their #names.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 -- Bob Weiner, Altrasoft, 4/25/1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2894 || ((oo_browser_format || funorvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2895 && definedef == dignorerest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2896 || (oo_browser_format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2897 && (oo_browser_construct == C_ENUMERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2898 || oo_browser_construct == C_ENUM_LABEL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 || (funorvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 && definedef == dignorerest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2903 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2904 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2905 tok.lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2906 tok.linelen = tokoff + toklen + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907 tok.buffer = newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2908 tok.linepos = newlinepos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2909 tok.valid = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2910
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2911 if (definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2912 && (fvdef == fvnameseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2913 || structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2914 || typdef == tend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2915 || objdef != onone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2916 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2917 if (current_lb_is_new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2918 switch_line_buffers ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2919 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2920 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2921 make_C_tag (funorvar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2922 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2923 midtoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2924 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2925 } /* if (endtoken (c)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2926 else if (intoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2928 toklen++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2929 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2930 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2931 } /* if (midtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2932 else if (begtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2933 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2935 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2937 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2942 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2943 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2944 set_construct(C_MACRO);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2945 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2946 make_C_tag (TRUE); /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2948 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2949 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2951 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2952 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2953 if (structdef == stagseen && !cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2955 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2956 case dsharpseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2957 savetok = tok;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2958 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2959 if (!yacc_rules || lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2960 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2961 tokoff = lp - 1 - newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2962 toklen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963 midtoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2965 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2966 } /* if (begtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2967 } /* if must look at token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2968
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2970 /* Detect end of line, colon, comma, semicolon and various braces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2971 after having handled a token.*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2972 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2973 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 case ':':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2975 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2976 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2977 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2978 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2979 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2980 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2981 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2982 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2983 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2984 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2985 objdef = omethodcolon;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2986 methodlen += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2987 grow_linebuffer (&token_name, methodlen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2988 strcat (token_name.buffer, ":");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2989 token_name.len = methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2990 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2991 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2992 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2993 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2994 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2995 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2996 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2997 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2998 if (yacc_rules)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2999 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3000 make_C_tag (FALSE); /* a yacc function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3001 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3002 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3003 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3004 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3005 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3007 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3008 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3009 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3010 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 if (cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3013 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3014 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3015 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3016 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3017 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3018 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3019 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3020 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3021 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3022 typdef = tnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3027 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3028 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3029 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3030 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3032 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3033 /* if (constantypedefs && structdef == snone)*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3034 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3035 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3036 switch (structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3037 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3038 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3039 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3040 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3041 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3042 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3043 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3044 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 set_construct(C_VARIABLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3046 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3047 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3048 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3049 /* Force reset of st_C_enum structtype value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3052 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3053 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3054 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3055 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056 /* The following instruction invalidates the token.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3057 Probably the token should be invalidated in all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3058 other cases where some state machine is reset. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3059 tok.valid = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3062 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3063 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3064 case ',':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3065 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3066 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3067 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3068 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3069 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3070 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3071 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3072 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3073 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3074 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3075 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3076 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3077 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3078 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3079 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3080 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3081 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3082 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3083 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3084 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3085 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3086 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3087 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3088 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3089 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3090 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3091 case '[':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3092 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3093 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3094 if (cblev == 0 && typdef == tend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3095 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3096 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3097 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3098 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3099 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3100 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3101 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3102 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3103 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3104 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3105 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3106 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3107 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3108 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3109 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3110 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3111 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3112 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3113 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3114 if (constantypedefs && structdef == snone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3115 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3117 switch (structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3120 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3121 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3122 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3123 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3124 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3125 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3126 set_construct(C_VARIABLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3127 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3128 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3129 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130 /* Force reset of st_C_enum structtype value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3131 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3133 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3134 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3135 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3136 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3137 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3138 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3139 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3140 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3141 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3142 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3143 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3144 if (objdef == otagseen && parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3145 objdef = oparenseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3146 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3149 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3151 case ttypedseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3152 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3153 if (tok.valid && *lp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3154 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3155 /* This handles constructs like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3156 typedef void OperatorFun (int fun); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3157 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3158 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3159 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3160 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3161 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3162 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3163 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3164 } /* switch (typdef) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3165 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3166 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3167 fvdef = fstartlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3168 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3169 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3170 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3171 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3172 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3173 parlev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3174 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3175 case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3176 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3177 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3178 if (objdef == ocatseen && parlev == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3180 make_C_tag (TRUE); /* an Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3181 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3183 if (--parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3185 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3187 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3188 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 fvdef = flistseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3191 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 if (cblev == 0 && typdef == tend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3194 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3196 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3197 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3198 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3200 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3201 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3203 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3204 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3205 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3207 if (typdef == ttypedseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208 typdef = tinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3209 switch (structdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3210 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 case skeyseen: /* unnamed struct */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3212 structdef = sinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3213 structtag = "_anonymous_";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3214 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3215 case stagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3216 case scolonseen: /* named struct */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3217 structdef = sinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3218 make_C_tag (FALSE); /* a struct */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3219 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3220 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3221 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3223 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3224 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3225 set_construct(C_FUNCTION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3226 /* Ensure function name is recorded.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3227 -- Bob Weiner, Altrasoft */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3228 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3229 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3230 make_C_tag (TRUE); /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3231 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3232 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3233 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3234 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3235 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3236 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3238 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3239 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3240 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3241 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3242 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3243 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3244 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3245 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3246 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3247 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3248 /* Neutralize `extern "C" {' grot. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3249 if (cblev == 0 && structdef == snone && typdef == tnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3250 cblev = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3251 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3253 cblev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3254 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3255 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3256 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3257 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258 if (fvdef == fstartlist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3259 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3260 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3261 case '}':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3262 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3263 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3264 if (!noindentypedefs && lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3266 cblev = 0; /* reset curly brace level if first column */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 parlev = 0; /* also reset paren level, just in case... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3268 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 else if (cblev > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3270 cblev--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3271 if (cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3273 if (typdef == tinbody)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3274 typdef = tend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3275 /* Memory leakage here: the string pointed by structtag is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 never released, because I fear to miss something and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3277 break things while freeing the area. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3278 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3279 struct tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3280 if (structdef == sinbody)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3281 free (structtag); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3282
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3283 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3284 structtag = "<error>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3285 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3286 /* Next line added to avoid any state carryover between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3287 functions. -- Bob Weiner, Altrasoft, 11/19/1997 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3288 fvdef = fvnone; oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3289 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3290 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3291 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3292 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3293 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3294 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3295 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3296 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3297 int is_method = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3299 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3305 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3306 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3307 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3308 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3309 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3312 switch (structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3313 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3314 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3315 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3316 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3317 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3318 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3319 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3320 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3321 /* a global variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3322 set_construct(C_VARIABLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3323 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3324 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3326 /* ootags categorizes each tag found whereas etags doesn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3327 Set the is_method flag if this tag has been marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3328 such by an earlier section of code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3329 -- Steve Baur, Altrasoft, 5/7/1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3330 is_method = (oo_browser_construct == C_METHOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3332 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3333 /* Force reset of st_C_enum structtype value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3334 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 fvdef = is_method ? fignore : vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3343 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3345 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3347 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3348 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349 case '+':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3350 case '-':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3351 if (objdef == oinbody && cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3352 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 objdef = omethodsign;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3354 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3355 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 case '#': case '~': case '&': case '%': case '/': case '|':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 case '^': case '!': case '<': case '>': case '.': case '?': case ']':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3360 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3361 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 if (!cplpl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3363 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3364 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3365 /* The above characters cannot follow a function tag in C, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3366 unmark this as a function entry. For C++, these characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3367 may follow an `operator' function construct, so skip the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3368 unmarking conditional below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3369 -- Steve Baur, Altrasoft, 5/7/1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3370 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3371 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3372 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3373 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3374 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3375 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3376 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3377 if (objdef == otagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3378 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3379 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3380 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3381 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3382 /* If a macro spans multiple lines don't reset its state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3383 if (quotednl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3384 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3385 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3386 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3387 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3388 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3390 } /* while not eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3391 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3392
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3393 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3394 * Process either a C++ file or a C file depending on the setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3395 * of a global flag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3396 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3397 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3398 default_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3399 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3400 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3401 C_entries (cplusplus ? C_PLPL : 0, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3404 /* Always do plain ANSI C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3405 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3406 plain_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3407 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3408 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3409 C_entries (0, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3410 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3412 /* Always do C++. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3413 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3414 Cplusplus_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3415 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3416 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3417 C_entries (C_PLPL, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3420 /* Always do Java. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3421 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3422 Cjava_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3423 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3424 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3425 C_entries (C_JAVA, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3426 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3428 /* Always do C*. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3429 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3430 Cstar_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3431 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3432 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3433 C_entries (C_STAR, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3434 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3435
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3436 /* Always do Yacc. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3437 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3438 Yacc_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3439 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3440 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3441 C_entries (YACC, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3442 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3443
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3444 /* A useful macro. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3445 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3446 for (lineno = charno = 0; /* loop initialization */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3447 !feof (file_pointer) /* loop test */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3448 && (lineno++, /* instructions at start of loop */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3449 linecharno = charno, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3450 charno += readline (&line_buffer, file_pointer), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3451 char_pointer = lb.buffer, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3452 TRUE); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3453 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3456 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3457 * Read a file, but do no processing. This is used to do regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3458 * matching on files that have no language defined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3459 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3460 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3461 just_read_file (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3462 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3463 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3464 register char *dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3466 LOOP_ON_INPUT_LINES (inf, lb, dummy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3467 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3469
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3470 /* Fortran parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3472 bool tail PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3473 bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3474 tail (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3475 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3476 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3477 register int len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3479 while (*cp && lowcase(*cp) == lowcase(dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3480 cp++, len++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3481 if (*cp == '\0' && !intoken(dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3482 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3483 dbp += len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3484 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3485 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3486 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3487 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3488
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3489 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3490 takeprec ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3491 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3492 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3493 if (*dbp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3494 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3495 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3496 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3497 if (strneq (dbp, "(*)", 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3498 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3499 dbp += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3500 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3501 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3502 if (!isdigit (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3503 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3504 --dbp; /* force failure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3505 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3507 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3508 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3509 while (isdigit (*dbp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3510 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3512 void getit PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3513 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3514 getit (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3515 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3516 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3517 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3519 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3520 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3522 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3523 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3524 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3525 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3526 if (dbp[5] != '&')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3527 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3528 dbp += 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3529 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3531 if (!isalpha (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3532 && *dbp != '_'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3533 && *dbp != '$')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3534 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3535 for (cp = dbp + 1; *cp && intoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3536 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3537 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3538 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3539 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3542 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3543 Fortran_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3544 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3546 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3547 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3548 if (*dbp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3549 dbp++; /* Ratfor escape to fortran */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3550 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3551 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3552 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3553 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3554 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3555 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3556 if (tail ("integer"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3557 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3558 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3559 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3560 if (tail ("real"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3561 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3562 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3563 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3564 if (tail ("logical"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3565 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3566 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3567 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3568 if (tail ("complex") || tail ("character"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3569 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3570 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3571 case 'd':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3572 if (tail ("double"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3573 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3574 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3575 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3576 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3577 if (tail ("precision"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3578 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3579 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3580 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3581 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3582 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3583 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3584 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3585 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3586 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3587 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3588 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3589 if (tail ("function"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3590 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3591 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3592 case 's':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3593 if (tail ("subroutine"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3594 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3595 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3596 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597 if (tail ("entry"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3598 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3599 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3600 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3601 if (tail ("program"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3602 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3603 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3604 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3606 if (tail ("procedure"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3607 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3610 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3611 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3613 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3614 * Bob Weiner, Motorola Inc., 4/3/94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3615 * Unix and microcontroller assembly tag handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3616 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3617 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
3619 Asm_labels (FILE *inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3620 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3621 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3623 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3624 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3625 /* If first char is alphabetic or one of [_.$], test for colon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3626 following identifier. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3627 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3628 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3629 /* Read past label. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3630 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3631 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3632 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3633 if (*cp == ':' || isspace (*cp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3634 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3635 /* Found end of label, so copy it and add it to the table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3636 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3637 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3638 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3639 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3640 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3641 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3643 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3644 * Perl support by Bart Robinson <lomew@cs.utah.edu>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3645 * enhanced by Michael Ernst <mernst@alum.mit.edu>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3646 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647 * Perl variable names: /^(my|local).../
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3648 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3649 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3650 Perl_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3651 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3653 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3655 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3656 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3657 if (*cp++ == 's'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3658 && *cp++ == 'u'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3659 && *cp++ == 'b' && isspace (*cp++))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3661 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3662 if (*cp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3663 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3664 while (*cp != '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3665 && !isspace (*cp) && *cp != '{' && *cp != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3666 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3667 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3668 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3669 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3670 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3671 else if (globals /* only if tagging global vars is enabled */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3672 && ((cp = lb.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3673 *cp++ == 'm'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674 && *cp++ == 'y')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3675 || (cp = lb.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3676 *cp++ == 'l'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3677 && *cp++ == 'o'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3678 && *cp++ == 'c'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3679 && *cp++ == 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680 && *cp++ == 'l'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3681 && (*cp == '(' || isspace (*cp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3682 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3683 /* After "my" or "local", but before any following paren or space. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3684 char *varname = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3685
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3686 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3687 if (*cp == '$' || *cp == '@' || *cp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3689 char* varstart = ++cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3690 while (isalnum (*cp) || *cp == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3691 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3692 varname = savenstr (varstart, cp-varstart);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3693 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3694 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3695 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3696 /* Should be examining a variable list at this point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3697 could insist on seeing an open parenthesis. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3698 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3702 /* Perhaps I should back cp up one character, so the TAGS table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3703 doesn't mention (and so depend upon) the following char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3704 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3705 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3706 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3707 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3708 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3710 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3711 * Python support by Eric S. Raymond <esr@thyrsus.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3712 * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3713 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3714 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3715 Python_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3716 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3717 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3718 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3719
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3720 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3721 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3722 if (*cp++ == 'd'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3723 && *cp++ == 'e'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3724 && *cp++ == 'f' && isspace (*cp++))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3725 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3726 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3727 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3728 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3729 pfnote ((char *) NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3730 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3731 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3733 cp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3734 if (*cp++ == 'c'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3735 && *cp++ == 'l'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3736 && *cp++ == 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3737 && *cp++ == 's'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3738 && *cp++ == 's' && isspace (*cp++))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3739 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3740 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3741 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3742 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3743 pfnote ((char *) NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3744 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3745 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3746 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3747 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3749 /* Idea by Corny de Souza
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3750 * Cobol tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3751 * We could look for anything that could be a paragraph name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3752 * i.e. anything that starts in column 8 is one word and ends in a full stop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3753 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3754 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3755 Cobol_paragraphs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3756 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3758 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3759
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3760 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3761 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3762 if (lb.len < 9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3763 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3764 bp += 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3765
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3766 /* If eoln, compiler option or comment ignore whole line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3767 if (bp[-1] != ' ' || !isalnum (bp[0]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3768 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3770 for (ep = bp; isalnum (*ep) || *ep == '-'; ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3771 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3772 if (*ep++ == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3773 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3774 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3775 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3776 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3777
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3778 /* Added by Mosur Mohan, 4/22/88 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 /* Pascal parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3781 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3782 * Locates tags for procedures & functions. Doesn't do any type- or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3783 * var-definitions. It does look for the keyword "extern" or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3784 * "forward" immediately following the procedure statement; if found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3785 * the tag is skipped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 Pascal_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3789 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3791 linebuffer tline; /* mostly copied from C_entries */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 long save_lcno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793 int save_lineno, save_len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 char c, *cp, *namebuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3796 bool /* each of these flags is TRUE iff: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3797 incomment, /* point is inside a comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3798 inquote, /* point is inside '..' string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3799 get_tagname, /* point is after PROCEDURE/FUNCTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3800 keyword, so next item = potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3801 found_tag, /* point is after a potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3802 inparms, /* point is within parameter-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3803 verify_tag; /* point has passed the parm-list, so the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3804 next token will determine whether this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3805 is a FORWARD/EXTERN to be ignored, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3806 whether it is a real tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3808 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3809 namebuf = NULL; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3810 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813 *dbp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3814 initbuffer (&tline);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3815
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3816 incomment = inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3817 found_tag = FALSE; /* have a proc name; check if extern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818 get_tagname = FALSE; /* have found "procedure" keyword */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 inparms = FALSE; /* found '(' after "proc" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 verify_tag = FALSE; /* check if "extern" is ahead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3822
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3823 while (!feof (inf)) /* long main loop to get next char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3825 c = *dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3826 if (c == '\0') /* if end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3828 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3829 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3830 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3832 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3833 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 if (!((found_tag && verify_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3835 || get_tagname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 c = *dbp++; /* only if don't need *dbp pointing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3837 to the beginning of the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3838 the procedure or function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3839 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3840 if (incomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3841 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3842 if (c == '}') /* within { } comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3843 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3844 else if (c == '*' && *dbp == ')') /* within (* *) comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3846 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3847 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3848 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3849 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3851 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3852 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3853 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3854 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3855 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3856 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3857 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3858 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3860 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3861 inquote = TRUE; /* found first quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3862 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3863 case '{': /* found open { comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3864 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3865 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3866 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3867 if (*dbp == '*') /* found open (* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3868 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3869 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3870 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3872 else if (found_tag) /* found '(' after tag, i.e., parm-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3873 inparms = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3874 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3875 case ')': /* end of parms list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3876 if (inparms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3877 inparms = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3878 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3879 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3880 if (found_tag && !inparms) /* end of proc or fn stmt */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3881 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3882 verify_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3883 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3884 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 if (found_tag && verify_tag && (*dbp != ' '))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 /* check if this is an "extern" declaration */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892 if (lowcase (*dbp == 'e'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3893 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3894 if (tail ("extern")) /* superfluous, really! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3895 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3897 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3899 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 else if (lowcase (*dbp) == 'f')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3902 if (tail ("forward")) /* check for forward reference */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3907 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 if (found_tag && verify_tag) /* not external proc, so make tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 pfnote (namebuf, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 tline.buffer, save_len, save_lineno, save_lcno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3915 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3916 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3917 if (get_tagname) /* grab name of proc or fn */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 /* save all values for later tagging */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923 grow_linebuffer (&tline, lb.len + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 strcpy (tline.buffer, lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 save_lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 save_lcno = linecharno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 /* grab block name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 namebuf = (CTAGS) ? savenstr (dbp, cp-dbp) : NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 dbp = cp; /* set dbp to e-o-token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 save_len = dbp - lb.buffer + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 get_tagname = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 found_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938 /* and proceed to check for "extern" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 else if (!incomment && !inquote && !found_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942 /* check for proc/fn keywords */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 switch (lowcase (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3950 if (tail ("unction"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3953 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3954 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3955 } /* while not eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 free (tline.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3959
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3960 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3961 * lisp tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3962 * look for (def or (DEF, quote or QUOTE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3963 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3964 int L_isdef PP ((char *strp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3965 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3966 L_isdef (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3967 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3968 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3969 return ((strp[1] == 'd' || strp[1] == 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 && (strp[2] == 'e' || strp[2] == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3971 && (strp[3] == 'f' || strp[3] == 'F'));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 int L_isquote PP ((char *strp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3975 L_isquote (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3976 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3977 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3978 return ((*++strp == 'q' || *strp == 'Q')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979 && (*++strp == 'u' || *strp == 'U')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980 && (*++strp == 'o' || *strp == 'O')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3981 && (*++strp == 't' || *strp == 'T')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3982 && (*++strp == 'e' || *strp == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3983 && isspace (*++strp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3984 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3985
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3986 void L_getit PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3987 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3988 L_getit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3989 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3990 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3991
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3992 if (*dbp == '\'') /* Skip prefix quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3993 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3994 else if (*dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3995 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3996 if (L_isquote (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3997 dbp += 7; /* Skip "(quote " */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3998 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3999 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4000 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4001 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4002
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4003 for (cp = dbp /*+1*/;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4004 *cp != '\0' && *cp != '(' && *cp != ' ' && *cp != ')';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4005 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4006 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4007 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4008 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4009
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4010 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4011 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4012 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4013
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4014 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4015 Lisp_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4016 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4017 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4018 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4019 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4020 if (dbp[0] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4021 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4022 if (L_isdef (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4023 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4024 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4025 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4026 L_getit ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4027 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4030 /* Check for (foo::defmumble name-defined ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4031 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4032 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4033 while (*dbp != '\0' && !isspace (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4034 && *dbp != ':' && *dbp != '(' && *dbp != ')');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4035 if (*dbp == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4036 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4037 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4038 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4039 while (*dbp == ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4041 if (L_isdef (dbp - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4042 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4043 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4044 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4045 L_getit ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4047 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4048 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4049 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4050 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4051 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4052
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4053 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4054 * Postscript tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4055 * Just look for lines where the first character is '/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4056 * Richard Mlynarik <mly@adoc.xerox.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4057 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4058 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4059 Postscript_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4060 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4061 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4062 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4063
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4064 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4065 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4066 if (bp[0] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4067 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4068 for (ep = bp+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4069 *ep != '\0' && *ep != ' ' && *ep != '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4070 ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4071 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4072 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4073 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4074 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4076 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4077
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4078
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4079 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4080 * Scheme tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4081 * look for (def... xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4082 * look for (def... (xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4083 * look for (def ... ((...(xyzzy ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4084 * look for (set! xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4085 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4086
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4087 void get_scheme PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4088
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4089 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4090 Scheme_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4091 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4092 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4093 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4094 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4095 if (dbp[0] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4096 && (dbp[1] == 'D' || dbp[1] == 'd')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4097 && (dbp[2] == 'E' || dbp[2] == 'e')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4098 && (dbp[3] == 'F' || dbp[3] == 'f'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4099 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4100 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4101 /* Skip over open parens and white space */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4102 while (isspace (*dbp) || *dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4103 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4104 get_scheme ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4105 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4106 if (dbp[0] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4107 && (dbp[1] == 'S' || dbp[1] == 's')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4108 && (dbp[2] == 'E' || dbp[2] == 'e')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4109 && (dbp[3] == 'T' || dbp[3] == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4110 && (dbp[4] == '!' || dbp[4] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4111 && (isspace (dbp[5])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4112 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4113 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4114 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4115 get_scheme ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4116 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4118 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4119
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4120 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4121 get_scheme ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4122 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4123 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4125 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4126 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4127 /* Go till you get to white space or a syntactic break */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4128 for (cp = dbp + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4129 *cp != '\0' && *cp != '(' && *cp != ')' && !isspace (*cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4130 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4131 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4132 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4133 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4136 /* Find tags in TeX and LaTeX input files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138 /* TEX_toktab is a table of TeX control sequences that define tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4139 Each TEX_tabent records one such control sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4140 CONVERT THIS TO USE THE Stab TYPE!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141 struct TEX_tabent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4142 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4143 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4144 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4145 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4146
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4147 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149 /* Default set of control sequences to put into TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4150 The value of environment var TEXTAGS is prepended to this. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4152 char *TEX_defenv = "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4153 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4154 :part:appendix:entry:index";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4156 void TEX_mode PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4157 struct TEX_tabent *TEX_decode_env PP ((char *evarname, char *defenv));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4158 int TEX_Token PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4160 char TEX_esc = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4161 char TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4162 char TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4164 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4165 * TeX/LaTeX scanning loop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4166 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4167 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4168 TeX_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4169 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4170 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4171 char *cp, *lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4172 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4174 /* Select either \ or ! as escape character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4175 TEX_mode (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4176
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4177 /* Initialize token table once from environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4178 if (!TEX_toktab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4179 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4181 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4182 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4183 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4184 /* Look at each esc in line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4185 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4186 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4187 if (*++cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4188 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4189 linecharno += cp - lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4190 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4191 i = TEX_Token (lasthit);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4192 if (i >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4194 /* We seem to include the TeX command in the tag name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4195 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4196 for (p = lasthit + TEX_toktab[i].len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4197 *p != '\0' && *p != TEX_clgrp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4198 p++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4199 continue; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4200 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4201 lb.buffer, lb.len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4202 break; /* We only tag a line once */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4203 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4204 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4205 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4206 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4208 #define TEX_LESC '\\'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4209 #define TEX_SESC '!'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 #define TEX_cmt '%'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4212 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4213 chars accordingly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4214 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 TEX_mode (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4216 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218 int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220 while ((c = getc (inf)) != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 /* Skip to next line if we hit the TeX comment char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4223 if (c == TEX_cmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 while (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 c = getc (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 else if (c == TEX_LESC || c == TEX_SESC )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4227 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4228 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4229
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4230 if (c == TEX_LESC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4231 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4232 TEX_esc = TEX_LESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4233 TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4234 TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4235 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4236 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4238 TEX_esc = TEX_SESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4239 TEX_opgrp = '<';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4240 TEX_clgrp = '>';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4241 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4242 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4243 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4245 /* Read environment and prepend it to the default string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4246 Build token table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4247 struct TEX_tabent *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4248 TEX_decode_env (evarname, defenv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4249 char *evarname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4250 char *defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4251 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4252 register char *env, *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4254 struct TEX_tabent *tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4255 int size, i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257 /* Append default string to environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4258 env = getenv (evarname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4259 if (!env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4260 env = defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4261 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4262 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263 char *oldenv = env;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 env = concat (oldenv, defenv, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4265 free (oldenv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4266 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4267
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4268 /* Allocate a token table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 for (size = 1, p = env; p;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 if ((p = etags_strchr (p, ':')) && *++p != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271 size++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4272 /* Add 1 to leave room for null terminator. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4273 tab = xnew (size + 1, struct TEX_tabent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4274
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4275 /* Unpack environment string into token table. Be careful about */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4276 /* zero-length strings (leading ':', "::" and trailing ':') */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4277 for (i = 0; *env;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4278 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4279 p = etags_strchr (env, ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4280 if (!p) /* End of environment string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4281 p = env + strlen (env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4282 if (p - env > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4283 { /* Only non-zero strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4284 tab[i].name = savenstr (env, p - env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4285 tab[i].len = strlen (tab[i].name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4286 i++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4288 if (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4289 env = p + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4290 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4291 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4292 tab[i].name = NULL; /* Mark end of table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4293 tab[i].len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4294 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4295 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4296 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4297 return tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4300 /* If the text at CP matches one of the tag-defining TeX command names,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4301 return the pointer to the first occurrence of that command in TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4302 Otherwise return -1.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4303 Keep the capital `T' in `token' for dumb truncating compilers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4304 (this distinguishes it from `TEX_toktab' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4305 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4306 TEX_Token (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4307 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4308 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4309 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4311 for (i = 0; TEX_toktab[i].len > 0; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4312 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4313 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4314 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4315 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4316
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4317 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4318 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4319 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4320 * Assumes that the predicate starts at column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321 * Only the first clause of a predicate is added.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4322 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4323 int prolog_pred PP ((char *s, char *last));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4324 void prolog_skip_comment PP ((linebuffer *plb, FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4325 int prolog_atom PP ((char *s, int pos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4327 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4328 Prolog_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4329 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4331 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4332 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4333 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4335 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4336 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4337 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4339 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4340 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4341 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4342 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4343 else if (isspace (cp[0])) /* Not a predicate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4344 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4345 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4346 prolog_skip_comment (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4347 else if ((len = prolog_pred (cp, last)) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4348 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4349 /* Predicate. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4350 generate a tag for the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4351 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4352 last = xnew(len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4353 else if (len + 1 > allocated)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4354 last = xrnew (last, len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4355 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4356 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4357 last[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4358 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4359 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4360 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4361
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4363 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4364 prolog_skip_comment (plb, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4365 linebuffer *plb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4366 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4367 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4368 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4370 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4371 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4372 for (cp = plb->buffer; *cp != '\0'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4373 if (cp[0] == '*' && cp[1] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4374 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4375 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4376 linecharno += readline (plb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4377 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4378 while (!feof(inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4379 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4380
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4381 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4382 * A predicate definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4383 * <beginning of line><Prolog Atom><whitespace>(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4384 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4385 * It is added to the tags database if it doesn't match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4386 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4387 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4388 * Return the size of the name of the predicate, or 0 if no header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4389 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4390 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4391 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4392 prolog_pred (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4393 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4394 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4396 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4397 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4399 pos = prolog_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4400 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4401 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4402
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4403 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4404 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4406 if ((s[pos] == '(') || (s[pos] == '.'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4408 if (s[pos] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4409 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4411 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4412 if (last == NULL
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
4413 || len != (int) strlen (last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4414 || !strneq (s, last, len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4415 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4416 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4417 s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4418 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4419 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4420 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4421 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4422 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4424 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4425 * Consume a Prolog atom.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4426 * Return the number of bytes consumed, or -1 if there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4427 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4428 * A prolog atom, in this context, could be one of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4429 * - An alphanumeric sequence, starting with a lower case letter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4430 * - A quoted arbitrary string. Single quotes can escape themselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4431 * Backslash quotes everything.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4432 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4433 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4434 prolog_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4435 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4436 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4437 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4438 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4440 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4441
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4442 if (islower(s[pos]) || (s[pos] == '_'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4443 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4444 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4445 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4446 while (isalnum(s[pos]) || (s[pos] == '_'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4447 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4448 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4449 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4450 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4451 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4452 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4454 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4456 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4457 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4458 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4459 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4460 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4461 if (s[pos] != '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4462 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4463 pos++; /* A double quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4465 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4466 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4467 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4468 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4469 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4470 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4471 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4472 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4473 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4474 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4475 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4476 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4477 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4478 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4479 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4480 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4481 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4483 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4484 * Support for Erlang -- Anders Lindgren, Feb 1996.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4485 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4486 * Generates tags for functions, defines, and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4487 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4488 * Assumes that Erlang functions start at column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4489 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4490 int erlang_func PP ((char *s, char *last));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4491 void erlang_attribute PP ((char *s));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4492 int erlang_atom PP ((char *s, int pos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4494 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4495 Erlang_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4496 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4498 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4499 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4500 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4502 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4503 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4504 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4506 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4508 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4509 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4510 else if (isspace (cp[0])) /* Not function nor attribute */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4511 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4512 else if (cp[0] == '%') /* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4513 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4514 else if (cp[0] == '"') /* Sometimes, strings start in column one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4515 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4516 else if (cp[0] == '-') /* attribute, e.g. "-define" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4517 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4518 erlang_attribute (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4519 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4520 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4521 else if ((len = erlang_func (cp, last)) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4522 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4523 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4524 * Function. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4525 * generates a tag for the first clause.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4526 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4527 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4528 last = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4529 else if (len + 1 > allocated)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4530 last = xrnew (last, len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4531 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4532 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4533 last[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4534 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4535 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4536 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4538
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4539 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4540 * A function definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4541 * <beginning of line><Erlang Atom><whitespace>(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4542 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4543 * It is added to the tags database if it doesn't match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4544 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4545 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4546 * Return the size of the name of the function, or 0 if no function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4547 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4548 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4549 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4550 erlang_func (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4551 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4552 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4553 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4554 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4555 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4557 pos = erlang_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4558 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4559 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4560
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4561 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4562 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4563
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4564 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4565 if (s[pos++] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4566 && (last == NULL
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
4567 || len != (int) strlen (last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4568 || !strneq (s, last, len)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4569 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4570 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4571 s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4572 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4573 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4575 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4579 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4580 * Handle attributes. Currently, tags are generated for defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4581 * and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4582 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4583 * They are on the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4584 * -define(foo, bar).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4585 * -define(Foo(M, N), M+N).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4586 * -record(graph, {vtab = notable, cyclic = true}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4587 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4588 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4589 erlang_attribute (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4590 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4591 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4592 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4593 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4595 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4596 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4597 pos = skip_spaces (s + 7) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4598 if (s[pos++] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4599 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4600 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4601 len = erlang_atom (s, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4602 if (len != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4603 pfnote ((CTAGS) ? savenstr (& s[pos], len) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4604 s, pos + len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4607 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4611 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4612 * Consume an Erlang atom (or variable).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4613 * Return the number of bytes consumed, or -1 if there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4614 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4615 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4616 erlang_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4617 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4618 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4619 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4620 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4622 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4624 if (isalpha (s[pos]) || s[pos] == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4625 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4626 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4627 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4628 while (isalnum (s[pos]) || s[pos] == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4629 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4630 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4631 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4632 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4633 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4634 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4636 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4637 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4638 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4639 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4640 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4641 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4642 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4643 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4644 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4645 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4646 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4647 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4648 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4649 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4650 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4651 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4652 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4653 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4654 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4655 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4656 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4658 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4659 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4661 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4662
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4663 /* Take a string like "/blah/" and turn it into "blah", making sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4664 that the first and last characters are the same, and handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4665 quoted separator characters. Actually, stops on the occurrence of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4666 an unquoted separator. Also turns "\t" into a Tab character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4667 Returns pointer to terminating separator. Works in place. Null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4668 terminates name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4669 char * scan_separators PP ((char *name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4670 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4671 scan_separators (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4672 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4673 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4674 char sep = name[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4675 char *copyto = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4676 bool quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4678 for (++name; *name != '\0'; ++name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4679 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4680 if (quoted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4681 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4682 if (*name == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4683 *copyto++ = '\t';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4684 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4685 *copyto++ = sep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4686 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4687 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4688 /* Something else is quoted, so preserve the quote. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4689 *copyto++ = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4690 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4691 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4692 quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4693 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4694 else if (*name == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4695 quoted = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4696 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4697 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4698 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4699 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4702 /* Terminate copied string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4703 *copyto = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4704 return name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4705 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4706
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4707 /* Look at the argument of --regex or --no-regex and do the right
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4708 thing. Same for each line of a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4709 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4710 analyse_regex (regex_arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4711 char *regex_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4712 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4713 if (regex_arg == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4714 free_patterns (); /* --no-regex: remove existing regexps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4715
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4716 /* A real --regexp option or a line in a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4717 switch (regex_arg[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4719 /* Comments in regexp file or null arg to --regex. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4720 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4721 case ' ':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4722 case '\t':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4723 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4725 /* Read a regex file. This is recursive and may result in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4726 loop, which will stop when the file descriptors are exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4727 case '@':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4728 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4729 FILE *regexfp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4730 linebuffer regexbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4731 char *regexfile = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4732
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4733 /* regexfile is a file containing regexps, one per line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4734 regexfp = fopen (regexfile, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4735 if (regexfp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4736 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4737 pfatal (regexfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4738 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4739 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4740 initbuffer (&regexbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4741 while (readline_internal (&regexbuf, regexfp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4742 analyse_regex (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4743 free (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4744 fclose (regexfp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4745 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4746 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4747
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4748 /* Regexp to be used for a specific language only. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4749 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4750 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4751 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4752 char *lang_name = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4753 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4755 for (cp = lang_name; *cp != '}'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4756 if (*cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4758 error ("unterminated language name in regex: %s", regex_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4759 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4760 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4761 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4762 lang = get_language_from_name (lang_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4763 if (lang == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4764 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4765 add_regex (cp + 1, lang);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4766 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4767 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4768
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4769 /* Regexp to be used for any language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4770 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4771 add_regex (regex_arg, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4772 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4773 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4776 /* Turn a name, which is an ed-style (but Emacs syntax) regular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4777 expression, into a real regular expression by compiling it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4778 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4779 add_regex (regexp_pattern, lang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4780 char *regexp_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4781 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4782 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4783 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4784 const char *err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4785 struct re_pattern_buffer *patbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4786 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4787
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4788
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4789 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4790 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4791 error ("%s: unterminated regexp", regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4792 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4793 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4794 name = scan_separators (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4795 if (regexp_pattern[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4796 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4797 error ("null regexp", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4798 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4799 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4800 (void) scan_separators (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4802 patbuf = xnew (1, struct re_pattern_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4803 patbuf->translate = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4804 patbuf->fastmap = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4805 patbuf->buffer = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4806 patbuf->allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4807
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4808 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4809 if (err != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4810 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4811 error ("%s while compiling pattern", err);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4812 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4813 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4815 pp = p_head;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4816 p_head = xnew (1, pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4817 p_head->regex = savestr (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4818 p_head->p_next = pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4819 p_head->language = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4820 p_head->pattern = patbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4821 p_head->name_pattern = savestr (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4822 p_head->error_signaled = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4823 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4824
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4825 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4826 * Do the substitutions indicated by the regular expression and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4827 * arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4828 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4829 char * substitute PP ((char *in, char *out, struct re_registers *regs));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4830 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4831 substitute (in, out, regs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4832 char *in, *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4833 struct re_registers *regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4834 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4835 char *result, *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4836 int size, dig, diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4837
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4838 result = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4839 size = strlen (out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4840
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4841 /* Pass 1: figure out how much to allocate by finding all \N strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4842 if (out[size - 1] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4843 fatal ("pattern error in \"%s\"", out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4844 for (t = etags_strchr (out, '\\');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4845 t != NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4846 t = etags_strchr (t + 2, '\\'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4847 if (isdigit (t[1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4848 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4849 dig = t[1] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4850 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4851 size += diglen - 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4852 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4853 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4854 size -= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4855
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4856 /* Allocate space and do the substitutions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4857 result = xnew (size + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4859 for (t = result; *out != '\0'; out++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4860 if (*out == '\\' && isdigit (*++out))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4861 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4862 /* Using "dig2" satisfies my debugger. Bleah. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4863 dig = *out - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4864 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4865 strncpy (t, in + regs->start[dig], diglen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4866 t += diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4867 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4868 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4869 *t++ = *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4870 *t = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4871
5820
b3824b7f5627 Some changes to eliminate warnings with Apple clang version 1.7.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5406
diff changeset
4872 if (DEBUG && (t > result + size || t - result != (int) (strlen (result))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4873 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4875 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4878 /* Deallocate all patterns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4879 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4880 free_patterns ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4881 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4882 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4883 while (p_head != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4884 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4885 pp = p_head->p_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4886 free (p_head->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4887 free (p_head->name_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4888 free (p_head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4889 p_head = pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4890 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4891 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4893
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4894 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4895 /* Initialize a linebuffer for use */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4896 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4897 initbuffer (lbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4898 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4899 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4900 lbp->size = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4901 lbp->buffer = xnew (200, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4902 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4903
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4904 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4905 * Read a line of text from `stream' into `lbp', excluding the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4906 * newline or CR-NL, if any. Return the number of characters read from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4907 * `stream', which is the length of the line including the newline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4908 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4909 * On DOS or Windows we do not count the CR character, if any, before the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4910 * NL, in the returned length; this mirrors the behavior of emacs on those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4911 * platforms (for text files, it translates CR-NL to NL as it reads in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4912 * file).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4913 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4914 long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4915 readline_internal (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4916 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4917 register FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4918 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4919 char *buffer = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4920 register char *p = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4921 register char *pend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4922 int chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4923
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4924 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4926 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4928 register int c = getc (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4929 if (p == pend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4930 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4931 /* We're at the end of linebuffer: expand it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4932 lbp->size *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4933 buffer = xrnew (buffer, lbp->size, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4934 p += buffer - lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4935 pend = buffer + lbp->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4936 lbp->buffer = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4937 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4938 if (c == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4940 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4941 chars_deleted = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4942 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4943 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4944 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4945 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4946 if (p > buffer && p[-1] == '\r')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4947 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4948 p -= 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4949 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4950 /* Assume CRLF->LF translation will be performed by Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4951 when loading this file, so CRs won't appear in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4952 It would be cleaner to compensate within Emacs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4953 however, Emacs does not know how many CRs were deleted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4954 before any given point in the file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4955 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4956 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4957 chars_deleted = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4958 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4959 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4960 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4962 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4963 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4964 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4965 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4966 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4967 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4968 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4969 lbp->len = p - buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4970
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4971 return lbp->len + chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4973
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4974 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4975 * Like readline_internal, above, but in addition try to match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4976 * input line against relevant regular expressions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4977 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4978 long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4979 readline (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4980 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4981 FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4982 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4983 /* Read new line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4984 long result = readline_internal (lbp, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4985 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4986 int match;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4987 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4988
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4989 /* Match against relevant patterns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4990 if (lbp->len > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4991 for (pp = p_head; pp != NULL; pp = pp->p_next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4992 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4993 /* Only use generic regexps or those for the current language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4994 if (pp->language != NULL && pp->language != curlang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4995 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4997 match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4998 switch (match)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4999 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5000 case -2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5001 /* Some error. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5002 if (!pp->error_signaled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5003 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5004 error ("error while matching \"%s\"", pp->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5005 pp->error_signaled = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5006 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5007 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5008 case -1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5009 /* No match. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5010 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5011 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5012 /* Match occurred. Construct a tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5013 if (pp->name_pattern[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5014 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5015 /* Make a named tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5016 char *name = substitute (lbp->buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5017 pp->name_pattern, &pp->regs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5018 if (name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5019 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5020 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5021 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5023 /* Make an unnamed tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5024 pfnote ((char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5025 lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5026 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5027 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5029 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5030 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5031
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5032 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5033 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5034
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5035 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5036 * Return a pointer to a space of size strlen(cp)+1 allocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5037 * with xnew where the string CP has been copied.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5038 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5039 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5040 savestr (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5041 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5042 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5043 return savenstr (cp, strlen (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5044 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5045
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5046 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5047 * Return a pointer to a space of size LEN+1 allocated with xnew where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5048 * the string CP has been copied for at most the first LEN characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5049 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5050 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5051 savenstr (cp, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5052 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5053 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5054 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5055 register char *dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5056
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5057 dp = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5058 strncpy (dp, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5059 dp[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5060 return dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5062
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5063 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5064 * Return the ptr in sp at which the character c last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5065 * appears; NULL if not found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5066 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5067 * Identical to System V strrchr, included for portability.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5068 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5069 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5070 etags_strrchr (sp, c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5071 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5072 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5073 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5074 register char *r;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5075
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5076 r = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5077 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5078 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5079 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5080 r = sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5081 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5082 return r;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5083 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5084
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5085
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5086 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5087 * Return the ptr in sp at which the character c first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5088 * appears; NULL if not found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5089 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5090 * Identical to System V strchr, included for portability.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5091 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5092 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5093 etags_strchr (sp, c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5094 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5095 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5096 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5097 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5098 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5099 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5100 return sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5101 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5102 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5103 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5105 /* Skip spaces, return new pointer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5106 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5107 skip_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5108 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5109 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5110 while (isspace (*cp)) /* isspace('\0')==FALSE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5111 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5112 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5113 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5114
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5115 /* Skip non spaces, return new pointer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5116 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5117 skip_non_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5118 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5119 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5120 while (!iswhite (*cp)) /* iswhite('\0')==TRUE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5121 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5122 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5123 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5125 /* Print error message and exit. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5126 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5127 fatal (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5128 char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5129 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5130 error (s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5131 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5132 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5134 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5135 pfatal (s1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5136 char *s1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5138 perror (s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5139 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5140 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5141
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5142 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5143 suggest_asking_for_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5144 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5145 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5146 progname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5147 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5148 "--help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5149 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5150 "-h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5151 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5152 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5153 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5154 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5156 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5157 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5158 error (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5159 const char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5160 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5161 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5162 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5163 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5165
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5166 /* Return a newly-allocated string whose contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5167 concatenate those of s1, s2, s3. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5168 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5169 concat (s1, s2, s3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5170 char *s1, *s2, *s3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5172 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5173 char *result = xnew (len1 + len2 + len3 + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5175 strcpy (result, s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5176 strcpy (result + len1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5177 strcpy (result + len1 + len2, s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5178 result[len1 + len2 + len3] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5179
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5180 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5181 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5183 /* Does the same work as the system V getcwd, but does not need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5184 guess the buffer size in advance. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5185 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5186 etags_getcwd ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5188 #ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5189 int bufsize = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5190 char *path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5192 while (getcwd (path, bufsize) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5194 if (errno != ERANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5195 pfatal ("getcwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5196 bufsize *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5197 free (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5198 path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5201 canonicalize_filename (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5202 return path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5204 #else /* not HAVE_GETCWD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5205 linebuffer path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5206 FILE *pipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5208 initbuffer (&path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5209 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5210 if (pipe == NULL || readline_internal (&path, pipe) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5211 pfatal ("pwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5212 pclose (pipe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5214 return path.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5215 #endif /* not HAVE_GETCWD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5218 /* Return a newly allocated string containing the file name of FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5219 relative to the absolute directory DIR (which should end with a slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5220 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5221 relative_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5222 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5224 char *fp, *dp, *afn, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5225 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5227 /* Find the common root of file and dir (with a trailing slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5228 afn = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5229 fp = afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5230 dp = dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5231 while (*fp++ == *dp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5232 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5233 fp--, dp--; /* back to the first differing char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5234 do /* look at the equal chars until '/' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5235 fp--, dp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5236 while (*fp != '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5237
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5238 /* Build a sequence of "../" strings for the resulting relative file name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5239 i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5240 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5241 i += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5242 res = xnew (3*i + strlen (fp + 1) + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5243 res[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5244 while (i-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5245 strcat (res, "../");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5246
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5247 /* Add the file name relative to the common root of file and dir. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5248 strcat (res, fp + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5249 free (afn);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5251 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5254 /* Return a newly allocated string containing the absolute file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5255 of FILE given DIR (which should end with a slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5256 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5257 absolute_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5258 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5259 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5260 char *slashp, *cp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5262 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5263 res = savestr (file);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5264 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5265 /* We don't support non-absolute file names with a drive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5266 letter, like `d:NAME' (it's too much hassle). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5267 else if (file[1] == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5268 fatal ("%s: relative file names with drive letters not supported", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5269 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5270 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5271 res = concat (dir, file, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5273 /* Delete the "/dirname/.." and "/." substrings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5274 slashp = etags_strchr (res, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5275 while (slashp != NULL && slashp[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5276 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5277 if (slashp[1] == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5278 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5279 if (slashp[2] == '.'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5280 && (slashp[3] == '/' || slashp[3] == '\0'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5281 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5282 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5283 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5284 cp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5285 while (cp >= res && !filename_is_absolute (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5286 if (cp < res)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5287 cp = slashp; /* the absolute name begins with "/.." */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5288 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5289 /* Under Windows we get `d:/NAME' as absolute
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5290 file name, so the luser could say `d:/../NAME'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5291 We silently treat this as `d:/NAME'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5292 else if (cp[0] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5293 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5294 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5295 strcpy (cp, slashp + 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5296 slashp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5297 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5299 else if (slashp[2] == '/' || slashp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5301 strcpy (slashp, slashp + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5302 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5303 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5304 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5306 slashp = etags_strchr (slashp + 1, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5307 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5309 if (res[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5310 return savestr ("/");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5311 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5312 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5313 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5315 /* Return a newly allocated string containing the absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5316 file name of dir where FILE resides given DIR (which should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5317 end with a slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5318 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5319 absolute_dirname (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5320 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5321 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5322 char *slashp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5323 char save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5324
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5325 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5326 slashp = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5327 if (slashp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5328 return savestr (dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5329 save = slashp[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5330 slashp[1] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5331 res = absolute_filename (file, dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5332 slashp[1] = save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5334 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5335 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5336
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5337 /* Whether the argument string is an absolute file name. The argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5338 string must have been canonicalized with canonicalize_filename. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5339 bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5340 filename_is_absolute (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5341 char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5342 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5343 return (fn[0] == '/'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5344 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5345 || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5346 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5347 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5350 /* Translate backslashes into slashes. Works in place. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5351 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5352 canonicalize_filename (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5353 register char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5354 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5355 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5356 for (; *fn != '\0'; fn++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5357 if (*fn == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5358 *fn = '/';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5359 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5360 /* No action. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5361 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5362 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5364 /* Increase the size of a linebuffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5365 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5366 grow_linebuffer (lbp, toksize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5367 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5368 int toksize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5369 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5370 while (lbp->size < toksize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5371 lbp->size *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5372 lbp->buffer = xrnew (lbp->buffer, lbp->size, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5373 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5375 /* Like malloc but get fatal error if memory is exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5376 long *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5377 xmalloc (size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5378 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5379 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5380 long *result = (long *) malloc (size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5381 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5382 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5383 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5384 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5385
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5386 long *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5387 xrealloc (ptr, size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5388 char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5389 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5390 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5391 long *result = (long *) realloc (ptr, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5392 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5393 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5394 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5395 }