annotate lib-src/ootags.c @ 4623:a9f83990e6bf

Fix a byte compiler bug with characters above ?\xFF. lisp/ChangeLog addition: 2009-02-22 Aidan Kehoe <kehoea@parhasard.net> * bytecomp.el (byte-compile-force-escape-quoted): New variable, used to force `byte-compile-insert-header' to treat the output as having characters above ?\xFF. (byte-compile-from-buffer): If the compiled output contains characters above ?\xFF, and byte-compile-dynamic-docstrings or byte-compile-dynamic is non-nil (or we're using an inappropriate coding system) recompile the file, turning off the dynamic features and using a more appropriate header. (byte-compile-insert-header): Pay attention to byte-compile-force-escape-quoted. tests/ChangeLog addition: 2009-02-22 Aidan Kehoe <kehoea@parhasard.net> * automated/mule-tests.el: Use more realistic tests for the escape-quoted mule encoding checks; update a comment, change a Known-Bug-Expect-Failure to a normal test now that we've addressed an old bug.
author Aidan Kehoe <kehoea@parhasard.net>
date Sun, 22 Feb 2009 19:57:28 +0000
parents b39c14581166
children 8b63e21b0436
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 (at your option) any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 GNU General Public License for more details.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with this program; if not, write to the Free Software Foundation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 * Authors:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 * Ctags originally by Ken Arnold.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * Fortran added by Jim Kleckner.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 * Ed Pelegri-Llopart added C typedefs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Gnu Emacs TAGS format and modifications by RMS?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 * Sam Kendall added C++.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 * Francesco Potorti` reorganised C and C++ based on work by Joe Wells.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 * Regexp tags by Tom Tromey.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 char pot_etags_version[] = "@(#) pot revision number is 12.28";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 /* Prototyping magic snarfed from gmalloc.c */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #if defined (__cplusplus) || defined (__STDC__)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #undef PP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 #define PP(args) args
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 #undef __ptr_t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 #define __ptr_t void *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 #else /* Not C++ or ANSI C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 #undef PP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 #define PP(args) ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45 #undef const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #define const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 #undef __ptr_t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #define __ptr_t char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 #endif /* C++ or ANSI C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 # include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 /* On some systems, Emacs defines static as nothing for the sake
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 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
55 # undef static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 # define ETAGS_REGEXPS /* use the regexp features */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 # define LONG_OPTIONS /* accept long options */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 #endif /* HAVE_CONFIG_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60 #define TRUE 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 #define FALSE 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 #ifndef DEBUG
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 # define DEBUG FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
67 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 # include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 # include <fcntl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 # include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 # include <io.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 # define MAXPATHLEN _MAX_PATH
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
73 # ifndef HAVE_CONFIG_H
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 # define HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 # endif /* not HAVE_CONFIG_H */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
76 #endif /* WIN32_NATIVE */
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
77
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
78 #if !defined (WIN32_NATIVE) && defined (STDC_HEADERS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 #include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 #include <string.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 # include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 # ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 extern char *getcwd ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 # endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 #endif /* HAVE_UNISTD_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 #include <errno.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 #include <sys/stat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 #if !defined (S_ISREG) && defined (S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 # include <getopt.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 extern char *optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 extern int optind, opterr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 # include <regex.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 /* Define CTAGS to make the program "ctags" compatible with the usual one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 Leave it undefined to make the program "etags", which makes emacs-style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 tag tables and tags typedefs, #defines and struct/union/enum by default. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 #ifdef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 # undef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 # define CTAGS TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 # define CTAGS FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 /* Exit codes for success and failure. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 # define GOOD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 # define BAD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 # define GOOD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 # define BAD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 /* C extensions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 #define C_PLPL 0x00001 /* C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 #define C_STAR 0x00003 /* C* */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 #define C_JAVA 0x00005 /* JAVA */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 #define YACC 0x10000 /* yacc file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 #define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 && (abort (), 1)) || !strcmp (s, t))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 && (abort (), 1)) || !strncmp (s, t, n))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 #define lowcase(c) tolower ((char)c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 #define CHARS 256 /* 2^sizeof(char) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 #define CHAR(x) ((unsigned int)x & (CHARS - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 /*#ifdef INFODOCK*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 /*#undef OO_BROWSER*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 /* Due to the way this file is constructed, this unfortunately doesn't */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 /* work except for documentation purposes. -slb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 #define OO_BROWSER 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 /*#endif*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 #define set_construct(construct) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 if (!oo_browser_construct) oo_browser_construct = construct
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
163 void oo_browser_clear_all_globals(void);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
164 void oo_browser_clear_some_globals(void);
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
165 void oo_browser_check_and_clear_structtype(void);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 #endif
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 * xnew, xrnew -- allocate, reallocate storage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 * SYNOPSIS: Type *xnew (int n, Type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 * Type *xrnew (OldPointer, int n, Type);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 #ifdef chkmalloc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 # include "chkmalloc.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 # define xrnew(op,n,Type) ((Type *) trace_realloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 (op), (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185 typedef int bool;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
187 typedef void Lang_function (FILE *);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 Lang_function *function;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 char **suffixes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 char **interpreters;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 } language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 typedef struct node_st
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 { /* sorting structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 char *name; /* function or type name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 short int construct; /* Construct type for the OO-Browser */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 char *file; /* file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 bool is_func; /* use pattern or line no */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 bool been_warned; /* set if noticed dup */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 int lno; /* line number tag is on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 long cno; /* character number line starts on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 char *pat; /* search pattern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 struct node_st *left, *right; /* left and right sons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 } node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 /* 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
214 following enum. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 static char *oo_browser_default_classes[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 /* Lack of square brackets around some of these entries are intentional. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 {"null", "class", "method", "[constant]", "[enumeration]", "[enum_label]",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 "extern", "[function]", "[macro]", "objc", "[structure]", "[type]",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 "[union]", "[variable]"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 /* 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
222 preceding array. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 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
224 C_ENUM_LABEL, C_EXTERN, C_FUNCTION, C_MACRO,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 C_OBJC, C_STRUCTURE, C_TYPE, C_UNION, C_VARIABLE};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 enum oo_browser_constructs oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 #endif
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 * A `linebuffer' is a structure which holds a line of text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 * `readline_internal' reads a line from a stream into a linebuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 * and works regardless of the length of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 * 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
235 * BUFFER after readline reads it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 long size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 } linebuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 extern char *getenv PP ((const char *envvar));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 /* Many compilers barf on this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 Lang_function Asm_labels;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 so let's write it this way */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 void Asm_labels PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 void C_entries PP ((int c_ext, FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 void default_C_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 void plain_C_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 void Cjava_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 void Cplusplus_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 void Yacc_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 void Cobol_paragraphs PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 void Cstar_entries PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 void Erlang_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 void Fortran_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 void Lisp_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 void Pascal_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 void Perl_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 void Postscript_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 void Prolog_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 void Python_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 void Scheme_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 void TeX_functions PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 void just_read_file PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 void print_language_names PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 void print_version PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 void print_help PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 language *get_language_from_name PP ((char *name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 language *get_language_from_interpreter PP ((char *interpreter));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 language *get_language_from_suffix PP ((char *suffix));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 int total_size_of_entries PP ((node *np));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 long readline PP ((linebuffer *lbp, FILE *stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 long readline_internal PP ((linebuffer *lbp, FILE *stream));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281 void analyse_regex PP ((char *regex_arg));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 void add_regex PP ((char *regexp_pattern, language *lang));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 void free_patterns PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 void error PP ((const char *s1, const char *s2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 void suggest_asking_for_help PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 void fatal PP ((char *s1, char *s2));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 void pfatal PP ((char *s1));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 void add_node PP ((node *np, node **cur_node_p));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 void init PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 void initbuffer PP ((linebuffer *lbp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 void find_entries PP ((char *file, FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 void free_tree PP ((node *np));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 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
296 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
297 void process_file PP ((char *file));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 void put_entries PP ((node *np));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 void takeprec PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 char *concat PP ((char *s1, char *s2, char *s3));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 char *skip_spaces PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 char *skip_non_spaces PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 char *savenstr PP ((char *cp, int len));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 char *savestr PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 char *etags_strchr PP ((char *sp, int c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 char *etags_strrchr PP ((char *sp, int c));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 char *etags_getcwd PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 char *relative_filename PP ((char *file, char *dir));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 char *absolute_filename PP ((char *file, char *dir));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 char *absolute_dirname PP ((char *file, char *dir));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 bool filename_is_absolute PP ((char *fn));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 void canonicalize_filename PP ((char *fn));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 void grow_linebuffer PP ((linebuffer *lbp, int toksize));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 long *xmalloc PP ((unsigned int size));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 long *xrealloc PP ((char *ptr, unsigned int size));
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 char searchar = '/'; /* use /.../ searches */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 char *tagfile; /* output file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 char *progname; /* name this program was invoked with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 char *cwd; /* current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 char *tagfiledir; /* directory of tagfile */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 FILE *tagf; /* ioptr for tags file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 char *curfile; /* current input file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 language *curlang; /* current language */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 int lineno; /* line number of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 long charno; /* current character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 long linecharno; /* charno of start of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 char *dbp; /* pointer to start of current tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 node *head; /* the head of the binary tree of tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 linebuffer lb; /* the current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 linebuffer token_name; /* used by C_entries as a temporary area */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 long linepos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 linebuffer lb; /* used by C_entries instead of lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 } lbs[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 /* boolean "functions" (see init) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 /* white chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 *white = " \f\t\n\r",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 /* not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 *nonam = " \f\t\n\r(=,[;",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 /* token ending chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 /* token starting chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 /* valid in-token chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 bool append_to_tagfile; /* -a: append to tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 /* 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
360 bool typedefs; /* -t: create tags for C typedefs */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 /* 0 struct/enum/union decls, and C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 /* member functions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 bool constantypedefs; /* -d: create tags for C #define, enum */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 /* constants and variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 /* -D: opposite of -d. Default under ctags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 bool globals; /* create tags for global variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 bool members; /* create tags for C member variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 bool update; /* -u: update tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 bool vgrind_style; /* -v: create vgrind style index output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 bool no_warnings; /* -w: suppress warnings */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 bool cxref_style; /* -x: create cxref style output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 bool cplusplus; /* .[hc] means C++, not C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 bool noindentypedefs; /* -I: ignore indentation in C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 bool oo_browser_format; /* -O: OO-Browser tags format */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 struct option longopts[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 { "append", no_argument, NULL, 'a' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 { "backward-search", no_argument, NULL, 'B' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 { "c++", no_argument, NULL, 'C' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 { "cxref", no_argument, NULL, 'x' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 { "defines", no_argument, NULL, 'd' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 { "no-defines", no_argument, NULL, 'D' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 { "globals", no_argument, &globals, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 { "no-globals", no_argument, &globals, FALSE },
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 { "help", no_argument, NULL, 'H' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 { "ignore-indentation", no_argument, NULL, 'I' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 { "include", required_argument, NULL, 'i' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 { "language", required_argument, NULL, 'l' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 { "members", no_argument, &members, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 { "no-members", no_argument, &members, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 { "no-warn", no_argument, NULL, 'w' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 { "output", required_argument, NULL, 'o' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 { "oo-browser", no_argument, NULL, 'O' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 { "regex", required_argument, NULL, 'r' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 { "no-regex", no_argument, NULL, 'R' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 { "typedefs", no_argument, NULL, 't' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 { "typedefs-and-c++", no_argument, NULL, 'T' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 { "update", no_argument, NULL, 'u' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 { "version", no_argument, NULL, 'V' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 { "vgrind", no_argument, NULL, 'v' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 { 0 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 /* Structure defining a regular expression. Elements are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 the compiled pattern, and the name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 typedef struct pattern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 struct pattern *p_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 language *language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 char *regex;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 struct re_pattern_buffer *pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 struct re_registers regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 char *name_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 bool error_signaled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 } pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 /* Array of all regexps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 pattern *p_head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 #endif /* ETAGS_REGEXPS */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 * Language stuff.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 /* Non-NULL if language fixed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 language *forced_lang = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 /* Assembly code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 char *Asm_suffixes [] = { "a", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 "asm", /* Microcontroller assembly */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 "def", /* BSO/Tasking definition includes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 "inc", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 "ins", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 "s", "sa", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 "src", /* BSO/Tasking C compiler output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 NULL
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 /* 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
452 given. That is why default_C_entries is called here. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 char *default_C_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 { "c", "h", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 char *Cplusplus_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 "M", /* Objective C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 "pdb", /* Postscript with C syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 char *Cjava_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 { "java", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 char *Cobol_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 { "COB", "cob", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 char *Cstar_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 { "cs", "hs", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 char *Erlang_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 { "erl", "hrl", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 char *Fortran_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 { "F", "f", "f90", "for", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477 char *Lisp_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 char *Pascal_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 { "p", "pas", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 char *Perl_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 { "pl", "pm", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 char *Perl_interpreters [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 { "perl", "@PERL@", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 char *plain_C_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 { "pc", /* Pro*C file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 "m", /* Objective C file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 "lm", /* Objective lex file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 char *Postscript_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 { "ps", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 char *Prolog_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 { "prolog", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 char *Python_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 { "py", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 /* Can't do the `SCM' or `scm' prefix with a version number. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 char *Scheme_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "ss", "t", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 char *TeX_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 { "TeX", "bib", "clo", "cls", "ltx", "sty", "tex", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 char *Yacc_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 { "y", "ym", NULL }; /* .ym is Objective yacc file */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 * Table of languages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 * 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
517 * name. I just didn't.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 language lang_names [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 { "asm", Asm_labels, Asm_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 { "c", default_C_entries, default_C_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 { "c*", Cstar_entries, Cstar_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 { "cobol", Cobol_paragraphs, Cobol_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 { "java", Cjava_entries, Cjava_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 { "proc", plain_C_entries, plain_C_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 { "python", Python_functions, Python_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 { "tex", TeX_functions, TeX_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 { "auto", NULL }, /* default guessing scheme */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 { "none", just_read_file }, /* regexp matching only */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 { NULL, NULL } /* end of list */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 print_language_names ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 char **ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 puts ("\nThese are the currently supported languages, along with the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 default file name suffixes:");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 printf ("\t%s\t", lang->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 printf (" .%s", *ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 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
563 name suffix, and `none' means only do regexp processing on files.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 If no language is specified and no matching suffix is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 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
566 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
567 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
568 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 #ifndef VERSION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 # define VERSION "20"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 print_version ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 printf ("%s (GNU Emacs %s)\n", (CTAGS) ? "ctags" : "etags", VERSION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 puts ("Copyright (C) 1996 Free Software Foundation, Inc. and Ken Arnold");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 puts ("This program is distributed under the same terms as Emacs");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 exit (GOOD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 print_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 These are the options accepted by %s.\n", progname, progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 puts ("You may use unambiguous abbreviations for the long option names.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 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
593 linked with GNU getopt.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 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
596 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 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
598 Relative ones are stored relative to the output file's directory.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 puts ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 puts ("-a, --append\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 Append tag entries to existing tags file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 puts ("-B, --backward-search\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 Write the search commands for the tag entries using '?', the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 backward-search command instead of '/', the forward-search command.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 puts ("-C, --c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 Treat files whose name suffix defaults to C language as C++ files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 puts ("-d, --defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 Create tag entries for C #define constants and enum constants, too.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 puts ("-D, --no-defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 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
618 This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 puts ("-i FILE, --include=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 Include a note in tag file indicating that, when searching for\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 a tag, one should also consult the tags file FILE after\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 checking the current file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 puts ("-l LANG, --language=LANG\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 Force the following files to be considered as written in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 named language up to the next --language=LANG option.");
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 puts ("--globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 Create tag entries for global variables in some languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 puts ("--no-globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 Do not create tag entries for global variables in some\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 languages. This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 puts ("--members\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 Create tag entries for member variables in C and derived languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 Make a tag for each line matching pattern REGEXP in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 following files. regexfile is a file containing one REGEXP\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 per line. REGEXP is anchored (as if preceded by ^).\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 named tags can be created with:\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 puts ("-R, --no-regex\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 Don't create tags from regexps for the following files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 puts ("-o FILE, --output=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 Write the tags to FILE.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 puts ("-O, --oo-browser\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 Generate a specialized tags format used only by the Altrasoft OO-Browser.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 puts ("-I, --ignore-indentation\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 Don't rely on indentation quite as much as normal. Currently,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 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
661 column is the final brace of a function or structure\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 definition in C and C++.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 puts ("-t, --typedefs\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 Generate tag entries for C typedefs.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 puts ("-T, --typedefs-and-c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 and C++ member functions.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 puts ("-u, --update\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 Update the tag entries for the given files, leaving tag\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 entries for other files in place. Currently, this is\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 implemented by deleting the existing entries for the given\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 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
676 tags file. It is often faster to simply rebuild the entire\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 tag file than to use this.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 puts ("-v, --vgrind\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 Generates an index of items intended for human consumption,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 similar to the output of vgrind. The index is sorted, and\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 gives the page number of each item.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 puts ("-w, --no-warn\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 Suppress warning messages about entries defined in multiple\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684 files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 puts ("-x, --cxref\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 The output uses line numbers instead of page numbers, but\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 beyond that the differences are cosmetic; try both to see\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 which you like.");
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 puts ("-V, --version\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 Print the version of the program.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 -h, --help\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 Print this help message.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 print_language_names ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 puts ("Report bugs to bug-gnu-emacs@prep.ai.mit.edu");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 exit (GOOD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 enum argument_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 at_language,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 at_regexp,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 at_filename
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 /* This structure helps us allow mixing of --lang and file names. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 enum argument_type arg_type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 char *what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 } argument;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 #ifdef VMS /* VMS specific functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 #define EOS '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 /* This is a BUG! ANY arbitrary limit is a BUG!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 Won't someone please fix this? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 #define MAX_FILE_SPEC_LEN 255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 typedef struct {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 short curlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 char body[MAX_FILE_SPEC_LEN + 1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 } vspec;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 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
735 returning in each successive call the next file name matching the input
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 spec. The function expects that each in_spec passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 to it will be processed to completion; in particular, up to and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 including the call following that in which the last matching name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 is returned, the function ignores the value of in_spec, and will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 only start processing a new spec with the following call.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 If an error occurs, on return out_spec contains the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 of in_spec when the error occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 With each successive file name returned in out_spec, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 function's return value is one. When there are no more matching
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 names the function returns zero. If on the first call no file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 matches in_spec, or there is any other error, -1 is returned.
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 #include <rmsdef.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 #include <descrip.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 #define OUTSIZE MAX_FILE_SPEC_LEN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 short
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 fn_exp (out, in)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 vspec *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 char *in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 static long context = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 static struct dsc$descriptor_s o;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 static struct dsc$descriptor_s i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 static bool pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 long status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 short retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 if (pass1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 pass1 = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 o.dsc$a_pointer = (char *) out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 o.dsc$w_length = (short)OUTSIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 i.dsc$a_pointer = in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 i.dsc$w_length = (short)strlen(in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 i.dsc$b_dtype = DSC$K_DTYPE_T;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 i.dsc$b_class = DSC$K_CLASS_S;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 o.dsc$b_dtype = DSC$K_DTYPE_VT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 o.dsc$b_class = DSC$K_CLASS_VS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 out->body[out->curlen] = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 else if (status == RMS$_NMF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 retval = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 strcpy(out->body, in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 retval = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 lib$find_file_end(&context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 return retval;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 name of each file specified by the provided arg expanding wildcards.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 gfnames (arg, p_error)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 char *arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 bool *p_error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 switch (fn_exp (&filename, arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 *p_error = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 return filename.body;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 #ifndef OLD /* Newer versions of VMS do provide `system'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 system (cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 char *cmd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 error ("%s", "system() function not implemented under VMS");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 #define VERSION_DELIM ';'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 char *massage_name (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 char *start = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 for ( ; *s; s++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 if (*s == VERSION_DELIM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 *s = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 *s = lowcase (*s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 return start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 #endif /* VMS */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 int
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
847 main (int argc, char *argv[])
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 unsigned int nincluded_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 char **included_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 char *this_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 argument *argbuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 int current_arg, file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 linebuffer filename_lb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 bool got_err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
860 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 _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
862 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 nincluded_files = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 included_files = xnew (argc, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 current_arg = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 file_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 /* Allocate enough no matter what happens. Overkill, but each one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 is small. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 argbuffer = xnew (argc, argument);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 /* Set syntax for regular expression routines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 #endif /* ETAGS_REGEXPS */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 * If etags, always find typedefs and structure tags. Why not?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 * Also default is to find macro constants, enum constants and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 * global variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 globals = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 members = FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 int opt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 char *optstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 optstring = "-aCdDf:Il:o:r:RStTi:BOuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 optstring = "-aCdDf:Il:o:StTi:BOuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 #ifndef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 optstring = optstring + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 opt = getopt_long (argc, argv, optstring, longopts, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 if (opt == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 switch (opt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 /* If getopt returns 0, then it has already processed a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 long-named option. We should do nothing. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 /* This means that a file name has been seen. Record it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 /* Common options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 case 'a': append_to_tagfile = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 case 'C': cplusplus = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 case 'd': constantypedefs = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 case 'D': constantypedefs = FALSE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 case 'f': /* for compatibility with old makefiles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 case 'o':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 if (tagfile)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 /* convert char to string, to call error with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 char buf[2];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 sprintf (buf, "%c", opt);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 error ("-%s option may only be given once.", buf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 tagfile = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 case 'O':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952 oo_browser_format = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 case 'I':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 case 'S': /* for backward compatibility */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 noindentypedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 language *lang = get_language_from_name (optarg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 if (lang != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964 argbuffer[current_arg].lang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 argbuffer[current_arg].arg_type = at_language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 ++current_arg;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 case 'R':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 argbuffer[current_arg].what = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982 case 'V':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 print_version ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 break;
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 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 print_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 typedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 typedefs = typedefs_and_cplusplus = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 #if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 /* Etags options */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 included_files[nincluded_files++] = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 #else /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 /* Ctags options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 case 'B': searchar = '?'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 case 'u': update = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 case 'x': cxref_style = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 case 'w': no_warnings = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 #endif /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 suggest_asking_for_help ();
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 for (; optind < argc; ++optind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 argbuffer[current_arg].what = argv[optind];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 ++file_count;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 if (nincluded_files == 0 && file_count == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 error ("no input files specified.", 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 suggest_asking_for_help ();
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 if (tagfile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 tagfile = CTAGS ? "tags" : "TAGS";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 cwd = etags_getcwd (); /* the current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 if (cwd[strlen (cwd) - 1] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 char *oldcwd = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 cwd = concat (oldcwd, "/", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 free (oldcwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 tagfiledir = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 tagfiledir = absolute_dirname (tagfile, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 init (); /* set up boolean "functions" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 initbuffer (&lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 initbuffer (&token_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 initbuffer (&lbs[0].lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 initbuffer (&lbs[1].lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 initbuffer (&filename_lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 tagf = stdout;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1054 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 /* Switch redirected `stdout' to binary mode (setting `_fmode'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 doesn't take effect until after `stdout' is already open). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 if (!isatty (fileno (stdout)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 setmode (fileno (stdout), O_BINARY);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1059 #endif /* WIN32_NATIVE */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 pfatal (tagfile);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 * Loop through files finding functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1069 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 switch (argbuffer[i].arg_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 case at_language:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 forced_lang = argbuffer[i].lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 case at_regexp:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 analyse_regex (argbuffer[i].what);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 case at_filename:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 if (got_err)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088 error ("can't find file %s\n", this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 argc--, argv++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 this_file = massage_name (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096 this_file = argbuffer[i].what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 oo_browser_clear_all_globals();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 /* Input file named "-" means read file names from stdin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102 (one per line) and use them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 if (streq (this_file, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 while (readline_internal (&filename_lb, stdin) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 oo_browser_clear_some_globals();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 process_file (filename_lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 process_file (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 free_patterns ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1127 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 while (nincluded_files-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 fprintf (tagf, "\f\n%s,include\n", *included_files++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1132 exit (GOOD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 /* 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
1136 because we want them ordered. Let's do it now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 exit (GOOD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 if (argbuffer[i].arg_type != at_filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 sprintf (cmd,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 tagfile, argbuffer[i].what, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 if (system (cmd) != GOOD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 fatal ("failed to execute shell command", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 append_to_tagfile = TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 exit (system (cmd));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 return GOOD;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 * Return a language given the name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 language *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 get_language_from_name (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 if (name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 error ("empty language name", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 if (streq (name, lang->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191 error ("unknown language \"%s\"", name);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 return NULL;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 * Return a language given the interpreter name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 language *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 get_language_from_interpreter (interpreter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 char *interpreter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 char **iname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 if (interpreter == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 if (lang->interpreters != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 for (iname = lang->interpreters; *iname != NULL; iname++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 if (streq (*iname, interpreter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 return NULL;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 * Return a language given the file suffix.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 language *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 get_language_from_suffix (suffix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226 char *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 char **ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 if (suffix == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 if (streq (*ext, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 return NULL;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244 * This routine is called on each file argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 process_file (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 struct stat stat_buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1251 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1253 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 error ("skipping %s: it is not a regular file.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 if (streq (file, tagfile) && !streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 error ("skipping inclusion of %s in self.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1262 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 inf = fopen (file, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 if (inf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 perror (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 find_entries (file, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1272
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1278 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1279 /* file is an absolute file name. Canonicalise it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 filename = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 /* file is a file name relative to cwd. Make it relative
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285 to the directory of the tags file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286 filename = relative_filename (file, tagfiledir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 if (oo_browser_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 fprintf (tagf, "\f\n%s\n", filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1291 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1292 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1293 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
1294 free (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 head = NULL;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 * This routine sets up the boolean pseudo-functions which work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 * by setting boolean flags dependent upon the corresponding character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 * 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
1305 * 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
1306 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 * 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
1308 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310 init ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 for (i = 0; i < CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 iswhite('\0') = iswhite('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 notinname('\0') = notinname('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 begtoken('\0') = begtoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 intoken('\0') = intoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 endtoken('\0') = endtoken('\n');
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 * This routine opens the specified file and calls the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331 * which finds the function and type definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333 node *last_node = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 find_entries (file, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1337 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1338 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1342 node *old_last_node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1343
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1344 curfile = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1346 /* If user specified a language, use it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1347 lang = forced_lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1348 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1349 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1350 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1351 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 cp = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 if (cp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 cp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 lang = get_language_from_suffix (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 /* Look for sharp-bang as the first two characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 if (readline_internal (&lb, inf) > 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 && lb.len >= 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 && lb.buffer[0] == '#'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 && lb.buffer[1] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378 char *lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 /* 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
1381 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
1382 the first successive blank and terminate the string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 lp = etags_strrchr (lb.buffer+2, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 if (lp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 lp = skip_spaces (lb.buffer + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 cp = skip_non_spaces (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 if (strlen (lp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 lang = get_language_from_interpreter (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 return;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 /* Try Fortran. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407 old_last_node = last_node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 curlang = get_language_from_name ("fortran");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 Fortran_functions (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 /* No Fortran entries found. Try C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 if (old_last_node == last_node)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 curlang = get_language_from_name (cplusplus ? "c++" : "c");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416 default_C_entries (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 free (curfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 /* Record a tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 pfnote (name, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1433 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1435 if (CTAGS && name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1436 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1438 np = xnew (1, node);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1439
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1440 /* If ctags mode, change name "main" to M<thisfilename>. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1441 if (CTAGS && !cxref_style && streq (name, "main"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1442 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1443 register char *fp = etags_strrchr (curfile, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1444 np->name = concat ("M", fp == 0 ? curfile : fp + 1, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1445 fp = etags_strrchr (np->name, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1446 if (fp && fp[1] != '\0' && fp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1447 fp[0] = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1448 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 np->name = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 np->been_warned = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 np->file = curfile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 np->is_func = is_func;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 np->lno = lno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 /* Our char numbers are 0-base, because of C language tradition?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 ctags compatibility? old versions compatibility? I don't know.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 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
1458 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
1459 uncomment the +1 below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 np->cno = cno /* + 1 */ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 np->left = np->right = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 if (CTAGS && !cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 if (strlen (linestart) < 50)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465 np->pat = concat (linestart, "$", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 np->pat = savenstr (linestart, 50);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 np->pat = savenstr (linestart, linelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 if (oo_browser_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1474 np->construct = oo_browser_construct;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 oo_browser_check_and_clear_structtype();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 add_node (np, &head);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 /* 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
1483 * From: Sam Kendall <kendall@mv.mv.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484 * Subject: Proposal for firming up the TAGS format specification
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 * To: F.Potorti@cnuce.cnr.it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 * pfnote should emit the optimized form [unnamed tag] only if:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 * 1. name does not contain any of the characters " \t\r\n(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 * 2. linestart contains name as either a rightmost, or rightmost but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 * one character, substring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491 * 3. the character, if any, immediately before name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 * be one of the characters " \t(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 * 4. the character, if any, immediately after name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 * also be one of the characters " \t(),;".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 * The real implementation uses the notinname() macro, which recognises
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 * characters slightly different form " \t\r\n(),;". See the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 * `nonam'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 #define traditional_tag_style TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 int namelen; /* tag length */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 bool named;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 for (cp = name; !notinname (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519 if (*cp == '\0') /* rule #1 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 cp = linestart + linelen - namelen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 if (notinname (linestart[linelen-1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 cp -= 1; /* rule #4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 if (!oo_browser_format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 && cp >= linestart /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1528 if (cp >= linestart /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 && (cp == linestart
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 || notinname (cp[-1])) /* rule #3 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 && strneq (name, cp, namelen)) /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533 named = FALSE; /* use unnamed tag */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 if (named)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1538 name = savenstr (name, namelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1540 name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 pfnote (name, is_func, linestart, linelen, lno, cno);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 * free_tree ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546 * recurse on left children, iterate on right children.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 free_tree (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552 while (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1553 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 register node *node_right = np->right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 free_tree (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 free (np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 free (np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 free (np);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 np = node_right;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 * add_node ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 * 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
1567 * it sorted; we just keep a linear list. In ctags mode, maintain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568 * an ordered tree, with no attempt at balancing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 * 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
1571 * maintain state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 add_node (np, cur_node_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 node *np, **cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577 register int dif;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 register node *cur_node = *cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 if (cur_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 *cur_node_p = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 /* Etags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 if (last_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 fatal ("internal error in add_node", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 last_node->right = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 /* Ctags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 dif = strcmp (np->name, cur_node->name);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 * If this tag name matches an existing one, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 * do not add the node, but maybe print a warning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 if (!dif)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 if (streq (np->file, cur_node->file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 if (!no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 np->file, lineno, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 fprintf (stderr, "Second entry ignored\n");
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 else if (!cur_node->been_warned && !no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 fprintf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 "Duplicate entry in files %s and %s: %s (Warning only)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 np->file, cur_node->file, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621 cur_node->been_warned = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626 /* Actually add the node */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 /* Default class name for the current OO-Browser tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1633 static char *oo_browser_class;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 /* Prefix character to use in OO-Browser listings for the current tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 static char oo_browser_prefix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1638 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1639 put_entries (node *np)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1641 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 /* Output subentries that precede this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 put_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 /* Output this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654 if (oo_browser_format)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656 /* Omit C++ `class' and `method' entries as well as Objective-C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 entries from this OO-Browser tags file since the browser handles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 them independently of this file. Omit `extern' variable declarations
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 as they are unused by the OO-Browser. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 if (np->construct != C_CLASS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 && np->construct != C_METHOD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 && np->construct != C_EXTERN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 && np->construct != C_OBJC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 oo_browser_class = oo_browser_default_classes[np->construct];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 switch (np->construct)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 case C_CONSTANT:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 case C_ENUMERATION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 case C_ENUM_LABEL:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 case C_STRUCTURE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 case C_TYPE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 case C_UNION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 case C_VARIABLE:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 oo_browser_prefix = '=';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 case C_FUNCTION:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 case C_MACRO:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 oo_browser_prefix = '-';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 fprintf (tagf, "%s@%c %s@%s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 oo_browser_class, oo_browser_prefix,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 np->name, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 fprintf (tagf, "%s@%c ???@%s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688 oo_browser_class, oo_browser_prefix, np->pat);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1692 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1693 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1694 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 fprintf (tagf, "%s\177%s\001%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 np->pat, np->name, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 fprintf (tagf, "%s\177%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 np->pat, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 if (np->name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 error ("internal error: NULL name in ctags mode.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1710 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 if (vgrind_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 fprintf (stdout, "%s %s %d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 np->name, np->file, (np->lno + 63) / 64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 fprintf (stdout, "%-16s %3d %-16s %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 np->name, np->lno, np->file, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 fprintf (tagf, "%s\t%s\t", np->name, np->file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722 if (np->is_func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 { /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 putc ('^', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 for (sp = np->pat; *sp; sp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 if (*sp == '\\' || *sp == searchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 putc ('\\', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 putc (*sp, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 { /* a typedef; text pattern inadequate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 fprintf (tagf, "%d", np->lno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 putc ('\n', tagf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 /* Output subentries that follow this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 put_entries (np->right);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747 /* Length of a number's decimal representation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 int number_len PP ((long num));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 number_len (num)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 long num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1752 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 int len = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 while ((num /= 10) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 len += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 return len;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 * Return total number of characters that put_entries will output for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 * the nodes in the subtree of the specified node. Works only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 * we are not ctags, but called only in that case. This count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 * is irrelevant with the new tags.el, but is still supplied for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 * backward compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767 total_size_of_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 register int total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 for (total = 0; np != NULL; np = np->right)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1777 /* Count left subentries. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 total += total_size_of_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 /* Count this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 total += strlen (np->pat) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 total += 1 + strlen (np->name); /* \001name */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 return total;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 * The C symbol tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 st_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 st_C_objprot, st_C_objimpl, st_C_objend,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 st_C_gnumacro,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 st_C_ignore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 st_C_javastruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 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
1801 st_C_const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803 , st_C_union, st_C_class, st_C_extern, st_C_inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 #endif
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 /* Feed stuff between (but not including) %[ and %] lines to:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 gperf -c -k 1,3 -o -p -r -t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 %[
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 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
1811 %%
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 @interface, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 @protocol, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 @implementation,0, st_C_objimpl
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 @end, 0, st_C_objend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 import, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 package, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 friend, C_PLPL, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 extends, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 implements, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 interface, C_JAVA, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 class, C_PLPL, st_C_class
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 namespace, C_PLPL, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 domain, C_STAR, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 union, 0, st_C_union
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 struct, 0, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 enum, 0, st_C_enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 typedef, 0, st_C_typedef
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829 define, 0, st_C_define
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 inline, 0, st_C_inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 bool, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 long, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 short, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1834 int, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835 char, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1836 float, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 double, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 signed, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 unsigned, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 auto, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841 void, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 extern, 0, st_C_extern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 static, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844 const, 0, st_C_const
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 volatile, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 explicit, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847 mutable, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 typename, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849 # 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
1850 DEFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 SYSCALL, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 ENTRY, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 PSEUDO, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 # These are defined inside C functions, so currently they are not met.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 # EXFUN used in glibc, DEFVAR_* in emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 #EXFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 #DEFVAR_, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 %]
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 and replace lines between %< and %> with its output. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 /*%<*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 /* C code produced by gperf version 2.5 (GNU C++ version) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863 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
1864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 #define TOTAL_KEYWORDS 41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 #define MIN_WORD_LENGTH 3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 #define MAX_WORD_LENGTH 15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 #define MIN_HASH_VALUE 13
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 #define MAX_HASH_VALUE 129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 /* maximum key range = 117, duplicates = 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 static unsigned int
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1873 hash (char *str, unsigned int len)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 static unsigned char asso_values[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876 {
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, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 130, 130, 130, 130, 13, 130, 130, 130, 33, 32,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 47, 130, 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 5, 130, 130, 20, 32, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 130, 130, 130, 130, 130, 130, 130, 47, 55, 8,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 15, 33, 61, 38, 130, 60, 130, 130, 2, 9,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 10, 62, 59, 130, 28, 27, 50, 19, 3, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 130, 130, 130, 130, 130, 130, 130, 130,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 };
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1891 return len +
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1892 asso_values[(unsigned char) str[2]] +
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1893 asso_values[(unsigned char) str[0]];
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1896 static struct C_stab_entry *
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
1897 in_word_set (char *str, unsigned int len)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 static struct C_stab_entry wordlist[] =
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 {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 {"volatile", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 {"long", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 {"const", 0, st_C_const},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 {"@end", 0, st_C_objend},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 {"namespace", C_PLPL, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912 {"domain", C_STAR, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 {"@interface", 0, st_C_objprot},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 {"@implementation", 0, st_C_objimpl},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 {"double", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1920 {"PSEUDO", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 {"SYSCALL", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 {"@protocol", 0, st_C_objprot},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 {"unsigned", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928 {"enum", 0, st_C_enum},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 {"char", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 {"class", C_PLPL, st_C_class},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 {"struct", 0, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933 {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 {"mutable", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 {"void", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 {"inline", 0, st_C_inline},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 {"ENTRY", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 {"signed", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 {"package", C_JAVA, st_C_ignore},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1943 {"static", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1945 {"define", 0, st_C_define},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1946 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1947 {"union", 0, st_C_union},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1948 {"DEFUN", 0, st_C_gnumacro},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1949 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1950 {"extern", 0, st_C_extern},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1951 {"extends", C_JAVA, st_C_javastruct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1952 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1953 {"short", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 {"",}, {"",}, {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 {"explicit", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 {"auto", 0, st_C_typespec},
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 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 {"int", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 {"typedef", 0, st_C_typedef},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 {"typename", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 {"interface", C_JAVA, st_C_struct},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1965 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 {"bool", C_PLPL, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 {"",}, {"",}, {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968 {"import", C_JAVA, st_C_ignore},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1969 {"",},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1970 {"friend", C_PLPL, st_C_ignore},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1971 {"float", 0, st_C_typespec},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1972 {"implements", C_JAVA, st_C_javastruct},
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 register int key = hash (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 if (key <= MAX_HASH_VALUE && key >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 register char *s = wordlist[key].name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 return &wordlist[key];
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 return 0;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 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
1992 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1993 C_symtype (str, len, c_ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 int c_ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 register struct C_stab_entry *se = in_word_set (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 return st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 return se->type;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 * C functions and variables are recognized using a simple
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 * finite automaton. fvdef is its state variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 fvnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 fvnameseen, /* function or variable name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 fstartlist, /* func: just after open parenthesis */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 finlist, /* func: in parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 flistseen, /* func: after parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 fignore, /* func: before open brace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 vignore /* var-like: ignore until ';' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 } fvdef;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 * typedefs are recognized using a simple finite automaton.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 * typdef is its state variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 tnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 ttypedseen, /* typedef keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 tinbody, /* inside typedef body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 tend, /* just before typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2031 tignore /* junk after typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2032 } typdef;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 * struct-like structures (enum, struct and union) are recognized
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037 * using another simple finite automaton. `structdef' is its state
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2038 * variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2041 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2042 snone, /* nothing seen yet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2043 skeyseen, /* struct-like keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044 stagseen, /* struct-like tag seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 scolonseen, /* colon seen after struct-like tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 sinbody /* in struct body: recognize member func defs*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 } structdef;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 * struct tag, and structtype is the type of the preceding struct-like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 * keyword.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 char *structtag = "<uninited>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2055 enum sym_type structtype;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2056
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2057 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2058 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
2059 oo_browser_check_and_clear_structtype(void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2060 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2061 /* Allow for multiple enum_label tags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2062 if (structtype != st_C_enum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2063 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2064 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2065 #endif
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2068 * 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
2069 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2070 char *objtag = "<uninited>";
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2073 * Yet another little state machine to deal with preprocessor lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2074 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2075 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2076 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2077 dnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2078 dsharpseen, /* '#' seen as first char on line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2079 ddefineseen, /* '#' and 'define' seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2080 dignorerest /* ignore rest of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 } definedef;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 * State machine for Objective C protocols and implementations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 * Tom R.Hageman <tom@basil.icce.rug.nl>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 onone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 oprotocol, /* @interface or @protocol seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 oimplementation, /* @implementations seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 otagseen, /* class name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 oparenseen, /* parenthesis before category seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 ocatseen, /* category name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 oinbody, /* in @implementation body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096 omethodsign, /* in @implementation body, after +/- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 omethodtag, /* after method name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 omethodcolon, /* after method colon */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 omethodparm, /* after method parameter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 oignore /* wait for @end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 } objdef;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 * 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
2105 * 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
2106 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2108 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2109 bool valid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2110 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2111 bool named;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 int linelen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2113 int lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2114 long linepos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2115 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2116 } token;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2117
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2118 token tok; /* latest token read */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2121 * 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
2122 * Used only for GNU emacs's function-defining macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2123 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2124 bool next_token_is_func;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2127 * 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
2128 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2129 bool yacc_rules;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2132 * methodlen is the length of the method name stored in token_name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2133 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2134 int methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2135
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2136 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2137 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
2138 oo_browser_clear_all_globals(void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 /* Initialize globals so there is no carry over between files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2142 fvdef = fvnone; typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2143 definedef = dnone; objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2144 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2145 next_token_is_func = yacc_rules = FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2148 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
2149 oo_browser_clear_some_globals(void)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2151 oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2152 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2153 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2154 #endif
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2157 * consider_token ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2158 * 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
2159 * function or variable, or corresponds to a typedef, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2160 * is a struct/union/enum tag, or #define, or an enum constant.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2161 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2162 * *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
2163 * with args. C_EXT is which language we are looking at.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2164 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2165 * 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
2166 * the token is; for instance, implementing the C++ keyword
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2167 * `operator' properly will adjust the end of the token to be after
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2168 * whatever follows `operator'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2170 * Globals
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2171 * fvdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2172 * structdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2173 * definedef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2174 * typdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2175 * objdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2176 * next_token_is_func IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2178 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
2179 int cblev, int parlev, bool *is_func_or_var));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2180 bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 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
2182 register char *str; /* IN: token pointer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 register int len; /* IN: token length */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 register int c; /* IN: first char after the token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 int c_ext; /* IN: C extensions mask */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186 int cblev; /* IN: curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 int parlev; /* IN: parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 bool *is_func_or_var; /* OUT: function or variable found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190 enum sym_type toktype = C_symtype (str, len, c_ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 set_construct(C_STRUCTURE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 set_construct(C_UNION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 case st_C_typedef:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2211 set_construct(C_EXTERN);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2213 case st_C_inline:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2214 set_construct(C_FUNCTION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2215 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2216 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 #endif
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2220 * Advance the definedef state machine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2221 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 /* We're not on a preprocessor line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 case dsharpseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 if (toktype == st_C_define)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230 definedef = ddefineseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2233 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2234 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2235 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2236 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237 case ddefineseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 * Make a tag for any macro, unless it is a constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 * and constantypedefs is FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 *is_func_or_var = (c == '(');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2247 char *p = str + len * sizeof(char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2248
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2249 if (*p == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2250 /* This must be a macro since there is no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2251 whitespace between the opening parenthesis
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 and the definition name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2254 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2255 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 *is_func_or_var = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2258 /* Handle possible whitespace between macro tag and opening
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2259 parenthesis and ensure this is an actual macro.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 -- Bob Weiner, Altrasoft, 11/19/1997 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261 while (*p && isspace(*p)) p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 if (*p) c = *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264 /* Skip over nested parentheses. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 if (c == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 short depth = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 while (*++p && depth > 0 && *p != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 switch (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 depth++; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 depth--; break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2280 /* If this is a macro, we have just passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 the arguments and there will be more on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 the line before the NULL character that marks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 the end of the line token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 while (*p == ' ' || *p == '\t') p++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 if (*p) *is_func_or_var = TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 set_construct((*is_func_or_var) ? C_MACRO : C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 if (!*is_func_or_var && !constantypedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 case dignorerest:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 error ("internal error: definedef value.", (char *)NULL);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2303 * Now typedefs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2307 case tnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2308 if (toktype == st_C_typedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310 if (typedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2311 typdef = ttypedseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2312 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2313 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2316 case ttypedseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2317 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2319 case st_C_const:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2320 set_construct(C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2321 /* fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2322 case st_none:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2323 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2324 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2325 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2326 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2327 typdef = tend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2328 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2329 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2330 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2331 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2332 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2333 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2334 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2335 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2336 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2337 /* Do not return here, so the structdef stuff has a chance. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2338 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2339 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2340 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2342 case st_C_const:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2343 set_construct(C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2344 /* fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2345 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2346 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2347 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2348 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2349 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2350 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2351 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2352 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2353 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2354 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2355 return TRUE;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2359 * This structdef business is currently only invoked when cblev==0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2360 * It should be recursively invoked whatever the curly brace level,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2361 * and a stack of states kept, to allow for definitions of structs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2362 * within structs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2363 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2364 * This structdef business is NOT invoked when we are ctags and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2365 * 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
2366 * name as another tag, and this loses with ctags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2367 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2368 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2369 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2370 case st_C_javastruct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2371 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2372 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2373 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2374 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2375 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2376 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2377 case st_C_union:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2378 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2379 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2380 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2381 if (typdef == ttypedseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2382 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2383 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2384 structdef = skeyseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2385 structtype = toktype;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2386 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2387 return FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2390 if (structdef == skeyseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2392 /* Save the tag for struct/union/class, for functions and variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2393 that may be defined inside. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2394 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2395 if (structtype == st_C_struct)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2396 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2397 if (structtype == st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2398 || structtype == st_C_union
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2399 || structtype == st_C_class)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2400 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2401 structtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2402 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2403 structtag = "<enum>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2404 structdef = stagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2405 return TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2408 /* Avoid entering fvdef stuff if typdef is going on. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2409 if (typdef != tnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2410 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2411 definedef = dnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2412 return FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 /* Detect GNU macros.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 DEFUN note for writers of emacs C code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 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
2419 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
2420 is a C function name. Since etags skips strings, the second arg
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 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
2422 first arg. The simplest way to deal with this problem would be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 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
2424 removing the initial 'F' character and substituting '-' for '_'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 Anyway, this assumes that the conventions of naming lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 functions will never change. Currently, this method is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 implemented, so writers of emacs code are recommended to put the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 first two args of a DEFUN on the same line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429 if (definedef == dnone && toktype == st_C_gnumacro)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2431 next_token_is_func = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2434 if (next_token_is_func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2435 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 next_token_is_func = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 return TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2442 /* Detect Objective C constructs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2443 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2445 case onone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2446 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2447 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2448 case st_C_objprot:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 set_construct(C_OBJC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452 objdef = oprotocol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 case st_C_objimpl:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 set_construct(C_OBJC);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2457 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2458 objdef = oimplementation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2459 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2460 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2461 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 case oimplementation:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 /* Save the class tag for functions or variables defined inside. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 case oprotocol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 /* Save the class tag for categories. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 objdef = otagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 case oparenseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 objdef = ocatseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 case oinbody:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 case omethodsign:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 objdef = omethodtag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 methodlen = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 grow_linebuffer (&token_name, methodlen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 strncpy (token_name.buffer, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 token_name.buffer[methodlen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 token_name.len = methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 case omethodcolon:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 objdef = omethodparm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 objdef = omethodtag;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 methodlen += len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500 grow_linebuffer (&token_name, methodlen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 strncat (token_name.buffer, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502 token_name.len = methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 case oignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 if (toktype == st_C_objend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 /* Memory leakage here: the string pointed by objtag is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2510 never released, because many tests would be needed to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 avoid breaking on incorrect input code. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2513 class tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514 free (objtag); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2516 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2517 return FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2520 /* A function, variable or enum constant? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2521 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2522 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2523 case st_C_const:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2524 set_construct(C_CONSTANT);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 /* fall through */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2526 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2528 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2529 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2530 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2531 fvdef = fvnone; /* should be useless */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2532 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 case st_C_ignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 case st_none:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 oo_browser_construct = C_ENUM_LABEL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2542 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2546 if (fvdef == fvnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2547 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2548 fvdef = fvnameseen; /* function or variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2549 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2550 return TRUE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2554 return FALSE;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2558 * C_entries ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2559 * This routine finds functions, variables, typedefs,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2560 * #define's, enum constants and struct/union/enum definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2561 * #C syntax and adds them to the list.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2562 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563 #define current_lb_is_new (newndx == curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564 #define switch_line_buffers() (curndx = 1 - curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2566 #define curlb (lbs[curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567 #define othlb (lbs[1-curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568 #define newlb (lbs[newndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2569 #define curlinepos (lbs[curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2570 #define othlinepos (lbs[1-curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2571 #define newlinepos (lbs[newndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2573 #define CNL_SAVE_DEFINEDEF() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2575 curlinepos = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2576 lineno++; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2577 linecharno = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2578 charno += readline (&curlb, inf); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2579 lp = curlb.buffer; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2580 quotednl = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581 newndx = curndx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2583
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 #define CNL() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2585 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2586 CNL_SAVE_DEFINEDEF(); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 if (savetok.valid) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2588 { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2589 tok = savetok; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2590 savetok.valid = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2591 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2592 definedef = dnone; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2593 } while (0)
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2596 void make_C_tag PP ((bool isfun));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2597 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 make_C_tag (isfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2599 bool isfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2600 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2601 /* This function should never be called when tok.valid is FALSE, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2602 we must protect against invalid input or internal errors. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2603 if (tok.valid)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2604 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2605 if (traditional_tag_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2606 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2607 /* This was the original code. Now we call new_pfnote instead,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 which uses the new method for naming tags (see new_pfnote). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609 char *name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2611 if (CTAGS || tok.named)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2612 name = savestr (token_name.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2613 pfnote (name, isfun,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2615 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2617 new_pfnote (token_name.buffer, token_name.len, isfun,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2618 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2619 tok.valid = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2620 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 else if (DEBUG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2622 abort ();
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2626 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2627 C_entries (c_ext, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2628 int c_ext; /* extension of C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2629 FILE *inf; /* input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2631 register char c; /* latest char read; '\0' for end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2632 register char *lp; /* pointer one beyond the character `c' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633 int curndx, newndx; /* indices for current and new lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 register int tokoff; /* offset in line of start of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 register int toklen; /* length of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 char *qualifier; /* string used to qualify names */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 int qlen; /* length of qualifier */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638 int cblev; /* current curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 int parlev; /* current parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 bool incomm, inquote, inchar, quotednl, midtoken;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 bool cplpl, cjava;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642 token savetok; /* token saved during preprocessor handling */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 tokoff = toklen = 0; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 curndx = newndx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2647 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 lp = curlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650 *lp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 fvdef = fvnone; typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 definedef = dnone; objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 next_token_is_func = yacc_rules = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 midtoken = inquote = inchar = incomm = quotednl = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 tok.valid = savetok.valid = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 cplpl = (c_ext & C_PLPL) == C_PLPL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 cjava = (c_ext & C_JAVA) == C_JAVA;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 if (cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 { qualifier = "."; qlen = 1; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2663 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664 { qualifier = "::"; qlen = 2; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2667 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2668 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2669 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2670 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2671 /* 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
2672 '\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
2673 to read the next line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2674 if (*lp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2675 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2676 quotednl = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2677 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2678 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2679 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2680 c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2681 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2682 else if (incomm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2684 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2685 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2686 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2687 if (*lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2689 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2690 incomm = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2691 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2692 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2693 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2694 /* Newlines inside comments do not end macro definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2695 traditional cpp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2696 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2700 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2703 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2704 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2705 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2706 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2707 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2708 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2709 /* Newlines inside strings do not end macro definitions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2710 in traditional cpp, even though compilers don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2711 usually accept them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2712 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2713 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2714 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2715 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2717 else if (inchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722 /* Hmmm, something went wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 inchar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2735 inquote = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2738 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2739 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2740 inchar = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2741 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2743 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 case '/':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2745 if (*lp == '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748 incomm = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2751 else if (/* cplpl && */ *lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2753 c = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2754 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2755 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 if ((c_ext & YACC) && *lp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2761 /* entering or exiting rules section in yacc file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2763 definedef = dnone; fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2764 typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2765 next_token_is_func = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2766 midtoken = inquote = inchar = incomm = quotednl = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2767 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2768 yacc_rules = !yacc_rules;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2769 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2770 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2771 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2772 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2773 case '#':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2774 if (definedef == dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2775 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2776 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777 bool cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2779 /* Look back on this line. If all blanks, or nonblanks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2780 followed by an end of comment, this is a preprocessor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2781 token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2782 for (cp = newlb.buffer; cp < lp-1; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2783 if (!iswhite (*cp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2784 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2785 if (*cp == '*' && *(cp+1) == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2786 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2787 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2788 cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 cpptoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 if (cpptoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 definedef = dsharpseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795 } /* if (definedef == dnone) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798 } /* switch (c) */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2801 /* Consider token only if some complicated conditions are satisfied. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 if ((definedef != dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2803 || (cblev == 0 && structdef != scolonseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2804 || (cblev == 1 && cplpl && structdef == sinbody)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2805 || (structdef == sinbody && structtype == st_C_enum))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2806 && typdef != tignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2807 && definedef != dignorerest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2808 && fvdef != finlist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2810 if (midtoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2812 if (endtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2813 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2814 if (c == ':' && cplpl && *lp == ':' && begtoken(*(lp + 1)))
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2817 * This handles :: in the middle, but not at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2818 * beginning of an identifier.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2819 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2820 lp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821 toklen += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2822 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2823 set_construct(C_METHOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2825 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2826 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2828 bool funorvar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2830 if (yacc_rules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2831 || consider_token (newlb.buffer + tokoff, toklen, c,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832 c_ext, cblev, parlev, &funorvar))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2833 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 tok.named = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 if (structdef == sinbody
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 && definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 && funorvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838 /* function or var defined in C++ class body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2840 int len = strlen (structtag) + qlen + toklen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841 grow_linebuffer (&token_name, len + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2842 strcpy (token_name.buffer, structtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2843 strcat (token_name.buffer, qualifier);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2844 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2845 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2846 token_name.len = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2847 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2848 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2849 oo_browser_construct = C_METHOD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2850 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2851 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2852 else if (objdef == ocatseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2853 /* Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2854 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2855 int len = strlen (objtag) + 2 + toklen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2856 grow_linebuffer (&token_name, len + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2857 strcpy (token_name.buffer, objtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2858 strcat (token_name.buffer, "(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2859 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2860 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2861 strcat (token_name.buffer, ")");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2862 token_name.len = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2863 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2864 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2865 oo_browser_construct = C_OBJC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2866 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2867 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2868 else if (objdef == omethodtag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2869 || objdef == omethodparm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2870 /* Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2871 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2872 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2874 oo_browser_construct = C_OBJC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2875 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 grow_linebuffer (&token_name, toklen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 strncpy (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 token_name.buffer[toklen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2883 token_name.len = toklen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 /* Name macros. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 tok.named
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 = (structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 || typdef == tend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 /* Also name #define constants,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890 enumerations and enum_labels.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 Conditionalize `funorvar' reference
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892 here or #defines will appear without
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 their #names.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2894 -- Bob Weiner, Altrasoft, 4/25/1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2895 || ((oo_browser_format || funorvar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2896 && definedef == dignorerest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2897 || (oo_browser_format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2898 && (oo_browser_construct == C_ENUMERATION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 || oo_browser_construct == C_ENUM_LABEL))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 || (funorvar
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 && definedef == dignorerest)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2903 #endif
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2906 tok.lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907 tok.linelen = tokoff + toklen + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2908 tok.buffer = newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2909 tok.linepos = newlinepos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2910 tok.valid = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2911
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2912 if (definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2913 && (fvdef == fvnameseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2914 || structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2915 || typdef == tend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2916 || objdef != onone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2917 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2918 if (current_lb_is_new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2919 switch_line_buffers ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2920 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2921 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2922 make_C_tag (funorvar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2923 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2924 midtoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2925 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2926 } /* if (endtoken (c)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2927 else if (intoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2928 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2929 toklen++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2930 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2931 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2932 } /* if (midtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2933 else if (begtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2935 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2937 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2942 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2943 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2944 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2945 set_construct(C_MACRO);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2946 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 make_C_tag (TRUE); /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2948 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2949 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2951 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2952 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2953 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 if (structdef == stagseen && !cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2955 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2956 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2957 case dsharpseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2958 savetok = tok;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2959 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2960 if (!yacc_rules || lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2962 tokoff = lp - 1 - newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963 toklen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 midtoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2965 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2966 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2967 } /* if (begtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2968 } /* if must look at token */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2971 /* Detect end of line, colon, comma, semicolon and various braces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2972 after having handled a token.*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2973 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2975 case ':':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2976 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2977 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2978 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2979 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2980 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2981 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2982 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2983 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2984 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2985 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2986 objdef = omethodcolon;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2987 methodlen += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2988 grow_linebuffer (&token_name, methodlen + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2989 strcat (token_name.buffer, ":");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2990 token_name.len = methodlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2991 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2992 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2993 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2994 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2995 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2996 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2998 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2999 if (yacc_rules)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3001 make_C_tag (FALSE); /* a yacc function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3002 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3003 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3004 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3005 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3007 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3008 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3009 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3010 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3013 if (cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3014 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3015 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3016 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3017 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3018 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3019 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3020 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3021 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3022 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 typdef = tnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3027 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3028 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3029 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3030 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3032 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3033 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3034 /* if (constantypedefs && structdef == snone)*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3035 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3036 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3037 switch (structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3038 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3039 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3040 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3041 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3042 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3043 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3044 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3046 set_construct(C_VARIABLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3047 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3048 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3049 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050 /* Force reset of st_C_enum structtype value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3052 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3053 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3054 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3055 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3057 /* The following instruction invalidates the token.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3058 Probably the token should be invalidated in all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3059 other cases where some state machine is reset. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 tok.valid = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3062 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3063 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3064 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3065 case ',':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3066 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3067 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3068 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3069 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3070 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3071 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3072 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3073 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3074 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3076 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3077 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3078 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3079 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3080 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3081 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3082 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3083 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3084 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3085 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3086 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3087 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3088 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3089 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3090 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3091 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3092 case '[':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3093 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3094 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3095 if (cblev == 0 && typdef == tend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3096 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3097 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3098 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3099 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3100 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3101 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3102 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3103 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3104 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3106 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3107 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3108 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3109 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3110 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3111 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3112 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3113 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3114 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3115 if (constantypedefs && structdef == snone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3117 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 switch (structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3120 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3121 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3122 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3123 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3124 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3125 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3126 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3127 set_construct(C_VARIABLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3128 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3131 /* Force reset of st_C_enum structtype value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3132 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3133 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3134 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3135 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3136 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3137 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3139 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3140 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3141 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3142 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3143 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3144 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3145 if (objdef == otagseen && parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3146 objdef = oparenseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3149 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3150 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3151 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3152 case ttypedseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3153 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3154 if (tok.valid && *lp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3155 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3156 /* This handles constructs like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3157 typedef void OperatorFun (int fun); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3158 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3159 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3160 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3161 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3162 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3163 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3164 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3165 } /* switch (typdef) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3166 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3167 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3168 fvdef = fstartlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3169 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3170 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3171 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3172 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3174 parlev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3175 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3176 case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3177 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3178 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3179 if (objdef == ocatseen && parlev == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3180 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3181 make_C_tag (TRUE); /* an Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3182 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3183 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3184 if (--parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3185 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3186 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3188 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190 fvdef = flistseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3191 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193 if (cblev == 0 && typdef == tend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3196 set_construct(C_TYPE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3197 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3198 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 make_C_tag (FALSE); /* a typedef */
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3203 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3204 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3205 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3207 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208 if (typdef == ttypedseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3209 typdef = tinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3210 switch (structdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3211 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3212 case skeyseen: /* unnamed struct */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3213 structdef = sinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3214 structtag = "_anonymous_";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3215 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3216 case stagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3217 case scolonseen: /* named struct */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3218 structdef = sinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3219 make_C_tag (FALSE); /* a struct */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3220 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3221 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3222 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3223 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3224 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3225 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3226 set_construct(C_FUNCTION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3227 /* Ensure function name is recorded.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3228 -- Bob Weiner, Altrasoft */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3229 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3230 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3231 make_C_tag (TRUE); /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3232 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3233 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3234 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3235 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3236 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3237 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3238 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3239 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3240 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3241 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3242 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3243 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3244 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3245 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3246 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3247 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3248 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3249 /* Neutralize `extern "C" {' grot. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3250 if (cblev == 0 && structdef == snone && typdef == tnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3251 cblev = -1;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3254 cblev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3255 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3256 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3257 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3259 if (fvdef == fstartlist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3260 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3261 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3262 case '}':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3263 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3264 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3265 if (!noindentypedefs && lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3266 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 cblev = 0; /* reset curly brace level if first column */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3268 parlev = 0; /* also reset paren level, just in case... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3270 else if (cblev > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3271 cblev--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3272 if (cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3273 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3274 if (typdef == tinbody)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3275 typdef = tend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 /* Memory leakage here: the string pointed by structtag is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3277 never released, because I fear to miss something and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3278 break things while freeing the area. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3279 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3280 struct tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3281 if (structdef == sinbody)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3282 free (structtag); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3284 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3285 structtag = "<error>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3286 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3287 /* Next line added to avoid any state carryover between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3288 functions. -- Bob Weiner, Altrasoft, 11/19/1997 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3289 fvdef = fvnone; oo_browser_construct = C_NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3290 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3291 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3292 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3293 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3294 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3295 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3296 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3297 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298 int is_method = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3299 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3305 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3306 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3307 if ((globals && cblev == 0) || (members && cblev == 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3308 #ifndef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3309 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3310 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3312 tok.named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3313 switch (structtype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3314 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3315 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3316 set_construct(C_ENUMERATION);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3317 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3318 case st_C_class:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3319 set_construct(C_CLASS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3320 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3321 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3322 /* a global variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3323 set_construct(C_VARIABLE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3324 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3327 /* ootags categorizes each tag found whereas etags doesn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3328 Set the is_method flag if this tag has been marked as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3329 such by an earlier section of code.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3330 -- Steve Baur, Altrasoft, 5/7/1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3331 is_method = (oo_browser_construct == C_METHOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3333 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3334 /* Force reset of st_C_enum structtype value. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 structtype = st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 fvdef = is_method ? fignore : vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3343 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3345 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3347 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3348 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349 break;
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 case '-':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3352 if (objdef == oinbody && cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3354 objdef = omethodsign;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3355 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 case '#': case '~': case '&': case '%': case '/': case '|':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359 case '^': case '!': case '<': case '>': case '.': case '?': case ']':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3360 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3361 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3363 if (!cplpl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3364 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3365 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3366 /* The above characters cannot follow a function tag in C, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3367 unmark this as a function entry. For C++, these characters
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3368 may follow an `operator' function construct, so skip the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3369 unmarking conditional below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3370 -- Steve Baur, Altrasoft, 5/7/1998 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3371 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3372 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3373 #ifdef OO_BROWSER
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3374 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3375 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3376 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3377 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3378 if (objdef == otagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3379 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3380 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3381 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3382 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3383 /* If a macro spans multiple lines don't reset its state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3384 if (quotednl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3385 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3386 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3387 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3388 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3389 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3390
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3391 } /* while not eof */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3395 * 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
3396 * of a global flag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3397 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3398 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3399 default_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3400 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3402 C_entries (cplusplus ? C_PLPL : 0, inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3405 /* Always do plain ANSI C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3406 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3407 plain_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3408 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3409 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3410 C_entries (0, inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3413 /* Always do C++. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3414 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3415 Cplusplus_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3416 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3417 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3418 C_entries (C_PLPL, inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3421 /* Always do Java. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3422 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3423 Cjava_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3424 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3425 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3426 C_entries (C_JAVA, inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3429 /* Always do C*. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3430 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3431 Cstar_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3432 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3433 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3434 C_entries (C_STAR, inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3437 /* Always do Yacc. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3438 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3439 Yacc_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3440 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3441 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3442 C_entries (YACC, inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3445 /* A useful macro. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3446 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3447 for (lineno = charno = 0; /* loop initialization */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3448 !feof (file_pointer) /* loop test */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3449 && (lineno++, /* instructions at start of loop */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3450 linecharno = charno, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3451 charno += readline (&line_buffer, file_pointer), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3452 char_pointer = lb.buffer, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3453 TRUE); \
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3458 * 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
3459 * matching on files that have no language defined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3460 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3461 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3462 just_read_file (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3463 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3464 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3465 register char *dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3466
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3467 LOOP_ON_INPUT_LINES (inf, lb, dummy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3468 continue;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3471 /* Fortran parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3472
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3473 bool tail PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3474 bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3475 tail (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3476 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3477 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3478 register int len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3479
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3480 while (*cp && lowcase(*cp) == lowcase(dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3481 cp++, len++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3482 if (*cp == '\0' && !intoken(dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3483 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3484 dbp += len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3485 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3486 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3487 return FALSE;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3490 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3491 takeprec ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3492 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3493 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3494 if (*dbp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3495 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3496 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3497 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3498 if (strneq (dbp, "(*)", 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3499 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3500 dbp += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3501 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3502 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3503 if (!isdigit (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3504 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3505 --dbp; /* force failure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3506 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3507 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3508 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3509 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3510 while (isdigit (*dbp));
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3513 void getit PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3514 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3515 getit (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3516 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3517 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3518 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3520 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3521 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3522 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3523 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3524 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3525 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3526 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3527 if (dbp[5] != '&')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3528 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3529 dbp += 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3530 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3531 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3532 if (!isalpha (*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 && *dbp != '$')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3535 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3536 for (cp = dbp + 1; *cp && intoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3537 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3538 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3539 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3543 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3544 Fortran_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3545 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3546 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3547 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3548 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3549 if (*dbp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3550 dbp++; /* Ratfor escape to fortran */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3551 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3552 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3553 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3554 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3555 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3556 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3557 if (tail ("integer"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3558 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3559 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3560 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3561 if (tail ("real"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3562 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3563 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3564 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3565 if (tail ("logical"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3566 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3567 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3568 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3569 if (tail ("complex") || tail ("character"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3570 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3571 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3572 case 'd':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3573 if (tail ("double"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3574 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3575 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3576 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3577 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3578 if (tail ("precision"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3579 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3580 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3582 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3583 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3584 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3585 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3586 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3587 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3589 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3590 if (tail ("function"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3591 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3592 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3593 case 's':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3594 if (tail ("subroutine"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3595 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3596 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3598 if (tail ("entry"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3599 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3600 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3601 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3602 if (tail ("program"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3603 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3604 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3605 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3607 if (tail ("procedure"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 continue;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3615 * Bob Weiner, Motorola Inc., 4/3/94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3616 * Unix and microcontroller assembly tag handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3617 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3619 void
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 428
diff changeset
3620 Asm_labels (FILE *inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3621 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3622 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3623
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3624 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3625 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3626 /* If first char is alphabetic or one of [_.$], test for colon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3627 following identifier. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3628 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3629 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3630 /* Read past label. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3631 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3632 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3633 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3634 if (*cp == ':' || isspace (*cp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3635 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3636 /* 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
3637 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3638 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3645 * Perl support by Bart Robinson <lomew@cs.utah.edu>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3646 * enhanced by Michael Ernst <mernst@alum.mit.edu>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3648 * Perl variable names: /^(my|local).../
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3649 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3650 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3651 Perl_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3652 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3653 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3654 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3655
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3656 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3657 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3658 if (*cp++ == 's'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3659 && *cp++ == 'u'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660 && *cp++ == 'b' && isspace (*cp++))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3661 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3662 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3663 if (*cp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3664 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3665 while (*cp != '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3666 && !isspace (*cp) && *cp != '{' && *cp != '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3667 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3668 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3669 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3672 else if (globals /* only if tagging global vars is enabled */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3673 && ((cp = lb.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674 *cp++ == 'm'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3675 && *cp++ == 'y')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3676 || (cp = lb.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3677 *cp++ == 'l'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3678 && *cp++ == 'o'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3679 && *cp++ == 'c'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680 && *cp++ == 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3681 && *cp++ == 'l'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3682 && (*cp == '(' || isspace (*cp)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3684 /* After "my" or "local", but before any following paren or space. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3685 char *varname = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3686
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3687 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3688 if (*cp == '$' || *cp == '@' || *cp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3689 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3690 char* varstart = ++cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3691 while (isalnum (*cp) || *cp == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3692 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3693 varname = savenstr (varstart, cp-varstart);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3694 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3695 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3696 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3697 /* Should be examining a variable list at this point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3698 could insist on seeing an open parenthesis. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700 cp++;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3703 /* Perhaps I should back cp up one character, so the TAGS table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3704 doesn't mention (and so depend upon) the following char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3705 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3706 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3712 * Python support by Eric S. Raymond <esr@thyrsus.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3713 * 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
3714 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3715 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3716 Python_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3717 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3718 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3719 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3721 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3722 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3723 if (*cp++ == 'd'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3724 && *cp++ == 'e'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3725 && *cp++ == 'f' && isspace (*cp++))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3726 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3727 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3728 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3729 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3730 pfnote ((char *) NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3731 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3734 cp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3735 if (*cp++ == 'c'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3736 && *cp++ == 'l'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3737 && *cp++ == 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3738 && *cp++ == 's'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3739 && *cp++ == 's' && isspace (*cp++))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3740 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3741 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3742 while (*cp != '\0' && !isspace (*cp) && *cp != '(' && *cp != ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3743 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3744 pfnote ((char *) NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3745 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3750 /* Idea by Corny de Souza
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3751 * Cobol tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3752 * We could look for anything that could be a paragraph name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3753 * 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
3754 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3755 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3756 Cobol_paragraphs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3757 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3758 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3759 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3760
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3761 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3762 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3763 if (lb.len < 9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3764 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3765 bp += 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3766
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3767 /* If eoln, compiler option or comment ignore whole line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3768 if (bp[-1] != ' ' || !isalnum (bp[0]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3769 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3770
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3771 for (ep = bp; isalnum (*ep) || *ep == '-'; ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3772 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3773 if (*ep++ == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3774 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3775 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 /* Added by Mosur Mohan, 4/22/88 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3780 /* Pascal parsing */
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3783 * Locates tags for procedures & functions. Doesn't do any type- or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3784 * var-definitions. It does look for the keyword "extern" or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3785 * "forward" immediately following the procedure statement; if found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 * the tag is skipped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3789 Pascal_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 linebuffer tline; /* mostly copied from C_entries */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793 long save_lcno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 int save_lineno, save_len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795 char c, *cp, *namebuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3796
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3797 bool /* each of these flags is TRUE iff: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3798 incomment, /* point is inside a comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3799 inquote, /* point is inside '..' string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3800 get_tagname, /* point is after PROCEDURE/FUNCTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3801 keyword, so next item = potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3802 found_tag, /* point is after a potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3803 inparms, /* point is within parameter-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3804 verify_tag; /* point has passed the parm-list, so the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3805 next token will determine whether this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3806 is a FORWARD/EXTERN to be ignored, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3807 whether it is a real tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3809 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3810 namebuf = NULL; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3814 *dbp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3815 initbuffer (&tline);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3817 incomment = inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818 found_tag = FALSE; /* have a proc name; check if extern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 get_tagname = FALSE; /* have found "procedure" keyword */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 inparms = FALSE; /* found '(' after "proc" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821 verify_tag = FALSE; /* check if "extern" is ahead */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824 while (!feof (inf)) /* long main loop to get next char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3825 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3826 c = *dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 if (c == '\0') /* if end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3828 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3829 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3830 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3832 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3833 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3835 if (!((found_tag && verify_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 || get_tagname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3837 c = *dbp++; /* only if don't need *dbp pointing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3838 to the beginning of the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3839 the procedure or function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3840 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3841 if (incomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3842 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3843 if (c == '}') /* within { } comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3844 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3845 else if (c == '*' && *dbp == ')') /* within (* *) comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3846 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3847 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3848 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3849 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3850 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3851 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3852 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3853 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3854 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3855 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3856 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3857 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3858 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3859 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3861 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3862 inquote = TRUE; /* found first quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3863 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3864 case '{': /* found open { comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3865 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3866 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3867 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3868 if (*dbp == '*') /* found open (* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3869 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3870 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3871 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3872 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3873 else if (found_tag) /* found '(' after tag, i.e., parm-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3874 inparms = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3875 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3876 case ')': /* end of parms list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3877 if (inparms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3878 inparms = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3879 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3880 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3881 if (found_tag && !inparms) /* end of proc or fn stmt */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3882 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3883 verify_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3884 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 if (found_tag && verify_tag && (*dbp != ' '))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 /* check if this is an "extern" declaration */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3893 if (lowcase (*dbp == 'e'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3894 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3895 if (tail ("extern")) /* superfluous, really! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3897 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3898 verify_tag = FALSE;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 else if (lowcase (*dbp) == 'f')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3902 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 if (tail ("forward")) /* check for forward reference */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 verify_tag = FALSE;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 if (found_tag && verify_tag) /* not external proc, so make tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 pfnote (namebuf, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 tline.buffer, save_len, save_lineno, save_lcno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3915 continue;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 if (get_tagname) /* grab name of proc or fn */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923 /* save all values for later tagging */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 grow_linebuffer (&tline, lb.len + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 strcpy (tline.buffer, lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 save_lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 save_lcno = linecharno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 /* grab block name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 namebuf = (CTAGS) ? savenstr (dbp, cp-dbp) : NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 dbp = cp; /* set dbp to e-o-token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 save_len = dbp - lb.buffer + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935 get_tagname = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936 found_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939 /* and proceed to check for "extern" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 else if (!incomment && !inquote && !found_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3943 /* check for proc/fn keywords */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944 switch (lowcase (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3950 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951 if (tail ("unction"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3953 continue;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956 } /* while not eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958 free (tline.buffer);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3962 * lisp tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3963 * look for (def or (DEF, quote or QUOTE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3964 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3965 int L_isdef PP ((char *strp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3966 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3967 L_isdef (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3968 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3969 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 return ((strp[1] == 'd' || strp[1] == 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3971 && (strp[2] == 'e' || strp[2] == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3972 && (strp[3] == 'f' || strp[3] == 'F'));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 int L_isquote PP ((char *strp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3975 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3976 L_isquote (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3977 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3978 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979 return ((*++strp == 'q' || *strp == 'Q')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980 && (*++strp == 'u' || *strp == 'U')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3981 && (*++strp == 'o' || *strp == 'O')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3982 && (*++strp == 't' || *strp == 'T')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3983 && (*++strp == 'e' || *strp == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3984 && isspace (*++strp));
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3987 void L_getit PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3988 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3989 L_getit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3990 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3991 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3992
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3993 if (*dbp == '\'') /* Skip prefix quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3994 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3995 else if (*dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3996 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3997 if (L_isquote (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3998 dbp += 7; /* Skip "(quote " */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3999 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4000 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4001 dbp = skip_spaces (dbp);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4004 for (cp = dbp /*+1*/;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4005 *cp != '\0' && *cp != '(' && *cp != ' ' && *cp != ')';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4006 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4007 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4008 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4009 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4010
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4011 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4012 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4015 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4016 Lisp_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4017 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4018 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4019 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4020 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4021 if (dbp[0] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4022 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4023 if (L_isdef (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4024 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4025 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4026 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4027 L_getit ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4030 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4031 /* Check for (foo::defmumble name-defined ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4032 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4033 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4034 while (*dbp != '\0' && !isspace (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4035 && *dbp != ':' && *dbp != '(' && *dbp != ')');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4036 if (*dbp == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4037 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4038 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4039 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4040 while (*dbp == ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4042 if (L_isdef (dbp - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4043 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4044 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4045 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 L_getit ();
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4055 * Postscript tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4056 * Just look for lines where the first character is '/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4057 * Richard Mlynarik <mly@adoc.xerox.com>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4058 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4059 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4060 Postscript_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4061 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4062 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4063 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4064
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4065 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4067 if (bp[0] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4068 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4069 for (ep = bp+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4070 *ep != '\0' && *ep != ' ' && *ep != '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4071 ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4072 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4073 pfnote ((CTAGS) ? savenstr (bp, ep-bp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4074 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4081 * Scheme tag functions
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 (def ... ((...(xyzzy ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4085 * look for (set! xyzzy
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4088 void get_scheme PP ((void));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4089
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4090 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4091 Scheme_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4092 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4093 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4094 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4095 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4096 if (dbp[0] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4097 && (dbp[1] == 'D' || dbp[1] == 'd')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4098 && (dbp[2] == 'E' || dbp[2] == 'e')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4099 && (dbp[3] == 'F' || dbp[3] == 'f'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4100 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4101 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4102 /* Skip over open parens and white space */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4103 while (isspace (*dbp) || *dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4104 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4105 get_scheme ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4106 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4107 if (dbp[0] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4108 && (dbp[1] == 'S' || dbp[1] == 's')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4109 && (dbp[2] == 'E' || dbp[2] == 'e')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4110 && (dbp[3] == 'T' || dbp[3] == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4111 && (dbp[4] == '!' || dbp[4] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4112 && (isspace (dbp[5])))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4113 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4114 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4115 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4116 get_scheme ();
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4121 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4122 get_scheme ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4124 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4126 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4127 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4128 /* Go till you get to white space or a syntactic break */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4129 for (cp = dbp + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4130 *cp != '\0' && *cp != '(' && *cp != ')' && !isspace (*cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4131 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4132 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4133 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4134 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4137 /* Find tags in TeX and LaTeX input files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4139 /* TEX_toktab is a table of TeX control sequences that define tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4140 Each TEX_tabent records one such control sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141 CONVERT THIS TO USE THE Stab TYPE!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4142 struct TEX_tabent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4143 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4144 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4145 int len;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4148 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4150 /* Default set of control sequences to put into TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4151 The value of environment var TEXTAGS is prepended to this. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4153 char *TEX_defenv = "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4154 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4155 :part:appendix:entry:index";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4156
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4157 void TEX_mode PP ((FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4158 struct TEX_tabent *TEX_decode_env PP ((char *evarname, char *defenv));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4159 int TEX_Token PP ((char *cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4161 char TEX_esc = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4162 char TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163 char TEX_clgrp = '}';
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4166 * TeX/LaTeX scanning loop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4167 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4168 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4169 TeX_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4170 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4171 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4172 char *cp, *lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4173 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4175 /* Select either \ or ! as escape character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4176 TEX_mode (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4177
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4178 /* Initialize token table once from environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4179 if (!TEX_toktab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4180 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4181
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4182 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4183 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4184 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4185 /* Look at each esc in line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4186 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4187 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4188 if (*++cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4189 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4190 linecharno += cp - lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4191 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4192 i = TEX_Token (lasthit);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4193 if (i >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4195 /* We seem to include the TeX command in the tag name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4196 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4197 for (p = lasthit + TEX_toktab[i].len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4198 *p != '\0' && *p != TEX_clgrp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4199 p++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4200 continue; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4201 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4202 lb.buffer, lb.len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4203 break; /* We only tag a line once */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4209 #define TEX_LESC '\\'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 #define TEX_SESC '!'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4211 #define TEX_cmt '%'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4212
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4213 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4214 chars accordingly. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4216 TEX_mode (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219 int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 while ((c = getc (inf)) != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4223 /* Skip to next line if we hit the TeX comment char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 if (c == TEX_cmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 while (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 c = getc (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4227 else if (c == TEX_LESC || c == TEX_SESC )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4228 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4231 if (c == TEX_LESC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4232 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4233 TEX_esc = TEX_LESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4234 TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4235 TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4236 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4237 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4238 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4239 TEX_esc = TEX_SESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4240 TEX_opgrp = '<';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4241 TEX_clgrp = '>';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4243 rewind (inf);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4246 /* Read environment and prepend it to the default string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4247 Build token table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4248 struct TEX_tabent *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4249 TEX_decode_env (evarname, defenv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4250 char *evarname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4251 char *defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4252 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4253 register char *env, *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4254
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4255 struct TEX_tabent *tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256 int size, i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4258 /* Append default string to environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4259 env = getenv (evarname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4260 if (!env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4261 env = defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4262 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 char *oldenv = env;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4265 env = concat (oldenv, defenv, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4266 free (oldenv);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 /* Allocate a token table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 for (size = 1, p = env; p;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271 if ((p = etags_strchr (p, ':')) && *++p != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4272 size++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4273 /* Add 1 to leave room for null terminator. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4274 tab = xnew (size + 1, struct TEX_tabent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4275
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4276 /* Unpack environment string into token table. Be careful about */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4277 /* zero-length strings (leading ':', "::" and trailing ':') */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4278 for (i = 0; *env;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4280 p = etags_strchr (env, ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4281 if (!p) /* End of environment string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4282 p = env + strlen (env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4283 if (p - env > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4284 { /* Only non-zero strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4285 tab[i].name = savenstr (env, p - env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4286 tab[i].len = strlen (tab[i].name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4287 i++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4288 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4289 if (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4290 env = p + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4291 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4292 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4293 tab[i].name = NULL; /* Mark end of table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4294 tab[i].len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4295 break;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4298 return tab;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4301 /* 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
4302 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
4303 Otherwise return -1.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4304 Keep the capital `T' in `token' for dumb truncating compilers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4305 (this distinguishes it from `TEX_toktab' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4306 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4307 TEX_Token (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4308 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4309 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4310 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4311
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4312 for (i = 0; TEX_toktab[i].len > 0; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4313 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4314 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4315 return -1;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4319 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4320 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321 * Assumes that the predicate starts at column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4322 * Only the first clause of a predicate is added.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4323 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4324 int prolog_pred PP ((char *s, char *last));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4325 void prolog_skip_comment PP ((linebuffer *plb, FILE *inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4326 int prolog_atom PP ((char *s, int pos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4328 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4329 Prolog_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4331 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4332 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4333 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4334 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4335
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4336 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4337 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4338 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4339
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4340 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4342 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4343 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4344 else if (isspace (cp[0])) /* Not a predicate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4345 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4346 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4347 prolog_skip_comment (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4348 else if ((len = prolog_pred (cp, last)) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4349 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4350 /* Predicate. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4351 generate a tag for the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4352 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4353 last = xnew(len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4354 else if (len + 1 > allocated)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4355 last = xrnew (last, len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4356 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4357 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4358 last[len] = '\0';
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4364 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4365 prolog_skip_comment (plb, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4366 linebuffer *plb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4367 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4369 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4370
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4371 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4372 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4373 for (cp = plb->buffer; *cp != '\0'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4374 if (cp[0] == '*' && cp[1] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4375 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4376 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4377 linecharno += readline (plb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4378 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4379 while (!feof(inf));
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4383 * A predicate definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4384 * <beginning of line><Prolog Atom><whitespace>(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4385 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4386 * 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
4387 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4388 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4389 * 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
4390 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4391 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4392 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4393 prolog_pred (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4394 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4395 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4396 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4397 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4398 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4399
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4400 pos = prolog_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4401 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4402 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4404 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4405 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4406
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4407 if ((s[pos] == '(') || (s[pos] == '.'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4408 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4409 if (s[pos] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4410 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4411
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4412 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4413 if (last == NULL
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
4414 || len != (int) strlen (last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4415 || !strneq (s, last, len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4416 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4417 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4418 s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4419 return len;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4422 return 0;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4426 * Consume a Prolog atom.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4427 * 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
4428 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4429 * A prolog atom, in this context, could be one of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4430 * - An alphanumeric sequence, starting with a lower case letter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4431 * - A quoted arbitrary string. Single quotes can escape themselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4432 * Backslash quotes everything.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4433 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4434 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4435 prolog_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4436 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4437 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4439 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4441 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4442
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4443 if (islower(s[pos]) || (s[pos] == '_'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4444 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4445 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4446 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4447 while (isalnum(s[pos]) || (s[pos] == '_'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4448 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4449 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4450 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4451 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4452 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4453 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4455 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4456
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4457 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4458 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4459 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4460 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4461 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4462 if (s[pos] != '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4463 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4464 pos++; /* A double quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4466 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4467 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4468 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4469 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4470 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4471 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4472 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4473 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4475 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4476 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4477 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4478 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4479 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4480 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4481 return -1;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4485 * Support for Erlang -- Anders Lindgren, Feb 1996.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4486 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4487 * Generates tags for functions, defines, and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4488 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4489 * Assumes that Erlang functions start at column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4490 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4491 int erlang_func PP ((char *s, char *last));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4492 void erlang_attribute PP ((char *s));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4493 int erlang_atom PP ((char *s, int pos));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4495 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4496 Erlang_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4497 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4498 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4499 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4500 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4501 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4502
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4503 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4504 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4505 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4506
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4507 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4508 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4509 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4510 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4511 else if (isspace (cp[0])) /* Not function nor attribute */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4512 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4513 else if (cp[0] == '%') /* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4514 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4515 else if (cp[0] == '"') /* Sometimes, strings start in column one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4516 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4517 else if (cp[0] == '-') /* attribute, e.g. "-define" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4518 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4519 erlang_attribute (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4520 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4521 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4522 else if ((len = erlang_func (cp, last)) > 0)
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4525 * Function. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4526 * generates a tag for the first clause.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4527 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4528 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4529 last = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4530 else if (len + 1 > allocated)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4531 last = xrnew (last, len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4532 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4533 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4534 last[len] = '\0';
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4541 * A function definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4542 * <beginning of line><Erlang Atom><whitespace>(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4543 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4544 * 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
4545 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4546 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4547 * 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
4548 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4549 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4550 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4551 erlang_func (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4552 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4553 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4554 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4555 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4556 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4558 pos = erlang_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4559 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4560 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4562 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4563 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4564
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4565 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4566 if (s[pos++] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4567 && (last == NULL
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 442
diff changeset
4568 || len != (int) strlen (last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4569 || !strneq (s, last, len)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4570 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4571 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4572 s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4573 return len;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4576 return 0;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4581 * Handle attributes. Currently, tags are generated for defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4582 * and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4583 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4584 * They are on the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4585 * -define(foo, bar).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4586 * -define(Foo(M, N), M+N).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4587 * -record(graph, {vtab = notable, cyclic = true}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4588 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4589 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4590 erlang_attribute (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4591 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4593 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4594 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4595
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4596 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4597 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4598 pos = skip_spaces (s + 7) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4599 if (s[pos++] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4600 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4601 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4602 len = erlang_atom (s, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4603 if (len != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4604 pfnote ((CTAGS) ? savenstr (& s[pos], len) : NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4605 s, pos + len, lineno, linecharno);
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4608 return;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4613 * Consume an Erlang atom (or variable).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4614 * 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
4615 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4616 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4617 erlang_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4618 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4619 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4620 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4621 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4623 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4625 if (isalpha (s[pos]) || s[pos] == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4626 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4627 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4628 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4629 while (isalnum (s[pos]) || s[pos] == '_')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4630 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4631 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4632 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4633 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4634 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4635 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4636
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4637 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4638 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4639 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4640 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4641 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4642 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4643 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4644 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4645 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4646 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4647 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4648 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4649 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4650 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4651 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4652 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4653 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4654 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4655 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4656 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4658 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4659 return -1;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4662 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4664 /* Take a string like "/blah/" and turn it into "blah", making sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4665 that the first and last characters are the same, and handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4666 quoted separator characters. Actually, stops on the occurrence of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4667 an unquoted separator. Also turns "\t" into a Tab character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4668 Returns pointer to terminating separator. Works in place. Null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4669 terminates name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4670 char * scan_separators PP ((char *name));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4671 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4672 scan_separators (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4673 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4674 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4675 char sep = name[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4676 char *copyto = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4677 bool quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4678
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4679 for (++name; *name != '\0'; ++name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4680 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4681 if (quoted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4682 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4683 if (*name == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4684 *copyto++ = '\t';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4685 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4686 *copyto++ = sep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4687 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4688 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4689 /* Something else is quoted, so preserve the quote. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4690 *copyto++ = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4691 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4692 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4693 quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4694 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4695 else if (*name == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4696 quoted = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4697 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4698 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4699 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4700 *copyto++ = *name;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4703 /* Terminate copied string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4704 *copyto = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4705 return name;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4708 /* 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
4709 thing. Same for each line of a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4710 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4711 analyse_regex (regex_arg)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4712 char *regex_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4713 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4714 if (regex_arg == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4715 free_patterns (); /* --no-regex: remove existing regexps */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4717 /* A real --regexp option or a line in a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4718 switch (regex_arg[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4720 /* Comments in regexp file or null arg to --regex. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4721 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4722 case ' ':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4723 case '\t':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4724 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4726 /* Read a regex file. This is recursive and may result in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4727 loop, which will stop when the file descriptors are exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4728 case '@':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4730 FILE *regexfp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4731 linebuffer regexbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4732 char *regexfile = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4733
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4734 /* regexfile is a file containing regexps, one per line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4735 regexfp = fopen (regexfile, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4736 if (regexfp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4737 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4738 pfatal (regexfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4739 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4740 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4741 initbuffer (&regexbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4742 while (readline_internal (&regexbuf, regexfp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4743 analyse_regex (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4744 free (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4745 fclose (regexfp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4746 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4747 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4748
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4749 /* Regexp to be used for a specific language only. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4750 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4751 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4752 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4753 char *lang_name = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4754 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4755
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4756 for (cp = lang_name; *cp != '}'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4757 if (*cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4758 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4759 error ("unterminated language name in regex: %s", regex_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4760 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4761 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4762 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4763 lang = get_language_from_name (lang_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4764 if (lang == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4765 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4766 add_regex (cp + 1, lang);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4767 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4768 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4770 /* Regexp to be used for any language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4771 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4772 add_regex (regex_arg, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4773 break;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4777 /* Turn a name, which is an ed-style (but Emacs syntax) regular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4778 expression, into a real regular expression by compiling it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4779 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4780 add_regex (regexp_pattern, lang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4781 char *regexp_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4782 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4783 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4784 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4785 const char *err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4786 struct re_pattern_buffer *patbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4787 pattern *pp;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4790 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4792 error ("%s: unterminated regexp", regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4793 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4794 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4795 name = scan_separators (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4796 if (regexp_pattern[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4797 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4798 error ("null regexp", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4799 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4800 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4801 (void) scan_separators (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4803 patbuf = xnew (1, struct re_pattern_buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4804 patbuf->translate = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4805 patbuf->fastmap = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4806 patbuf->buffer = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4807 patbuf->allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4808
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4809 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4810 if (err != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4812 error ("%s while compiling pattern", err);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4813 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4816 pp = p_head;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4817 p_head = xnew (1, pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4818 p_head->regex = savestr (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4819 p_head->p_next = pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4820 p_head->language = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4821 p_head->pattern = patbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4822 p_head->name_pattern = savestr (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4823 p_head->error_signaled = FALSE;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4827 * Do the substitutions indicated by the regular expression and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4828 * arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4829 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4830 char * substitute PP ((char *in, char *out, struct re_registers *regs));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4831 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4832 substitute (in, out, regs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4833 char *in, *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4834 struct re_registers *regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4835 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4836 char *result, *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4837 int size, dig, diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4838
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4839 result = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4840 size = strlen (out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4841
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4842 /* 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
4843 if (out[size - 1] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4844 fatal ("pattern error in \"%s\"", out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4845 for (t = etags_strchr (out, '\\');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4846 t != NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4847 t = etags_strchr (t + 2, '\\'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4848 if (isdigit (t[1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4849 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4850 dig = t[1] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4851 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4852 size += diglen - 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4853 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4854 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4855 size -= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4857 /* Allocate space and do the substitutions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4858 result = xnew (size + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4859
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4860 for (t = result; *out != '\0'; out++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4861 if (*out == '\\' && isdigit (*++out))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4862 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4863 /* Using "dig2" satisfies my debugger. Bleah. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4864 dig = *out - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4865 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4866 strncpy (t, in + regs->start[dig], diglen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4867 t += diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4868 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4869 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4870 *t++ = *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4871 *t = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4872
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4873 if (DEBUG && (t > result + size || t - result != strlen (result)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4874 abort ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4875
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4876 return result;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4879 /* Deallocate all patterns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4880 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4881 free_patterns ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4882 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4883 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4884 while (p_head != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4885 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4886 pp = p_head->p_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4887 free (p_head->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4888 free (p_head->name_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4889 free (p_head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4890 p_head = pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4891 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4892 return;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4895 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4896 /* Initialize a linebuffer for use */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4897 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4898 initbuffer (lbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4899 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4900 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4901 lbp->size = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4902 lbp->buffer = xnew (200, char);
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4906 * Read a line of text from `stream' into `lbp', excluding the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4907 * 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
4908 * `stream', which is the length of the line including the newline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4909 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4910 * 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
4911 * 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
4912 * 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
4913 * file).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4914 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4915 long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4916 readline_internal (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4917 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4918 register FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4919 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4920 char *buffer = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4921 register char *p = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4922 register char *pend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4923 int chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4924
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4925 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4927 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4928 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4929 register int c = getc (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4930 if (p == pend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4931 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4932 /* We're at the end of linebuffer: expand it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4933 lbp->size *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4934 buffer = xrnew (buffer, lbp->size, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4935 p += buffer - lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4936 pend = buffer + lbp->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4937 lbp->buffer = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4938 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4939 if (c == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4940 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4941 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4942 chars_deleted = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4943 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4944 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4945 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4946 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4947 if (p > buffer && p[-1] == '\r')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4948 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4949 p -= 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4950 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4951 /* Assume CRLF->LF translation will be performed by Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4952 when loading this file, so CRs won't appear in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4953 It would be cleaner to compensate within Emacs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4954 however, Emacs does not know how many CRs were deleted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4955 before any given point in the file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4956 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4957 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4958 chars_deleted = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4959 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4960 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4961 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4962 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4963 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4964 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4965 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4966 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4967 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4968 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4969 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4970 lbp->len = p - buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4971
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4972 return lbp->len + chars_deleted;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4976 * Like readline_internal, above, but in addition try to match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4977 * input line against relevant regular expressions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4978 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4979 long
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4980 readline (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4981 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4982 FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4983 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4984 /* Read new line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4985 long result = readline_internal (lbp, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4986 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4987 int match;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4988 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4989
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4990 /* Match against relevant patterns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4991 if (lbp->len > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4992 for (pp = p_head; pp != NULL; pp = pp->p_next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4993 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4994 /* Only use generic regexps or those for the current language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4995 if (pp->language != NULL && pp->language != curlang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4996 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4998 match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4999 switch (match)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5000 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5001 case -2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5002 /* Some error. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5003 if (!pp->error_signaled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5004 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5005 error ("error while matching \"%s\"", pp->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5006 pp->error_signaled = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5007 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5008 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5009 case -1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5010 /* No match. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5011 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5012 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5013 /* Match occurred. Construct a tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5014 if (pp->name_pattern[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5015 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5016 /* Make a named tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5017 char *name = substitute (lbp->buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5018 pp->name_pattern, &pp->regs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5019 if (name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5020 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5021 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5022 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5023 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5024 /* Make an unnamed tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5025 pfnote ((char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5026 lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5027 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5028 break;
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 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5031 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5032
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5033 return result;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5037 * Return a pointer to a space of size strlen(cp)+1 allocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5038 * with xnew where the string CP has been copied.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5039 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5040 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5041 savestr (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5042 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5043 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5044 return savenstr (cp, strlen (cp));
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5048 * 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
5049 * 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
5050 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5051 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5052 savenstr (cp, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5053 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5054 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5055 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5056 register char *dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5057
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5058 dp = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5059 strncpy (dp, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5060 dp[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5061 return dp;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5065 * Return the ptr in sp at which the character c last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5066 * appears; NULL if not found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5067 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5068 * Identical to System V strrchr, included for portability.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5069 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5070 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5071 etags_strrchr (sp, c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5072 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5073 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5074 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5075 register char *r;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5076
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5077 r = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5078 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5079 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5080 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5081 r = sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5082 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5083 return r;
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 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5088 * Return the ptr in sp at which the character c first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5089 * appears; NULL if not found
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5090 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5091 * Identical to System V strchr, included for portability.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5092 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5093 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5094 etags_strchr (sp, c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5095 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5096 register int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5097 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5098 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5099 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5100 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5101 return sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5102 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5103 return NULL;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5106 /* Skip spaces, return new pointer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5107 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5108 skip_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5109 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5110 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5111 while (isspace (*cp)) /* isspace('\0')==FALSE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5112 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5113 return cp;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5116 /* Skip non spaces, return new pointer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5117 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5118 skip_non_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5119 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5120 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5121 while (!iswhite (*cp)) /* iswhite('\0')==TRUE */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5122 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5123 return cp;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5126 /* Print error message and exit. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5127 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5128 fatal (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5129 char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5130 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5131 error (s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5132 exit (BAD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5135 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5136 pfatal (s1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5137 char *s1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5138 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5139 perror (s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5140 exit (BAD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5143 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5144 suggest_asking_for_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5145 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5146 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5147 progname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5148 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5149 "--help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5150 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5151 "-h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5152 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5153 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5154 exit (BAD);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5157 /* 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
5158 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5159 error (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5160 const char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5162 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5163 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5164 fprintf (stderr, "\n");
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5167 /* Return a newly-allocated string whose contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5168 concatenate those of s1, s2, s3. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5169 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5170 concat (s1, s2, s3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5171 char *s1, *s2, *s3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5172 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5173 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5174 char *result = xnew (len1 + len2 + len3 + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5176 strcpy (result, s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5177 strcpy (result + len1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5178 strcpy (result + len1 + len2, s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5179 result[len1 + len2 + len3] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5180
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5181 return result;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5184 /* 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
5185 guess the buffer size in advance. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5186 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5187 etags_getcwd ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5189 #ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5190 int bufsize = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5191 char *path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5192
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5193 while (getcwd (path, bufsize) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5194 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5195 if (errno != ERANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5196 pfatal ("getcwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5197 bufsize *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5198 free (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5199 path = xnew (bufsize, char);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5202 canonicalize_filename (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5203 return path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5204
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5205 #else /* not HAVE_GETCWD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5206 linebuffer path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5207 FILE *pipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5209 initbuffer (&path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5210 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5211 if (pipe == NULL || readline_internal (&path, pipe) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5212 pfatal ("pwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5213 pclose (pipe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5214
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5215 return path.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5216 #endif /* not HAVE_GETCWD */
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5219 /* Return a newly allocated string containing the file name of FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5220 relative to the absolute directory DIR (which should end with a slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5221 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5222 relative_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5223 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5224 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5225 char *fp, *dp, *afn, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5226 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5228 /* Find the common root of file and dir (with a trailing slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5229 afn = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5230 fp = afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5231 dp = dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5232 while (*fp++ == *dp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5233 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5234 fp--, dp--; /* back to the first differing char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5235 do /* look at the equal chars until '/' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5236 fp--, dp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5237 while (*fp != '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5238
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5239 /* Build a sequence of "../" strings for the resulting relative file name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5240 i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5241 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5242 i += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5243 res = xnew (3*i + strlen (fp + 1) + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5244 res[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5245 while (i-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5246 strcat (res, "../");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5248 /* 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
5249 strcat (res, fp + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5250 free (afn);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5252 return res;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5255 /* Return a newly allocated string containing the absolute file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5256 of FILE given DIR (which should end with a slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5257 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5258 absolute_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5259 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5261 char *slashp, *cp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5262
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5263 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5264 res = savestr (file);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5265 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5266 /* We don't support non-absolute file names with a drive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5267 letter, like `d:NAME' (it's too much hassle). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5268 else if (file[1] == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5269 fatal ("%s: relative file names with drive letters not supported", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5270 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5271 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5272 res = concat (dir, file, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5274 /* Delete the "/dirname/.." and "/." substrings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5275 slashp = etags_strchr (res, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5276 while (slashp != NULL && slashp[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5277 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5278 if (slashp[1] == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5279 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5280 if (slashp[2] == '.'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5281 && (slashp[3] == '/' || slashp[3] == '\0'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5282 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5283 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5284 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5285 cp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5286 while (cp >= res && !filename_is_absolute (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5287 if (cp < res)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5288 cp = slashp; /* the absolute name begins with "/.." */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5289 #ifdef WIN32_NATIVE
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5290 /* Under Windows we get `d:/NAME' as absolute
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5291 file name, so the luser could say `d:/../NAME'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5292 We silently treat this as `d:/NAME'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5293 else if (cp[0] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5294 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5295 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5296 strcpy (cp, slashp + 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5297 slashp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5298 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5300 else if (slashp[2] == '/' || slashp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5301 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5302 strcpy (slashp, slashp + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5303 continue;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5307 slashp = etags_strchr (slashp + 1, '/');
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5310 if (res[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5311 return savestr ("/");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5312 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5313 return res;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5316 /* Return a newly allocated string containing the absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5317 file name of dir where FILE resides given DIR (which should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5318 end with a slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5319 char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5320 absolute_dirname (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5321 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5322 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5323 char *slashp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5324 char save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5325
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5326 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5327 slashp = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5328 if (slashp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5329 return savestr (dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5330 save = slashp[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5331 slashp[1] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5332 res = absolute_filename (file, dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5333 slashp[1] = save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5335 return res;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5338 /* Whether the argument string is an absolute file name. The argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5339 string must have been canonicalized with canonicalize_filename. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5340 bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5341 filename_is_absolute (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5342 char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5343 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5344 return (fn[0] == '/'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5345 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5346 || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5347 #endif
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5351 /* Translate backslashes into slashes. Works in place. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5352 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5353 canonicalize_filename (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5354 register char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5355 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5356 #ifdef WIN32_NATIVE
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5357 for (; *fn != '\0'; fn++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5358 if (*fn == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5359 *fn = '/';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5360 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5361 /* No action. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5362 #endif
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5365 /* Increase the size of a linebuffer. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5366 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5367 grow_linebuffer (lbp, toksize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5368 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5369 int toksize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5370 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5371 while (lbp->size < toksize)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5372 lbp->size *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5373 lbp->buffer = xrnew (lbp->buffer, lbp->size, char);
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5376 /* Like malloc but get fatal error if memory is exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5377 long *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5378 xmalloc (size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5379 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5380 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5381 long *result = (long *) malloc (size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5382 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5383 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5384 return result;
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
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5387 long *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5388 xrealloc (ptr, size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5389 char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5390 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5392 long *result = (long *) realloc (ptr, size);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5393 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5394 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5395 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5396 }