annotate lib-src/etags.c @ 163:0132846995bd r20-3b8

Import from CVS: tag r20-3b8
author cvs
date Mon, 13 Aug 2007 09:43:35 +0200
parents 6b37e6ddd302
children 8eaf7971accc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* Tags file maker to go with GNU Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Free Software Foundation, Inc. and Ken Arnold
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is not considered part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 (at your option) any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
18 along with this program; if not, write to the Free Software Foundation,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 * Authors:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 * Ctags originally by Ken Arnold.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 * Fortran added by Jim Kleckner.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 * Ed Pelegri-Llopart added C typedefs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 * Gnu Emacs TAGS format and modifications by RMS?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 * Sam Kendall added C++.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 * Francesco Potorti` reorganised C and C++ based on work by Joe Wells.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 * Regexp tags by Tom Tromey.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
31 * Francesco Potorti` (F.Potorti@cnuce.cnr.it) is the current maintainer.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
34 char pot_etags_version[] = "@(#) pot revision number is 12.11";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 #define TRUE 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #define FALSE 0
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
38
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 #ifndef DEBUG
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 # define DEBUG FALSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 #ifdef MSDOS
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
44 # include <string.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
45 # include <fcntl.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
46 # include <sys/param.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 #endif /* MSDOS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 #ifdef WINDOWSNT
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
50 # include <stdlib.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
51 # include <fcntl.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
52 # include <string.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
53 # include <io.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
54 # define MAXPATHLEN _MAX_PATH
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
55 #endif
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
56
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #ifdef HAVE_CONFIG_H
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
58 # include <config.h>
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
59 /* On some systems, Emacs defines static as nothing for the sake
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
60 of unexec. We don't want that here since we don't use unexec. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
61 # undef static
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
62 # define ETAGS_REGEXPS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
63 # define LONG_OPTIONS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
66 #if !defined (MSDOS) && !defined (WINDOWSNT) && defined (STDC_HEADERS)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
67 #include <stdlib.h>
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
68 #include <string.h>
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
69 #endif
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
70
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 #include <ctype.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 #include <errno.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 #ifndef errno
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 extern int errno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 #include <sys/types.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 #include <sys/stat.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 #if !defined (S_ISREG) && defined (S_IFREG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
84 #ifdef HAVE_UNISTD_H
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
85 #include <unistd.h>
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
86 #endif
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
87
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
88 #ifdef LONG_OPTIONS
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 155
diff changeset
89 # include "getopt.h"
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
90 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
91 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
92 extern char *optarg;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
93 extern int optind, opterr;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
94 #endif /* LONG_OPTIONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 #ifdef ETAGS_REGEXPS
157
6b37e6ddd302 Import from CVS: tag r20-3b5
cvs
parents: 155
diff changeset
97 # include "../src/regex.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 /* Define CTAGS to make the program "ctags" compatible with the usual one.
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
101 Leave it undefined to make the program "etags", which makes emacs-style
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 tag tables and tags typedefs, #defines and struct/union/enum by default. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 #ifdef CTAGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 # undef CTAGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 # define CTAGS TRUE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 # define CTAGS FALSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 /* Exit codes for success and failure. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 #ifdef VMS
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
112 # define GOOD 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
113 # define BAD 0
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 #else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
115 # define GOOD 0
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
116 # define BAD 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 /* C extensions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 #define C_PLPL 0x00001 /* C++ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 #define C_STAR 0x00003 /* C* */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
122 #define C_JAVA 0x00005 /* JAVA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 #define YACC 0x10000 /* yacc file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
125 #define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
126 && (abort (), 1)) || !strcmp (s, t))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
127 #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
128 && (abort (), 1)) || !strncmp (s, t, n))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
129
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
130 #define lowcase(c) tolower ((char)c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
131
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
132 #define CHARS 256 /* 2^sizeof(char) */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
133 #define CHAR(x) ((int)x & (CHARS - 1))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
134 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
135 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
136 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
137 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
138 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 #ifdef DOS_NT
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
141 # define absolutefn(fn) (fn[0] == '/' \
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
142 || (fn[1] == ':' && fn[2] == '/'))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 # define absolutefn(fn) (fn[0] == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 * xnew -- allocate storage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 * SYNOPSIS: Type *xnew (int n, Type);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
153 #ifdef chkmalloc
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
154 # include "chkmalloc.h"
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
155 # define xnew(n,Type) ((Type *) trace_xmalloc (__FILE__, __LINE__, \
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
156 (n) * sizeof (Type)))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
157 #else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
158 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
159 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
161 typedef int bool;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 typedef struct nd_st
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
164 { /* sorting structure */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 char *name; /* function or type name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 char *file; /* file name */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
167 bool is_func; /* use pattern or line no */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
168 bool been_warned; /* set if noticed dup */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
169 int lno; /* line number tag is on */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 long cno; /* character number line starts on */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 char *pat; /* search pattern */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 struct nd_st *left, *right; /* left and right sons */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 } NODE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 extern char *getenv ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
177 char *concat ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
178 char *savenstr (), *savestr ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
179 char *etags_strchr (), *etags_strrchr ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
180 char *etags_getcwd ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
181 char *relative_filename (), *absolute_filename (), *absolute_dirname ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
182 void grow_linebuffer ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
183 long *xmalloc (), *xrealloc ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 typedef void Lang_function ();
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
186 /* Many compilers barf on this:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
187 Lang_function Asm_labels;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
188 so let's write it this way */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
189 void Asm_labels ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
190 void C_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
191 void default_C_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
192 void plain_C_entries ();
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
193 void Cjava_entries ();
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
194 void Cobol_paragraphs ();
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
195 void Cplusplus_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
196 void Cstar_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
197 void Erlang_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
198 void Fortran_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
199 void Yacc_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
200 void Lisp_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
201 void Pascal_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
202 void Perl_functions ();
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
203 void Postscript_functions ();
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
204 void Prolog_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
205 void Scheme_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
206 void TeX_functions ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
207 void just_read_file ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
209 Lang_function *get_language_from_name ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
210 Lang_function *get_language_from_interpreter ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
211 Lang_function *get_language_from_suffix ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
212 int total_size_of_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
213 long readline ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
214 long readline_internal ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 #ifdef ETAGS_REGEXPS
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
216 void analyse_regex ();
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
217 void add_regex ();
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
218 #endif /* ETAGS_REGEXPS */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
219 void add_node ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
220 void error ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
221 void suggest_asking_for_help ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
222 void fatal (), pfatal ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
223 void find_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
224 void free_tree ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
225 void getit ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
226 void init ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
227 void initbuffer ();
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
228 void pfnote (), new_pfnote ();
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
229 void process_file ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
230 void put_entries ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
231 void takeprec ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 char searchar = '/'; /* use /.../ searches */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 int lineno; /* line number of current line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 long charno; /* current character number */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
238 long linecharno; /* charno of start of line */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 char *curfile; /* current input file name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 char *tagfile; /* output file */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
242 char *progname; /* name this program was invoked with */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 char *cwd; /* current working directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 char *tagfiledir; /* directory of tagfile */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 FILE *tagf; /* ioptr for tags file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 NODE *head; /* the head of the binary tree of tags */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
249 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
250 * A `struct linebuffer' is a structure which holds a line of text.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
251 * `readline' reads a line from a stream into a linebuffer and works
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
252 * regardless of the length of the line.
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
253 * SIZE is the size of BUFFER, LEN is the length of the string in
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
254 * BUFFER after readline reads it.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
255 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
256 struct linebuffer
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
257 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
258 long size;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
259 int len;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
260 char *buffer;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
261 };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
262
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 struct linebuffer lb; /* the current line */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
264 struct linebuffer token_name; /* used by C_entries as a temporary area */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 long linepos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 struct linebuffer lb; /* used by C_entries instead of lb */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 } lbs[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 /* boolean "functions" (see init) */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
272 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
273 char
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
274 /* white chars */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
275 *white = " \f\t\n\013",
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
276 /* not in a name */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
277 *nonam =" \f\t\n\013(=,[;",
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
278 /* token ending chars */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
279 *endtk = " \t\n\013\"'#()[]{}=-+%*/&|^~!<>;,.:?",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
280 /* token starting chars */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
281 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
282 /* valid in-token chars */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
283 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
285 bool append_to_tagfile; /* -a: append to tags */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
286 /* The following four default to TRUE for etags, but to FALSE for ctags. */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
287 bool typedefs; /* -t: create tags for C typedefs */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
288 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 /* 0 struct/enum/union decls, and C++ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 /* member functions. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
291 bool constantypedefs; /* -d: create tags for C #define, enum */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
292 /* constants and variables. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 /* -D: opposite of -d. Default under ctags. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
294 bool globals; /* create tags for C global variables */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
295 bool members; /* create tags for C member variables */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
296 bool update; /* -u: update tags */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
297 bool vgrind_style; /* -v: create vgrind style index output */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
298 bool no_warnings; /* -w: suppress warnings */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
299 bool cxref_style; /* -x: create cxref style output */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
300 bool cplusplus; /* .[hc] means C++, not C */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
301 bool noindentypedefs; /* -I: ignore indentation in C */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
302
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
303 #ifdef LONG_OPTIONS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 struct option longopts[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
306 { "append", no_argument, NULL, 'a' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
307 { "backward-search", no_argument, NULL, 'B' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
308 { "c++", no_argument, NULL, 'C' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
309 { "cxref", no_argument, NULL, 'x' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
310 { "defines", no_argument, NULL, 'd' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
311 { "no-defines", no_argument, NULL, 'D' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
312 { "globals", no_argument, &globals, TRUE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
313 { "no-globals", no_argument, &globals, FALSE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
314 { "help", no_argument, NULL, 'h' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
315 { "help", no_argument, NULL, 'H' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
316 { "ignore-indentation", no_argument, NULL, 'I' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
317 { "include", required_argument, NULL, 'i' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
318 { "language", required_argument, NULL, 'l' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
319 { "members", no_argument, &members, TRUE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
320 { "no-members", no_argument, &members, FALSE },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
321 { "no-warn", no_argument, NULL, 'w' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
322 { "output", required_argument, NULL, 'o' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
323 #ifdef ETAGS_REGEXPS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
324 { "regex", required_argument, NULL, 'r' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
325 { "no-regex", no_argument, NULL, 'R' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
326 #endif /* ETAGS_REGEXPS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
327 { "typedefs", no_argument, NULL, 't' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
328 { "typedefs-and-c++", no_argument, NULL, 'T' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
329 { "update", no_argument, NULL, 'u' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
330 { "version", no_argument, NULL, 'V' },
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
331 { "vgrind", no_argument, NULL, 'v' },
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 { 0 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 };
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
334 #endif /* LONG_OPTIONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 /* Structure defining a regular expression. Elements are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 the compiled pattern, and the name string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 struct pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 struct re_pattern_buffer *pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 struct re_registers regs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 char *name_pattern;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
344 bool error_signaled;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 /* Number of regexps found. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 int num_patterns = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 /* Array of all regexps. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 struct pattern *patterns = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 * Language stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 /* Non-NULL if language fixed. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 Lang_function *lang_func = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 /* Assembly code */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
362 char *Asm_suffixes [] = { "a", /* Unix assembler */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 "asm", /* Microcontroller assembly */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "def", /* BSO/Tasking definition includes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 "inc", /* Microcontroller include files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 "ins", /* Microcontroller include files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 "s", "sa", /* Unix assembler */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 "src", /* BSO/Tasking C compiler output */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 /* Note that .c and .h can be considered C++, if the --c++ flag was
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 given. That is why default_C_entries is called here. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
374 char *default_C_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 { "c", "h", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
377 char *Cplusplus_suffixes [] =
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
378 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
379 "M", /* Objective C++ */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
380 "pdb", /* Postscript with C syntax */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
381 NULL };
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
382
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
383 char *Cjava_suffixes [] =
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
384 { "java", NULL };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
385
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
386 char *Cobol_suffixes [] =
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
387 { "COB", "cob", NULL };
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
388
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
389 char *Cstar_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 { "cs", "hs", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
392 char *Erlang_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
393 { "erl", "hrl", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
394
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
395 char *Fortran_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 { "F", "f", "f90", "for", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
398 char *Lisp_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
401 char *Pascal_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 { "p", "pas", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
404 char *Perl_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 { "pl", "pm", NULL };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
406 char *Perl_interpreters [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
407 { "perl", "@PERL@", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
408
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
409 char *plain_C_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
410 { "pc", /* Pro*C file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
411 "m", /* Objective C file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
412 "lm", /* Objective lex file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
413 NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
414
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
415 char *Postscript_suffixes [] =
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
416 { "ps", NULL };
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
417
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
418 char *Prolog_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 { "prolog", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
421 /* Can't do the `SCM' or `scm' prefix with a version number. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
422 char *Scheme_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "t", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
425 char *TeX_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
426 { "TeX", "bib", "clo", "cls", "ltx", "sty", "tex", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
427
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
428 char *Yacc_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
429 { "y", "ym", NULL }; /* .ym is Objective yacc file */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 /* Table of language names and corresponding functions, file suffixes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 and interpreter names.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 It is ok for a given function to be listed under more than one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 name. I just didn't. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 struct lang_entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
437 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 Lang_function *function;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
439 char **suffixes;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
440 char **interpreters;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
443 struct lang_entry lang_names [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 {
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
445 { "asm", Asm_labels, Asm_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
446 { "c", default_C_entries, default_C_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
447 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
448 { "c*", Cstar_entries, Cstar_suffixes, NULL },
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
449 { "cobol", Cobol_paragraphs, Cobol_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
450 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
451 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
452 { "java", Cjava_entries, Cjava_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
453 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
454 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
455 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
456 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
457 { "proc", plain_C_entries, plain_C_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
458 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
459 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
460 { "tex", TeX_functions, TeX_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
461 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
462 { "auto", NULL }, /* default guessing scheme */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
463 { "none", just_read_file }, /* regexp matching only */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
464 { NULL, NULL } /* end of list */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
468 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
469 print_language_names ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
471 struct lang_entry *lang;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
472 char **ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 puts ("\nThese are the currently supported languages, along with the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 default file name suffixes:");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 printf ("\t%s\t", lang->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 if (lang->suffixes != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 for (ext = lang->suffixes; *ext != NULL; ext++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 printf (" .%s", *ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 puts ("");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 puts ("Where `auto' means use default language for files based on file\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 name suffix, and `none' means only do regexp processing on files.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 If no language is specified and no matching suffix is found,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 the first line of the file is read for a sharp-bang (#!) sequence\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 followed by the name of an interpreter. If no such sequence is found,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 Fortran is tried first; if no tags are found, C is tried next.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 #ifndef VERSION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 # define VERSION "19"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
495 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
496 print_version ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
498 printf ("%s (GNU Emacs %s)\n", (CTAGS) ? "ctags" : "etags", VERSION);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
499 puts ("Copyright (C) 1996 Free Software Foundation, Inc. and Ken Arnold");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
500 puts ("This program is distributed under the same terms as Emacs");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
505 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
506 print_help ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
508 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
509 \n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
510 These are the options accepted by %s.\n", progname, progname);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
511 #ifdef LONG_OPTIONS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
512 puts ("You may use unambiguous abbreviations for the long option names.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
513 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
514 puts ("Long option names do not work with this executable, as it is not\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
515 linked with GNU getopt.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
516 #endif /* LONG_OPTIONS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
517 puts ("A - as file name means read names from stdin.");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
518 if (!CTAGS)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
519 printf (" Absolute names are stored in the output file as they\n\
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
520 are. Relative ones are stored relative to the output file's directory.");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
521 puts ("\n");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 puts ("-a, --append\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 Append tag entries to existing tags file.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 puts ("-B, --backward-search\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 Write the search commands for the tag entries using '?', the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 backward-search command instead of '/', the forward-search command.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 puts ("-C, --c++\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 Treat files whose name suffix defaults to C language as C++ files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 puts ("-d, --defines\n\
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
536 Create tag entries for C #define constants and enum constants, too.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 puts ("-D, --no-defines\n\
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
539 Don't create tag entries for C #define constants and enum constants.\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
540 This makes the tags file smaller.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 puts ("-i FILE, --include=FILE\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 Include a note in tag file indicating that, when searching for\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 a tag, one should also consult the tags file FILE after\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 checking the current file.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 puts ("-l LANG, --language=LANG\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 Force the following files to be considered as written in the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 named language up to the next --language=LANG option.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
553 if (CTAGS)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
554 puts ("--globals\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
555 Create tag entries for global variables in C and derived languages.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
556 else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
557 puts ("--no-globals\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
558 Do not create tag entries for global variables in C and\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
559 derived languages. This makes the tags file smaller.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
560 puts ("--members\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
561 Create tag entries for member variables in C and derived languages.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
562
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 #ifdef ETAGS_REGEXPS
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
564 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 Make a tag for each line matching pattern REGEXP in the\n\
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
566 following files. regexfile is a file containing one REGEXP\n\
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
567 per line. REGEXP is anchored (as if preceded by ^).\n\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 The form /REGEXP/NAME/ creates a named tag. For example Tcl\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 named tags can be created with:\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 puts ("-R, --no-regex\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 Don't create tags from regexps for the following files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 puts ("-o FILE, --output=FILE\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 Write the tags to FILE.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 puts ("-I, --ignore-indentation\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 Don't rely on indentation quite as much as normal. Currently,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 this means not to assume that a closing brace in the first\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 column is the final brace of a function or structure\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 definition in C and C++.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 puts ("-t, --typedefs\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 Generate tag entries for C typedefs.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 puts ("-T, --typedefs-and-c++\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 and C++ member functions.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 puts ("-u, --update\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 Update the tag entries for the given files, leaving tag\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 entries for other files in place. Currently, this is\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 implemented by deleting the existing entries for the given\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 files and then rewriting the new entries at the end of the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 tags file. It is often faster to simply rebuild the entire\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 tag file than to use this.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 puts ("-v, --vgrind\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 Generates an index of items intended for human consumption,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 similar to the output of vgrind. The index is sorted, and\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 gives the page number of each item.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 puts ("-w, --no-warn\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 Suppress warning messages about entries defined in multiple\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 puts ("-x, --cxref\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 The output uses line numbers instead of page numbers, but\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 beyond that the differences are cosmetic; try both to see\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 which you like.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 puts ("-V, --version\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 Print the version of the program.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 -h, --help\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 Print this help message.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 print_language_names ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
617 puts ("");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
618 puts ("Report bugs to bug-gnu-emacs@prep.ai.mit.edu");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
619
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 enum argument_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 at_language,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 at_regexp,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 at_filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
631 /* This structure helps us allow mixing of --lang and file names. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 typedef struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 enum argument_type arg_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 char *what;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 Lang_function *function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 } argument;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 #ifdef VMS /* VMS specific functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 #define EOS '\0'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 /* This is a BUG! ANY arbitrary limit is a BUG!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 Won't someone please fix this? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 #define MAX_FILE_SPEC_LEN 255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 typedef struct {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 short curlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 char body[MAX_FILE_SPEC_LEN + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 } vspec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
653 returning in each successive call the next file name matching the input
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 spec. The function expects that each in_spec passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 to it will be processed to completion; in particular, up to and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 including the call following that in which the last matching name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 is returned, the function ignores the value of in_spec, and will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 only start processing a new spec with the following call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 If an error occurs, on return out_spec contains the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 of in_spec when the error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
662 With each successive file name returned in out_spec, the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 function's return value is one. When there are no more matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 names the function returns zero. If on the first call no file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 matches in_spec, or there is any other error, -1 is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 #include <rmsdef.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 #include <descrip.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 #define OUTSIZE MAX_FILE_SPEC_LEN
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 short
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
672 fn_exp (out, in)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
673 vspec *out;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
674 char *in;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 static long context = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 static struct dsc$descriptor_s o;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 static struct dsc$descriptor_s i;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
679 static bool pass1 = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 short retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 if (pass1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 pass1 = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 o.dsc$a_pointer = (char *) out;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 o.dsc$w_length = (short)OUTSIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 i.dsc$a_pointer = in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 i.dsc$w_length = (short)strlen(in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 i.dsc$b_dtype = DSC$K_DTYPE_T;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 i.dsc$b_class = DSC$K_CLASS_S;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 o.dsc$b_dtype = DSC$K_DTYPE_VT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 o.dsc$b_class = DSC$K_CLASS_VS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 out->body[out->curlen] = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 else if (status == RMS$_NMF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 strcpy(out->body, in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 retval = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 lib$find_file_end(&context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 pass1 = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 name of each file specified by the provided arg expanding wildcards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
717 gfnames (arg, p_error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
718 char *arg;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
719 bool *p_error;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 switch (fn_exp (&filename, arg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 case 1:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 *p_error = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 return filename.body;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 *p_error = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 *p_error = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 return filename.body;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 #ifndef OLD /* Newer versions of VMS do provide `system'. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
738 system (cmd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
739 char *cmd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
741 error ("%s", "system() function not implemented under VMS");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 #define VERSION_DELIM ';'
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
746 char *massage_name (s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
747 char *s;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 char *start = s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 for ( ; *s; s++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 if (*s == VERSION_DELIM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 *s = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 *s = lowcase (*s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 return start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 #endif /* VMS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
764 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
765 main (argc, argv)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
766 int argc;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
767 char *argv[];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 int i;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
770 unsigned int nincluded_files;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
771 char **included_files;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 char *this_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 argument *argbuffer;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
774 int current_arg, file_count;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 struct linebuffer filename_lb;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 #ifdef VMS
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
777 bool got_err;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 #ifdef DOS_NT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 _fmode = O_BINARY; /* all of files are treated as binary files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 #endif /* DOS_NT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 progname = argv[0];
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
785 nincluded_files = 0;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
786 included_files = xnew (argc, char *);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
787 current_arg = 0;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
788 file_count = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 /* Allocate enough no matter what happens. Overkill, but each one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 is small. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 argbuffer = xnew (argc, argument);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 /* Set syntax for regular expression routines. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 re_set_syntax (RE_SYNTAX_EMACS);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 * If etags, always find typedefs and structure tags. Why not?
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
801 * Also default is to find macro constants, enum constants and
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
802 * global variables.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 if (!CTAGS)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
805 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
806 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
807 globals = TRUE;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
808 members = FALSE;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
809 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
813 int opt;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
814 char *optstring;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
815
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
816 #ifdef ETAGS_REGEXPS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
817 optstring = "-aCdDf:Il:o:r:RStTi:BuvxwVhH";
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
818 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
819 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
820 #endif /* ETAGS_REGEXPS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
821
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
822 #ifndef LONG_OPTIONS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
823 optstring = optstring + 1;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
824 #endif /* LONG_OPTIONS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
825
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
826 opt = getopt_long (argc, argv, optstring, longopts, 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 if (opt == EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 switch (opt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 /* If getopt returns 0, then it has already processed a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 long-named option. We should do nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 case 1:
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
838 /* This means that a file name has been seen. Record it. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 argbuffer[current_arg].arg_type = at_filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 argbuffer[current_arg].what = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ++file_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 /* Common options. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
846 case 'a': append_to_tagfile = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
847 case 'C': cplusplus = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
848 case 'd': constantypedefs = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
849 case 'D': constantypedefs = FALSE; break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 case 'f': /* for compatibility with old makefiles */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 case 'o':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 if (tagfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
854 error ("-%c option may only be given once.", opt);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
855 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 tagfile = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 case 'I':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 case 'S': /* for backward compatibility */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 noindentypedefs = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 argbuffer[current_arg].function = get_language_from_name (optarg);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 argbuffer[current_arg].arg_type = at_language;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 case 'r':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 argbuffer[current_arg].arg_type = at_regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 argbuffer[current_arg].what = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 case 'R':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 argbuffer[current_arg].arg_type = at_regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 argbuffer[current_arg].what = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 case 'V':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 print_version ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 case 'h':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 case 'H':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 print_help ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 case 't':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 typedefs = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 case 'T':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 typedefs = typedefs_and_cplusplus = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 #if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 /* Etags options */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 included_files[nincluded_files++] = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 #else /* CTAGS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 /* Ctags options. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
900 case 'B': searchar = '?'; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
901 case 'u': update = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
902 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
903 case 'x': cxref_style = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
904 case 'w': no_warnings = TRUE; break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 #endif /* CTAGS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 default:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
907 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 for (; optind < argc; ++optind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 argbuffer[current_arg].arg_type = at_filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 argbuffer[current_arg].what = argv[optind];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 ++file_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 if (nincluded_files == 0 && file_count == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
921 error ("no input files specified.", 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
922 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 if (tagfile == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
926 tagfile = CTAGS ? "tags" : "TAGS";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 cwd = etags_getcwd (); /* the current working directory */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
928 if (cwd[strlen (cwd) - 1] != '/')
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
929 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
930 char *oldcwd = cwd;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
931 cwd = concat (oldcwd, "/", "");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
932 free (oldcwd);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
933 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 if (streq (tagfile, "-"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
935 tagfiledir = cwd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
937 tagfiledir = absolute_dirname (tagfile, cwd);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 init (); /* set up boolean "functions" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 initbuffer (&lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 initbuffer (&token_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 initbuffer (&lbs[0].lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 initbuffer (&lbs[1].lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 initbuffer (&filename_lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 if (streq (tagfile, "-"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
950 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
951 tagf = stdout;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
952 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
953 /* Switch redirected `stdout' to binary mode (setting `_fmode'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
954 doesn't take effect until after `stdout' is already open). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
955 if (!isatty (fileno (stdout)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
956 setmode (fileno (stdout), O_BINARY);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
957 #endif /* DOS_NT */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
958 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 if (tagf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 pfatal (tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 * Loop through files finding functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 for (i = 0; i < current_arg; ++i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 switch (argbuffer[i].arg_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 case at_language:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 lang_func = argbuffer[i].function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 case at_regexp:
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
977 analyse_regex (argbuffer[i].what);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 case at_filename:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 if (got_err)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
986 error ("can't find file %s\n", this_file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 argc--, argv++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 this_file = massage_name (this_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 this_file = argbuffer[i].what;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 /* Input file named "-" means read file names from stdin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 and use them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 if (streq (this_file, "-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 while (readline_internal (&filename_lb, stdin) > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 process_file (filename_lb.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 process_file (this_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 while (nincluded_files-- > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 fprintf (tagf, "\f\n%s,include\n", *included_files++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 fclose (tagf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 /* If CTAGS, we are here. process_file did not write the tags yet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 because we want them ordered. Let's do it now. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 if (cxref_style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027 if (update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 char cmd[BUFSIZ];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 for (i = 0; i < current_arg; ++i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 if (argbuffer[i].arg_type != at_filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 sprintf (cmd,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 tagfile, argbuffer[i].what, tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 if (system (cmd) != GOOD)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1038 fatal ("failed to execute shell command", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 append_to_tagfile = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 if (tagf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 pfatal (tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 fclose (tagf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 if (update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 char cmd[BUFSIZ];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 exit (system (cmd));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1055 return GOOD;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 * Return a Lang_function given the name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 Lang_function *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1063 get_language_from_name (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1064 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1066 struct lang_entry *lang;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1067
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1068 if (name != NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1069 for (lang = lang_names; lang->name != NULL; lang++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1070 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1071 if (streq (name, lang->name))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1072 return lang->function;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1073 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1074
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
1075 error ("language \"%s\" not recognized.", optarg);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1076 suggest_asking_for_help ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1077
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1078 /* This point should never be reached. The function should either
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1079 return a function pointer or never return. Note that a NULL
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1080 pointer cannot be considered as an error, as it means that the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1081 language has not been explicitely imposed by the user ("auto"). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1082 return NULL; /* avoid warnings from compiler */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 * Return a Lang_function given the interpreter name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 Lang_function *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1090 get_language_from_interpreter (interpreter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1091 char *interpreter;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1093 struct lang_entry *lang;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1094 char **iname;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 if (interpreter == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 if (lang->interpreters != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 for (iname = lang->interpreters; *iname != NULL; iname++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 if (streq (*iname, interpreter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 return lang->function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 * Return a Lang_function given the file suffix.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 Lang_function *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1113 get_language_from_suffix (suffix)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1114 char *suffix;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1116 struct lang_entry *lang;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1117 char **ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 if (suffix == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 if (lang->suffixes != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 for (ext = lang->suffixes; *ext != NULL; ext++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 if (streq (*ext, suffix))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 return lang->function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 * This routine is called on each file argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1135 process_file (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1136 char *file;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 struct stat stat_buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 FILE *inf;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1140 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1141 char *p;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1142
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1143 for (p = file; *p != '\0'; p++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1144 if (*p == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1145 *p = '/';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1146 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 if (stat (file, &stat_buf) == 0 && !S_ISREG (stat_buf.st_mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1150 error ("skipping %s: it is not a regular file.", file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 if (streq (file, tagfile) && !streq (tagfile, "-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1155 error ("skipping inclusion of %s in self.", file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 inf = fopen (file, "r");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 if (inf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 perror (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 find_entries (file, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 char *filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 if (absolutefn (file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 {
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
1173 /* file is an absolute file name. Canonicalise it. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 filename = absolute_filename (file, cwd);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 {
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
1178 /* file is a file name relative to cwd. Make it relative
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 to the directory of the tags file. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 filename = relative_filename (file, tagfiledir);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 free (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 free_tree (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 head = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 * This routine sets up the boolean pseudo-functions which work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 * by setting boolean flags dependent upon the corresponding character
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 * Every char which is NOT in that string is not a white char. Therefore,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 * all of the array "_wht" is set to FALSE, and then the elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 * of a char is TRUE if it is the string "white", else FALSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1199 init ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1201 register char *sp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 register int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1204 for (i = 0; i < CHARS; i++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1205 _wht[i] = _nin[i] = _etk[i] = _itk[i] = _btk[i] = FALSE;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1206 for (sp = white; *sp; sp++) _wht[*sp] = TRUE; _wht[0] = _wht['\n'];
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1207 for (sp = nonam; *sp; sp++) _nin[*sp] = TRUE; _nin[0] = _nin['\n'];
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1208 for (sp = endtk; *sp; sp++) _etk[*sp] = TRUE; _etk[0] = _etk['\n'];
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1209 for (sp = midtk; *sp; sp++) _itk[*sp] = TRUE; _btk[0] = _btk['\n'];
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1210 for (sp = begtk; *sp; sp++) _btk[*sp] = TRUE; _itk[0] = _itk['\n'];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 * This routine opens the specified file and calls the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 * which finds the function and type definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1218 find_entries (file, inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1219 char *file;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1220 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 Lang_function *function;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 NODE *old_last_node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 extern NODE *last_node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1227
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 /* Memory leakage here: the memory block pointed by curfile is never
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 released. The amount of memory leaked here is the sum of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 lengths of the input file names. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 curfile = savestr (file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 /* If user specified a language, use it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 function = lang_func;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 if (function != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 function (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 cp = etags_strrchr (file, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 if (cp != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 cp += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 function = get_language_from_suffix (cp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 if (function != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 function (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 /* Look for sharp-bang as the first two characters. */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
1256 if (readline_internal (&lb, inf)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
1257 && lb.len >= 2
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 && lb.buffer[0] == '#'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 && lb.buffer[1] == '!')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 char *lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 /* Set lp to point at the first char after the last slash in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 line or, if no slashes, at the first nonblank. Then set cp to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 the first successive blank and terminate the string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 lp = etags_strrchr (lb.buffer+2, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 if (lp != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 lp += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 for (lp = lb.buffer+2; *lp != '\0' && isspace (*lp); lp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 for (cp = lp; *cp != '\0' && !isspace (*cp); cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 *cp = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1276 if (strlen (lp) > 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 function = get_language_from_interpreter (lp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 if (function != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 function (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 /* Try Fortran. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 old_last_node = last_node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 Fortran_functions (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 /* No Fortran entries found. Try C. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 if (old_last_node == last_node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 default_C_entries (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 fclose (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 /* Record a tag. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1304 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1305 pfnote (name, is_func, linestart, linelen, lno, cno)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1306 char *name; /* tag name, or NULL if unnamed */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1307 bool is_func; /* tag is a function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 char *linestart; /* start of the line where tag is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 int linelen; /* length of the line where tag is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 int lno; /* line number */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 long cno; /* character number */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1313 register NODE *np;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1314
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1315 if (CTAGS && name == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1316 return;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1317
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1318 np = xnew (1, NODE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 /* If ctags mode, change name "main" to M<thisfilename>. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 if (CTAGS && !cxref_style && streq (name, "main"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 register char *fp = etags_strrchr (curfile, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 np->name = concat ("M", fp == 0 ? curfile : fp + 1, "");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 fp = etags_strrchr (np->name, '.');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 if (fp && fp[1] != '\0' && fp[2] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 fp[0] = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 np->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 np->been_warned = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 np->file = curfile;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 np->is_func = is_func;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 np->lno = lno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 /* Our char numbers are 0-base, because of C language tradition?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 ctags compatibility? old versions compatibility? I don't know.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1337 Anyway, since emacs's are 1-base we expect etags.el to take care
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 of the difference. If we wanted to have 1-based numbers, we would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 uncomment the +1 below. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 np->cno = cno /* + 1 */ ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 np->left = np->right = NULL;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1342 if (CTAGS && !cxref_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1343 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1344 if (strlen (linestart) < 50)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1345 np->pat = concat (linestart, "$", "");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1346 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1347 np->pat = savenstr (linestart, 50);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1348 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1349 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1350 np->pat = savenstr (linestart, linelen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 add_node (np, &head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1355 /* Date: Wed, 22 Jan 1997 02:56:31 -0500
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1356 * From: Sam Kendall <kendall@cybercom.net>
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1357 * Subject: Proposal for firming up the TAGS format specification
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1358 * To: F.Potorti@cnuce.cnr.it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1359 *
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1360 * pfnote should emit the optimized form [unnamed tag] only if:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1361 * 1. name does not contain any of the characters " \t\r\n()";
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1362 * 2. linestart contains name as either a rightmost, or rightmost but
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1363 * one character, substring;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1364 * 3. the character, if any, immediately before name in linestart must
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1365 * be one of the characters " \t()";
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1366 * 4. the character, if any, immediately after name in linestart must
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1367 * also be one of the characters " \t()".
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1368 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1369 #define traditional_tag_style TRUE
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1370 void
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1371 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1372 char *name; /* tag name, or NULL if unnamed */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1373 int namelen; /* tag length */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1374 bool is_func; /* tag is a function */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1375 char *linestart; /* start of the line where tag is */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1376 int linelen; /* length of the line where tag is */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1377 int lno; /* line number */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1378 long cno; /* character number */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1379 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1380 register char *cp;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1381 bool named;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1382
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1383 named = TRUE;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1384 if (!CTAGS)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1385 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1386 for (cp = name; !notinname (*cp); cp++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1387 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1388 if (*cp == '\0') /* rule #1 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1389 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1390 cp = linestart + linelen - namelen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1391 if (notinname (linestart[linelen-1]))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1392 cp -= 1; /* rule #4 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1393 if (cp >= linestart /* rule #2 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1394 && (cp == linestart
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1395 || notinname (cp[-1])) /* rule #3 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1396 && strneq (name, cp, namelen)) /* rule #2 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1397 named = FALSE; /* use unnamed tag */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1398 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1399 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1400
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1401 if (named)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1402 name = savenstr (name, namelen);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1403 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1404 name = NULL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1405 pfnote (name, is_func, linestart, linelen, lno, cno);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1406 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1407
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 * free_tree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 * recurse on left children, iterate on right children.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1413 free_tree (node)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1414 register NODE *node;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 while (node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 register NODE *node_right = node->right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 free_tree (node->left);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 if (node->name != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 free (node->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 free (node->pat);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 free ((char *) node);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 node = node_right;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 * add_node ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 * Adds a node to the tree of nodes. In etags mode, we don't keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 * it sorted; we just keep a linear list. In ctags mode, maintain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 * an ordered tree, with no attempt at balancing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 * add_node is the only function allowed to add nodes, so it can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 * maintain state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 NODE *last_node = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1439 add_node (node, cur_node_p)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1440 NODE *node, **cur_node_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 register int dif;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 register NODE *cur_node = *cur_node_p;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 if (cur_node == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 *cur_node_p = node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 last_node = node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 /* Etags Mode */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 if (last_node == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1456 fatal ("internal error in add_node", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 last_node->right = node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 last_node = node;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 /* Ctags Mode */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 dif = strcmp (node->name, cur_node->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 * If this tag name matches an existing one, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 * do not add the node, but maybe print a warning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 if (!dif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 if (streq (node->file, cur_node->file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 if (!no_warnings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 node->file, lineno, node->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 fprintf (stderr, "Second entry ignored\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 else if (!cur_node->been_warned && !no_warnings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 fprintf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 (stderr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 "Duplicate entry in files %s and %s: %s (Warning only)\n",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 node->file, cur_node->file, node->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 cur_node->been_warned = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 /* Actually add the node */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 add_node (node, dif < 0 ? &cur_node->left : &cur_node->right);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1497 put_entries (node)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1498 register NODE *node;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 register char *sp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 if (node == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 /* Output subentries that precede this one */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 put_entries (node->left);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 /* Output this entry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 if (node->name != NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1513 fprintf (tagf, "%s\177%s\001%d,%d\n",
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 node->pat, node->name, node->lno, node->cno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1516 fprintf (tagf, "%s\177%d,%d\n",
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 node->pat, node->lno, node->cno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1519 else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1521 if (node->name == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1522 error ("internal error: NULL name in ctags mode.", (char *)NULL);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1523
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1524 if (cxref_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1525 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1526 if (vgrind_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1527 fprintf (stdout, "%s %s %d\n",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1528 node->name, node->file, (node->lno + 63) / 64);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1529 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1530 fprintf (stdout, "%-16s %3d %-16s %s\n",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1531 node->name, node->lno, node->file, node->pat);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1534 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1535 fprintf (tagf, "%s\t%s\t", node->name, node->file);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1536
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1537 if (node->is_func)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1538 { /* a function */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1539 putc (searchar, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1540 putc ('^', tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1541
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1542 for (sp = node->pat; *sp; sp++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1543 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1544 if (*sp == '\\' || *sp == searchar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1545 putc ('\\', tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1546 putc (*sp, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1547 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1548 putc (searchar, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1549 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1550 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1551 { /* a typedef; text pattern inadequate */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1552 fprintf (tagf, "%d", node->lno);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1553 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1554 putc ('\n', tagf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 /* Output subentries that follow this one */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 put_entries (node->right);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 /* Length of a number's decimal representation. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1563 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1564 number_len (num)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1565 long num;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 int len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 if (!num)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 for (; num; num /= 10)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 ++len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 return len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 * Return total number of characters that put_entries will output for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 * the nodes in the subtree of the specified node. Works only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 * we are not ctags, but called only in that case. This count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 * is irrelevant with the new tags.el, but is still supplied for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 * backward compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1583 total_size_of_entries (node)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1584 register NODE *node;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 register int total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 if (node == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 total = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 for (; node; node = node->right)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 /* Count left subentries. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 total += total_size_of_entries (node->left);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 /* Count this entry */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 total += strlen (node->pat) + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 total += number_len ((long) node->lno) + 1 + number_len (node->cno) + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 if (node->name != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 total += 1 + strlen (node->name); /* \001name */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 return total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 * The C symbol tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 enum sym_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1612 st_none,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1613 st_C_objprot, st_C_objimpl, st_C_objend,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1614 st_C_gnumacro,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1615 st_C_ignore,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1616 st_C_javastruct,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1617 st_C_struct, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 /* Feed stuff between (but not including) %[ and %] lines to:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1621 gperf -c -k 1,3 -o -p -r -t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 %[
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1623 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 %%
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1625 @interface, 0, st_C_objprot
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1626 @protocol, 0, st_C_objprot
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1627 @implementation,0, st_C_objimpl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1628 @end, 0, st_C_objend
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1629 import, C_JAVA, st_C_ignore
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1630 package, C_JAVA, st_C_ignore
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1631 friend, C_PLPL, st_C_ignore
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1632 extends, C_JAVA, st_C_javastruct
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1633 implements, C_JAVA, st_C_javastruct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 class, C_PLPL, st_C_struct
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1635 namespace, C_PLPL, st_C_struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 domain, C_STAR, st_C_struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 union, 0, st_C_struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 struct, 0, st_C_struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 enum, 0, st_C_enum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 typedef, 0, st_C_typedef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 define, 0, st_C_define
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1642 bool, C_PLPL, st_C_typespec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 long, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 short, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 int, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 char, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 float, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 double, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 signed, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 unsigned, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 auto, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 void, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 extern, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 static, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 const, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 volatile, 0, st_C_typespec
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1657 explicit, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1658 mutable, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1659 typename, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1660 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1661 DEFUN, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1662 SYSCALL, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1663 ENTRY, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1664 PSEUDO, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1665 # These are defined inside C functions, so currently they are not met.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1666 # EXFUN used in glibc, DEFVAR_* in emacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1667 #EXFUN, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1668 #DEFVAR_, 0, st_C_gnumacro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 %]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 and replace lines between %< and %> with its output. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 /*%<*/
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1672 /* starting time is 10:31:16 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1673 /* C code produced by gperf version 2.1 (K&R C version) */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1674 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1675
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1676
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1677 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 #define MIN_WORD_LENGTH 3
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1680 #define MAX_WORD_LENGTH 15
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1681 #define MIN_HASH_VALUE 15
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1682 #define MAX_HASH_VALUE 128
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 /*
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1684 39 keywords
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1685 114 is the maximum key range
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1688 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1689 hash (str, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1690 register char *str;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1691 register unsigned int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 static unsigned char hash_table[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1695 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1696 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1697 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1698 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1699 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1700 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1701 128, 128, 128, 128, 39, 128, 128, 128, 54, 48,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1702 46, 128, 128, 128, 128, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1703 28, 128, 128, 40, 32, 128, 128, 128, 128, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1704 128, 128, 128, 128, 128, 128, 128, 24, 30, 47,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1705 62, 7, 60, 27, 128, 60, 128, 128, 59, 16,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1706 31, 23, 45, 128, 4, 14, 2, 55, 5, 128,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1707 128, 128, 128, 128, 128, 128, 128, 128,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1709 return len + hash_table[str[2]] + hash_table[str[0]];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1712 struct C_stab_entry *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1713 in_word_set (str, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1714 register char *str;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1715 register unsigned int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 static struct C_stab_entry wordlist[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1720 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1721 {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1722 {"extern", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1723 {"extends", C_JAVA, st_C_javastruct},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1724 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1725 {"struct", 0, st_C_struct},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1726 {"mutable", C_PLPL, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1727 {"",}, {"",}, {"",}, {"",},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1728 {"auto", 0, st_C_typespec},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1729 {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1730 {"",}, {"",},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1731 {"short", 0, st_C_typespec},
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1732 {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1733 {"static", 0, st_C_typespec},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1734 {"",}, {"",},
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1735 {"signed", 0, st_C_typespec},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1736 {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1737 {"@protocol", 0, st_C_objprot},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1738 {"",},
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1739 {"typedef", 0, st_C_typedef},
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1740 {"typename", C_PLPL, st_C_typespec},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1741 {"namespace", C_PLPL, st_C_struct},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1742 {"bool", C_PLPL, st_C_typespec},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1743 {"",}, {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1744 {"explicit", C_PLPL, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1745 {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1746 {"int", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1747 {"enum", 0, st_C_enum},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1748 {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1749 {"void", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1750 {"@implementation", 0, st_C_objimpl},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1751 {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1752 {"volatile", 0, st_C_typespec},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1753 {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1754 {"@end", 0, st_C_objend},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 {"char", 0, st_C_typespec},
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 {"class", C_PLPL, st_C_struct},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1757 {"unsigned", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1758 {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1759 {"@interface", 0, st_C_objprot},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1760 {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1761 {"PSEUDO", 0, st_C_gnumacro},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1762 {"const", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1763 {"domain", C_STAR, st_C_struct},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1764 {"ENTRY", 0, st_C_gnumacro},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1765 {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1766 {"SYSCALL", 0, st_C_gnumacro},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1767 {"float", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1768 {"",}, {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1769 {"long", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1770 {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1771 {"package", C_JAVA, st_C_ignore},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1772 {"",}, {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1773 {"DEFUN", 0, st_C_gnumacro},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1774 {"",}, {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1775 {"import", C_JAVA, st_C_ignore},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1776 {"",}, {"",}, {"",},
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1777 {"implements", C_JAVA, st_C_javastruct},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1778 {"",}, {"",}, {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1779 {"union", 0, st_C_struct},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1780 {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1781 {"double", 0, st_C_typespec},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1782 {"",}, {"",},
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1783 {"friend", C_PLPL, st_C_ignore},
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1784 {"",},
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1785 {"define", 0, st_C_define},
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 register int key = hash (str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 if (key <= MAX_HASH_VALUE && key >= MIN_HASH_VALUE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1794 register char *s = wordlist[key].name;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1795
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1796 if (*s == *str && !strncmp (str + 1, s + 1, len - 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 return &wordlist[key];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1802 /* ending time is 10:31:16 */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 /*%>*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1805 enum sym_type
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1806 C_symtype (str, len, c_ext)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1807 char *str;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1808 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1809 int c_ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1811 register struct C_stab_entry *se = in_word_set (str, len);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 return st_none;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 return se->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 /*
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1819 * C functions and variables are recognized using a simple
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1820 * finite automaton. fvdef is its state variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1822 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1824 fvnone, /* nothing seen */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1825 fvnameseen, /* function or variable name seen */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1826 fstartlist, /* func: just after open parenthesis */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1827 finlist, /* func: in parameter list */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1828 flistseen, /* func: after parameter list */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1829 fignore, /* func: before open brace */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1830 vignore /* var-like: ignore until ';' */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1831 } fvdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 * typedefs are recognized using a simple finite automaton.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1836 * typdef is its state variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1838 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 tnone, /* nothing seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 ttypedseen, /* typedef keyword seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 tinbody, /* inside typedef body */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 tend, /* just before typedef tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 tignore /* junk after typedef tag */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1845 } typdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 * struct-like structures (enum, struct and union) are recognized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 * using another simple finite automaton. `structdef' is its state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 * variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1853 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 snone, /* nothing seen yet */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 skeyseen, /* struct-like keyword seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 stagseen, /* struct-like tag seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 scolonseen, /* colon seen after struct-like tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 sinbody /* in struct body: recognize member func defs*/
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1860 } structdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 * struct tag, and structtype is the type of the preceding struct-like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 * keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1867 char *structtag = "<uninited>";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 enum sym_type structtype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1871 * When objdef is different from onone, objtag is the name of the class.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1872 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1873 char *objtag = "<uninited>";
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1874
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1875 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 * Yet another little state machine to deal with preprocessor lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1878 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 dnone, /* nothing seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 dsharpseen, /* '#' seen as first char on line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 ddefineseen, /* '#' and 'define' seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 dignorerest /* ignore rest of line */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1884 } definedef;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1885
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1886 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1887 * State machine for Objective C protocols and implementations.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1888 * Tom R.Hageman <tom@basil.icce.rug.nl>
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1889 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1890 enum
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1891 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1892 onone, /* nothing seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1893 oprotocol, /* @interface or @protocol seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1894 oimplementation, /* @implementations seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1895 otagseen, /* class name seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1896 oparenseen, /* parenthesis before category seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1897 ocatseen, /* category name seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1898 oinbody, /* in @implementation body */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1899 omethodsign, /* in @implementation body, after +/- */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1900 omethodtag, /* after method name */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1901 omethodcolon, /* after method colon */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1902 omethodparm, /* after method parameter */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1903 oignore /* wait for @end */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1904 } objdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1906
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1907 /*
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1908 * Use this structure to keep info about the token read, and how it
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1909 * should be tagged. Used by the make_C_tag function to build a tag.
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1910 */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1911 typedef struct
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1912 {
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1913 bool valid;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1914 char *str;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1915 bool named;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1916 int linelen;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1917 int lineno;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1918 long linepos;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1919 char *buffer;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1920 } TOKEN;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1921 TOKEN tok; /* latest token read */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1922
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1923
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 * Set this to TRUE, and the next token considered is called a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 * Used only for GNU emacs's function-defining macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1928 bool next_token_is_func;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 * TRUE in the rules part of a yacc file, FALSE outside (parse as C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1933 bool yacc_rules;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1936 * methodlen is the length of the method name stored in token_name.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1937 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1938 int methodlen;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1939
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1940 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 * consider_token ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 * checks to see if the current token is at the start of a
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1943 * function or variable, or corresponds to a typedef, or
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1944 * is a struct/union/enum tag, or #define, or an enum constant.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1946 * *IS_FUNC gets TRUE iff the token is a function or #define macro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1947 * with args. C_EXT is which language we are looking at.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 * In the future we will need some way to adjust where the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 * the token is; for instance, implementing the C++ keyword
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 * `operator' properly will adjust the end of the token to be after
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 * whatever follows `operator'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 * Globals
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1955 * fvdef IN OUT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 * structdef IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 * definedef IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 * typdef IN OUT
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1959 * objdef IN OUT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 * next_token_is_func IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1963 bool
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1964 consider_token (str, len, c, c_ext, cblev, parlev, is_func_or_var)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 register char *str; /* IN: token pointer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 register int len; /* IN: token length */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 register char c; /* IN: first char after the token */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 int c_ext; /* IN: C extensions mask */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 int cblev; /* IN: curly brace level */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1970 int parlev; /* IN: parenthesis level */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1971 bool *is_func_or_var; /* OUT: function or variable found */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 enum sym_type toktype = C_symtype (str, len, c_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 * Advance the definedef state machine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 switch (definedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 case dnone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 /* We're not on a preprocessor line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 case dsharpseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 if (toktype == st_C_define)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 definedef = ddefineseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 definedef = dignorerest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 case ddefineseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 * Make a tag for any macro, unless it is a constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 * and constantypedefs is FALSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 definedef = dignorerest;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1999 *is_func_or_var = (c == '(');
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2000 if (!*is_func_or_var && !constantypedefs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 case dignorerest:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 default:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2007 error ("internal error: definedef value.", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 * Now typedefs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 case tnone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 if (toktype == st_C_typedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 if (typedefs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 typdef = ttypedseen;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2020 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 case ttypedseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027 case st_none:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 case st_C_typespec:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 typdef = tend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 case st_C_enum:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2034 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 /* Do not return here, so the structdef stuff has a chance. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 case tend:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 case st_C_typespec:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 case st_C_enum:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 * This structdef business is currently only invoked when cblev==0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 * It should be recursively invoked whatever the curly brace level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 * and a stack of states kept, to allow for definitions of structs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 * within structs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 * This structdef business is NOT invoked when we are ctags and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 * file is plain C. This is because a struct tag may have the same
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 * name as another tag, and this loses with ctags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2060 case st_C_javastruct:
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2061 if (structdef == stagseen)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2062 structdef = scolonseen;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2063 return FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 case st_C_enum:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 if (typdef == ttypedseen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 structdef = skeyseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 structtype = toktype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2074
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 if (structdef == skeyseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2077 /* Save the tag for struct/union/class, for functions and variables
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2078 that may be defined inside. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 if (structtype == st_C_struct)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 structtag = savenstr (str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 structtag = "<enum>";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 structdef = stagseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2087 /* Avoid entering fvdef stuff if typdef is going on. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 if (typdef != tnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 definedef = dnone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2094 /* Detect GNU macros.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2095
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2096 DEFUN note for writers of emacs C code:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2097 The DEFUN macro, used in emacs C source code, has a first arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2098 that is a string (the lisp function name), and a second arg that
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2099 is a C function name. Since etags skips strings, the second arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2100 is tagged. This is unfortunate, as it would be better to tag the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2101 first arg. The simplest way to deal with this problem would be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2102 to name the tag with a name built from the function name, by
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2103 removing the initial 'F' character and substituting '-' for '_'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2104 Anyway, this assumes that the conventions of naming lisp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2105 functions will never change. Currently, this method is not
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2106 implemented, so writers of emacs code are recommended to put the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2107 first two args of a DEFUN on the same line. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2108 if (definedef == dnone && toktype == st_C_gnumacro)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2109 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2110 next_token_is_func = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2111 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2112 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 if (next_token_is_func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 next_token_is_func = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2116 fvdef = fignore;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2117 *is_func_or_var = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2121 /* Detect Objective C constructs. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2122 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2123 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2124 case onone:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2125 switch (toktype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2126 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2127 case st_C_objprot:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2128 objdef = oprotocol;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2129 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2130 case st_C_objimpl:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2131 objdef = oimplementation;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2132 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2133 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2134 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2135 case oimplementation:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2136 /* Save the class tag for functions or variables defined inside. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2137 objtag = savenstr (str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2138 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2139 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2140 case oprotocol:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2141 /* Save the class tag for categories. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2142 objtag = savenstr (str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2143 objdef = otagseen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2144 *is_func_or_var = TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2145 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2146 case oparenseen:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2147 objdef = ocatseen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2148 *is_func_or_var = TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2149 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2150 case oinbody:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2151 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2152 case omethodsign:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2153 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2154 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2155 objdef = omethodtag;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2156 methodlen = len;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2157 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2158 strncpy (token_name.buffer, str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2159 token_name.buffer[methodlen] = '\0';
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2160 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2161 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2162 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2163 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2164 case omethodcolon:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2165 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2166 objdef = omethodparm;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2167 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2168 case omethodparm:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2169 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2170 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2171 objdef = omethodtag;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2172 methodlen += len;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2173 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2174 strncat (token_name.buffer, str, len);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2175 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2176 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2177 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2178 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2179 case oignore:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2180 if (toktype == st_C_objend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2181 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2182 /* Memory leakage here: the string pointed by objtag is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2183 never released, because many tests would be needed to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2184 avoid breaking on incorrect input code. The amount of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2185 memory leaked here is the sum of the lengths of the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2186 class tags.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2187 free (objtag); */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2188 objdef = onone;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2189 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2190 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2191 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2192
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2193 /* A function, variable or enum constant? */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 case st_C_typespec:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2197 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2198 fvdef = fvnone; /* should be useless */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2199 return FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2200 case st_C_ignore:
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2201 fvdef = vignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 return FALSE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2203 case st_none:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2204 if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2205 return TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2206 if (fvdef == fvnone)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2208 fvdef = fvnameseen; /* function or variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2209 *is_func_or_var = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 * C_entries ()
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2219 * This routine finds functions, variables, typedefs,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2220 * #define's, enum constants and struct/union/enum definitions in
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2221 * #C syntax and adds them to the list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223 #define current_lb_is_new (newndx == curndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 #define switch_line_buffers() (curndx = 1 - curndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 #define curlb (lbs[curndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 #define othlb (lbs[1-curndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 #define newlb (lbs[newndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229 #define curlinepos (lbs[curndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 #define othlinepos (lbs[1-curndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 #define newlinepos (lbs[newndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 #define CNL_SAVE_DEFINEDEF \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 curlinepos = charno; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 lineno++; \
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2237 linecharno = charno; \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 charno += readline (&curlb, inf); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 lp = curlb.buffer; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 quotednl = FALSE; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 newndx = curndx; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 #define CNL \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246 CNL_SAVE_DEFINEDEF; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 if (savetok.valid) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 tok = savetok; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 savetok.valid = FALSE; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 definedef = dnone; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2255
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2256 void
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2257 make_C_tag (isfun)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2258 bool isfun;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2259 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2260 /* This function should never be called when tok.valid is FALSE, but
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2261 we must protect against invalid input or internal errors. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2262 if (tok.valid)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2263 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2264 if (traditional_tag_style)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2265 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2266 /* This was the original code. Now we call new_pfnote instead,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2267 which uses the new method for naming tags (see new_pfnote). */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2268 char *name = NULL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2269
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2270 if (CTAGS || tok.named)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2271 name = savestr (token_name.buffer);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2272 pfnote (name, isfun,
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2273 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2274 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2275 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2276 new_pfnote (token_name.buffer, token_name.len, isfun,
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2277 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2278 tok.valid = FALSE;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2279 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2280 else if (DEBUG)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2281 abort ();
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2282 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2283
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2284
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2285 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2286 C_entries (c_ext, inf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 int c_ext; /* extension of C */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 FILE *inf; /* input file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 register char c; /* latest char read; '\0' for end of line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 register char *lp; /* pointer one beyond the character `c' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 int curndx, newndx; /* indices for current and new lb */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2293 register int tokoff; /* offset in line of start of current token */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2294 register int toklen; /* length of current token */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2295 char *qualifier; /* string used to qualify names */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2296 int qlen; /* length of qualifier */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 int cblev; /* current curly brace level */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 int parlev; /* current parenthesis level */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2299 bool incomm, inquote, inchar, quotednl, midtoken;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2300 bool cplpl, cjava;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 TOKEN savetok; /* token saved during preprocessor handling */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 curndx = newndx = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 lp = curlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 *lp = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2310 fvdef = fvnone; typdef = tnone; structdef = snone;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2311 definedef = dnone; objdef = onone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 next_token_is_func = yacc_rules = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 midtoken = inquote = inchar = incomm = quotednl = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 tok.valid = savetok.valid = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 cblev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 parlev = 0;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2317 cplpl = (c_ext & C_PLPL) == C_PLPL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2318 cjava = (c_ext & C_JAVA) == C_JAVA;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2319 if (cjava)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2320 { qualifier = "."; qlen = 1; }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2321 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2322 { qualifier = "::"; qlen = 2; }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 c = *lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 if (c == '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 /* If we're at the end of the line, the next character is a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 '\0'; don't skip it, because it's the thing that tells us
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 to read the next line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 if (*lp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 quotednl = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 c = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 else if (incomm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 case '*':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 if (*lp == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 c = *lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 incomm = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 /* Newlines inside comments do not end macro definitions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 traditional cpp. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 CNL_SAVE_DEFINEDEF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 else if (inquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 case '"':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 /* Newlines inside strings do not end macro definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 in traditional cpp, even though compilers don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 usually accept them. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 CNL_SAVE_DEFINEDEF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 else if (inchar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 /* Hmmm, something went wrong. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 CNL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 inchar = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 case '"':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 inquote = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2394 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2395 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 inchar = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2399 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2400 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 case '/':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 if (*lp == '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 incomm = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2409 else if (/* cplpl && */ *lp == '/')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2411 c = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 case '%':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 if ((c_ext & YACC) && *lp == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 /* entering or exiting rules section in yacc file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 lp++;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2421 definedef = dnone; fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 typdef = tnone; structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 next_token_is_func = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 midtoken = inquote = inchar = incomm = quotednl = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 cblev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 yacc_rules = !yacc_rules;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 case '#':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 if (definedef == dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 char *cp;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2435 bool cpptoken = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 /* Look back on this line. If all blanks, or nonblanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 followed by an end of comment, this is a preprocessor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 token. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 for (cp = newlb.buffer; cp < lp-1; cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 if (!iswhite (*cp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 if (*cp == '*' && *(cp+1) == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 cpptoken = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 cpptoken = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 if (cpptoken)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 definedef = dsharpseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 } /* if (definedef == dnone) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 } /* switch (c) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 /* Consider token only if some complicated conditions are satisfied. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 if ((definedef != dnone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 || (cblev == 0 && structdef != scolonseen)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2462 || (cblev == 1 && cplpl && structdef == sinbody)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2463 || (structdef == sinbody && structtype == st_C_enum))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 && typdef != tignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 && definedef != dignorerest
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2466 && fvdef != finlist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 if (midtoken)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 if (endtoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2472 if (c == ':' && cplpl && *lp == ':' && begtoken(*(lp + 1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 * This handles :: in the middle, but not at the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 * beginning of an identifier.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 lp += 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 toklen += 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2483 bool funorvar = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 if (yacc_rules
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2486 || consider_token (newlb.buffer + tokoff, toklen, c,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2487 c_ext, cblev, parlev, &funorvar))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2489 tok.named = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 if (structdef == sinbody
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 && definedef == dnone
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2492 && funorvar)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2493 /* function or var defined in C++ class body */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2495 int len = strlen (structtag) + qlen + toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2496 grow_linebuffer (&token_name, len + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 strcpy (token_name.buffer, structtag);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2498 strcat (token_name.buffer, qualifier);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 strncat (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2500 newlb.buffer + tokoff, toklen);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2501 token_name.len = len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 tok.named = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2504 else if (objdef == ocatseen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2505 /* Objective C category */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2506 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2507 int len = strlen (objtag) + 2 + toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2508 grow_linebuffer (&token_name, len + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2509 strcpy (token_name.buffer, objtag);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2510 strcat (token_name.buffer, "(");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2511 strncat (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2512 newlb.buffer + tokoff, toklen);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2513 strcat (token_name.buffer, ")");
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2514 token_name.len = len;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2515 tok.named = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2516 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2517 else if (objdef == omethodtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2518 || objdef == omethodparm)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2519 /* Objective C method */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2520 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2521 tok.named = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2522 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2525 grow_linebuffer (&token_name, toklen + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 strncpy (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2527 newlb.buffer + tokoff, toklen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 token_name.buffer[toklen] = '\0';
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2529 token_name.len = toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2530 /* Name macros. */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2531 tok.named = (structdef == stagseen
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2532 || typdef == tend
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2533 || (funorvar
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2534 && definedef == dignorerest));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 tok.lineno = lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 tok.linelen = tokoff + toklen + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 tok.buffer = newlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 tok.linepos = newlinepos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 tok.valid = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 if (definedef == dnone
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2543 && (fvdef == fvnameseen
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 || structdef == stagseen
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2545 || typdef == tend
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2546 || objdef != onone))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 if (current_lb_is_new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 switch_line_buffers ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 else
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2552 make_C_tag (funorvar);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 midtoken = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 } /* if (endtoken (c)) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 else if (intoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 toklen++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 } /* if (midtoken) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 else if (begtoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 switch (definedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 case dnone:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2568 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 case fstartlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2571 fvdef = finlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2574 make_C_tag (TRUE); /* a function */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2575 fvdef = fignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2577 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2578 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 }
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2581 if (structdef == stagseen && !cjava)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 case dsharpseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 savetok = tok;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 if (!yacc_rules || lp == newlb.buffer + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 tokoff = lp - 1 - newlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 toklen = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591 midtoken = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2593 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2594 } /* if (begtoken) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2595 } /* if must look at token */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2597
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2598 /* Detect end of line, colon, comma, semicolon and various braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2599 after having handled a token.*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2600 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2601 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2602 case ':':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2603 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2604 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2605 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2606 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2607 case otagseen:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2608 objdef = oignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2609 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2610 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2611 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2612 case omethodparm:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2613 objdef = omethodcolon;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2614 methodlen += 1;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2615 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2616 strcat (token_name.buffer, ":");
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2617 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2618 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2619 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2620 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2621 structdef = scolonseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 else
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2623 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2625 case fvnameseen:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 if (yacc_rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2628 make_C_tag (FALSE); /* a yacc function */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2629 fvdef = fignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2630 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2631 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 case fstartlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2633 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2634 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2635 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2636 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2637 case ';':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2638 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2639 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 if (cblev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 case tend:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2644 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2646 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2647 typdef = tnone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2649 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2651 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2652 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2653 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2654 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2655 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2656 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2657 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2658 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2659 /* The following instruction invalidates the token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660 Probably the token should be invalidated in all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 other cases where some state machine is reset. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 tok.valid = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2667 case ',':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2670 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2671 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2672 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2673 case omethodparm:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2674 make_C_tag (TRUE); /* an Objective C method */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2675 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2676 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2677 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2678 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2679 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2680 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2681 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2682 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2683 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2684 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2685 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2686 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2687 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2688 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2689 fvdef = fvnone;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2690 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2691 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 case '[':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 if (cblev == 0 && typdef == tend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 typdef = tignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2700 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2703 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2704 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2705 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2706 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2707 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2708 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2709 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2710 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2711 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2712 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2713 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2714 fvdef = fvnone;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2715 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2718 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 case '(':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2722 if (objdef == otagseen && parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2723 objdef = oparenseen;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2724 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2726 case fvnone:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2728 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2729 case ttypedseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 case tend:
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2731 if (tok.valid && *lp != '*')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2732 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2733 /* This handles constructs like:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2734 typedef void OperatorFun (int fun); */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2735 make_C_tag (FALSE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 typdef = tignore;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2739 } /* switch (typdef) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2740 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2741 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2742 fvdef = fstartlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2743 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2745 fvdef = finlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 parlev++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 case ')':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2752 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2753 if (objdef == ocatseen && parlev == 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2754 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2755 make_C_tag (TRUE); /* an Objective C category */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2756 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2757 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 if (--parlev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2760 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 case fstartlist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 case finlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2764 fvdef = flistseen;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 if (cblev == 0 && typdef == tend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 typdef = tignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2770 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 parlev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 case '{':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2778 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779 if (typdef == ttypedseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 typdef = tinbody;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 switch (structdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 case skeyseen: /* unnamed struct */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2784 structdef = sinbody;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 structtag = "_anonymous_";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 case stagseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 case scolonseen: /* named struct */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 structdef = sinbody;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2790 make_C_tag (FALSE); /* a struct */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2793 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2796 make_C_tag (TRUE); /* a function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 case fignore:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2799 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2801 case fvnone:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2802 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2803 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2804 case otagseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2805 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2806 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2807 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2808 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2809 case omethodparm:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2810 make_C_tag (TRUE); /* an Objective C method */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2811 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2812 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2813 default:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2814 /* Neutralize `extern "C" {' grot. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2815 if (cblev == 0 && structdef == snone && typdef == tnone)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2816 cblev = -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2817 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2818 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2819 cblev++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2821 case '*':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2822 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 break;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2824 if (fvdef == fstartlist)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2825 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2826 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2827 case '}':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 if (!noindentypedefs && lp == newlb.buffer + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2832 cblev = 0; /* reset curly brace level if first column */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2833 parlev = 0; /* also reset paren level, just in case... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2835 else if (cblev > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2836 cblev--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2837 if (cblev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2838 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2839 if (typdef == tinbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2840 typdef = tend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2841 /* Memory leakage here: the string pointed by structtag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2842 never released, because I fear to miss something and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2843 break things while freeing the area. The amount of
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2844 memory leaked here is the sum of the lengths of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2845 struct tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2846 if (structdef == sinbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2847 free (structtag); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2849 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 structtag = "<error>";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2851 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2852 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2853 case '=':
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2854 if (definedef != dnone)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2855 break;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2856 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2857 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2858 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2859 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2860 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2861 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2862 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2863 if ((globals && cblev == 0) || (members && cblev == 1))
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2864 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2865 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2866 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2867 fvdef = vignore;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2868 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2869 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2870 case '+':
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2871 case '-':
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2872 if (objdef == oinbody && cblev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2873 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2874 objdef = omethodsign;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2875 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2876 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2877 /* FALLTHRU */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2878 case '#': case '~': case '&': case '%': case '/': case '|':
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2879 case '^': case '!': case '<': case '>': case '.': case '?': case ']':
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2880 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2881 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 /* These surely cannot follow a function tag. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2883 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2884 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2886 case '\0':
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2887 if (objdef == otagseen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2888 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2889 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2890 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2891 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2892 /* If a macro spans multiple lines don't reset its state. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2893 if (quotednl)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2894 CNL_SAVE_DEFINEDEF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2895 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2896 CNL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2897 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 } /* switch (c) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 } /* while not eof */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904 * Process either a C++ file or a C file depending on the setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 * of a global flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2906 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2907 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2908 default_C_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2909 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2910 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 C_entries (cplusplus ? C_PLPL : 0, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 /* Always do plain ANSI C. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2916 plain_C_entries (inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 FILE *inf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 C_entries (0, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2922 /* Always do C++. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2924 Cplusplus_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2925 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 C_entries (C_PLPL, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2930 /* Always do Java. */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2931 void
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2932 Cjava_entries (inf)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2933 FILE *inf;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2934 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2935 C_entries (C_JAVA, inf);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2936 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2937
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 /* Always do C*. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2939 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2940 Cstar_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2941 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2942 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2943 C_entries (C_STAR, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2946 /* Always do Yacc. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2948 Yacc_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2949 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 C_entries (YACC, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 /* Fortran parsing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 char *dbp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2958 bool
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2959 tail (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2960 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962 register int len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 while (*cp && lowcase(*cp) == lowcase(dbp[len]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 cp++, len++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 if (*cp == '\0' && !intoken(dbp[len]))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 dbp += len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2970 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2971 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2972 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2973
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2974 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2975 takeprec ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2976 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2977 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2978 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2979 if (*dbp != '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2980 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2981 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2982 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2983 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2984 if (strneq (dbp, "(*)", 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 dbp += 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2988 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 if (!isdigit (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2990 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 --dbp; /* force failure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2993 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2994 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 while (isdigit (*dbp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2998
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2999 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3000 getit (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3001 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3010 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 if (dbp[5] != '&')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3015 dbp += 6;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3017 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3018 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3019 if (!isalpha (*dbp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3020 && *dbp != '_'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3021 && *dbp != '$')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3022 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3023 for (cp = dbp + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3024 (*cp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3025 && (isalpha (*cp) || isdigit (*cp) || (*cp == '_') || (*cp == '$')));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3026 cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3027 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3028 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3029 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3030 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3031
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3032 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3033 Fortran_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3034 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3045 if (*dbp == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3046 dbp++; /* Ratfor escape to fortran */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3047 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3048 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3049 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3050 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3051 switch (lowcase (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3052 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3053 case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3054 if (tail ("integer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3055 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3056 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3057 case 'r':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3058 if (tail ("real"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3059 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3060 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3061 case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3062 if (tail ("logical"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3063 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3064 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3065 case 'c':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3066 if (tail ("complex") || tail ("character"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3067 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 case 'd':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 if (tail ("double"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 if (tail ("precision"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3077 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3080 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3081 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3082 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3083 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3084 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3085 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3086 switch (lowcase (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3087 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3088 case 'f':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3089 if (tail ("function"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3090 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3091 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3092 case 's':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3093 if (tail ("subroutine"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3094 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 case 'e':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 if (tail ("entry"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3101 if (tail ("program"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3102 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3103 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3105 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3106 if (tail ("procedure"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3107 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3108 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3109 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3111 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3113 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3114 * Bob Weiner, Motorola Inc., 4/3/94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3115 * Unix and microcontroller assembly tag handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3116 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3117 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3118 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3119 Asm_labels (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3120 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3121 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3129 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3130 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3131 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3132 cp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 /* If first char is alphabetic or one of [_.$], test for colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 following identifier. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3136 if (isalpha (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 /* Read past label. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3140 while (isalnum (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 if (*cp == ':' || isspace (*cp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3143 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 /* Found end of label, so copy it and add it to the table. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3145 pfnote ((CTAGS) ? savenstr(lb.buffer, cp-lb.buffer) : NULL, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3146 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3147 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3148 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3149 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 * Perl support by Bart Robinson <lomew@cs.utah.edu>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3155 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 Perl_functions (inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 FILE *inf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3160 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3166 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3169 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 cp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3172 if (*cp++ == 's' && *cp++ == 'u' && *cp++ == 'b' && isspace (*cp++))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3174 while (*cp && isspace (*cp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3175 cp++;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3176 while (*cp && ! isspace (*cp) && *cp != '{')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3177 cp++;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3178 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : NULL, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3179 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3180 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3181 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3182 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3183
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3184 /* Idea by Corny de Souza
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3185 * Cobol tag functions
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3186 * We could look for anything that could be a paragraph name.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3187 * i.e. anything that starts in column 8 is one word and ends in a full stop.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3188 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3189 void
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3190 Cobol_paragraphs (inf)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3191 FILE *inf;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3192 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3193 register char *cp;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3194
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3195 lineno = 0;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3196 charno = 0;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3197
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3198 while (!feof (inf))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3199 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3200 lineno++;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3201 linecharno = charno;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3202 charno += readline (&lb, inf);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3203
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3204 if (lb.len < 9)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3205 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3206 dbp = lb.buffer + 8;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3207
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3208 /* If eoln, compiler option or comment ignore whole line. */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3209 if (dbp[-1] != ' ' || !isalnum (dbp[0]))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3210 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3211
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3212 for (cp = dbp; isalnum (*cp) || *cp == '-'; cp++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3213 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3214 if (*cp++ == '.')
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3215 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3216 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3217 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3218 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3219
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3220 /* Added by Mosur Mohan, 4/22/88 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 /* Pascal parsing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224 * Locates tags for procedures & functions. Doesn't do any type- or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 * var-definitions. It does look for the keyword "extern" or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 * "forward" immediately following the procedure statement; if found,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 * the tag is skipped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3229 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3230 Pascal_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3231 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3232 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3233 struct linebuffer tline; /* mostly copied from C_entries */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3234 long save_lcno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3235 int save_lineno, save_len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3236 char c, *cp, *namebuf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3237
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3238 bool /* each of these flags is TRUE iff: */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3239 incomment, /* point is inside a comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3240 inquote, /* point is inside '..' string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3241 get_tagname, /* point is after PROCEDURE/FUNCTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3242 keyword, so next item = potential tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3243 found_tag, /* point is after a potential tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3244 inparms, /* point is within parameter-list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3245 verify_tag; /* point has passed the parm-list, so the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3246 next token will determine whether this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3247 is a FORWARD/EXTERN to be ignored, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3248 whether it is a real tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3250 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3251 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3252 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3253 *dbp = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3254 save_len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3255 initbuffer (&tline);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3256
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3257 incomment = inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 found_tag = FALSE; /* have a proc name; check if extern */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 get_tagname = FALSE; /* have found "procedure" keyword */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3260 inparms = FALSE; /* found '(' after "proc" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3261 verify_tag = FALSE; /* check if "extern" is ahead */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3263 /* long main loop to get next char */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3264 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3265 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3266 c = *dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3267 if (c == '\0') /* if end of line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3268 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3269 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3270 linecharno = charno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3271 charno += readline (&lb, inf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3272 dbp = lb.buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3273 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3274 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3275 if (!((found_tag && verify_tag) ||
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3276 get_tagname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3277 c = *dbp++; /* only if don't need *dbp pointing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 to the beginning of the name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 the procedure or function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3280 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 if (incomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3282 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 if (c == '}') /* within { } comments */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 incomment = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285 else if (c == '*' && *dbp == ')') /* within (* *) comments */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288 incomment = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 else if (inquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3293 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3294 if (c == '\'')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3295 inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3301 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 inquote = TRUE; /* found first quote */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 case '{': /* found open { comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 incomment = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307 case '(':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 if (*dbp == '*') /* found open (* comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3309 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3310 incomment = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3311 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 else if (found_tag) /* found '(' after tag, i.e., parm-list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 inparms = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3316 case ')': /* end of parms list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3317 if (inparms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3318 inparms = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3319 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3320 case ';':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3321 if (found_tag && !inparms) /* end of proc or fn stmt */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3322 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3323 verify_tag = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3325 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3326 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3327 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 if (found_tag && verify_tag && (*dbp != ' '))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 /* check if this is an "extern" declaration */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3333 if (lowcase (*dbp == 'e'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3334 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3335 if (tail ("extern")) /* superfluous, really! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 verify_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3340 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3341 else if (lowcase (*dbp) == 'f')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3343 if (tail ("forward")) /* check for forward reference */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3344 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3345 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3346 verify_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3347 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3348 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3349 if (found_tag && verify_tag) /* not external proc, so make tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3350 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3351 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3352 verify_tag = FALSE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3353 pfnote (namebuf, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3354 tline.buffer, save_len, save_lineno, save_lcno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3355 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3356 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3357 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3358 if (get_tagname) /* grab name of proc or fn */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3359 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3360 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3361 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3363 /* save all values for later tagging */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
3364 grow_linebuffer (&tline, lb.len + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3365 strcpy (tline.buffer, lb.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 save_lineno = lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367 save_lcno = linecharno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3368
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3369 /* grab block name */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3370 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3371 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3372 namebuf = (CTAGS) ? savenstr (dbp, cp-dbp) : NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3373 dbp = cp; /* set dbp to e-o-token */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3374 save_len = dbp - lb.buffer + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 get_tagname = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 found_tag = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 /* and proceed to check for "extern" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3380 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 else if (!incomment && !inquote && !found_tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 /* check for proc/fn keywords */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 switch (lowcase (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3388 get_tagname = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3389 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 case 'f':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3391 if (tail ("unction"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 get_tagname = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3395 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 } /* while not eof */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 free (tline.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3401 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 * lisp tag functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 * look for (def or (DEF, quote or QUOTE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3405 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3406 L_isdef (strp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3407 register char *strp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3408 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 return ((strp[1] == 'd' || strp[1] == 'D')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410 && (strp[2] == 'e' || strp[2] == 'E')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3411 && (strp[3] == 'f' || strp[3] == 'F'));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3412 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3413
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3414 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3415 L_isquote (strp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3416 register char *strp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3417 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 return ((*(++strp) == 'q' || *strp == 'Q')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 && (*(++strp) == 'u' || *strp == 'U')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 && (*(++strp) == 'o' || *strp == 'O')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 && (*(++strp) == 't' || *strp == 'T')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 && (*(++strp) == 'e' || *strp == 'E')
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3423 && isspace (*(++strp)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3426 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3427 L_getit ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3429 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3431 if (*dbp == '\'') /* Skip prefix quote */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3433 else if (*dbp == '(' && L_isquote (dbp)) /* Skip "(quote " */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3434 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 dbp += 7;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3436 while (isspace (*dbp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3437 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3438 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3439 for (cp = dbp /*+1*/;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3440 *cp != '\0' && *cp != '(' && *cp != ' ' && *cp != ')';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3442 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 if (cp == dbp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3446 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3447 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3451 Lisp_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3452 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 if (dbp[0] == '(')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 if (L_isdef (dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 while (!isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3470 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 L_getit ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 /* Check for (foo::defmumble name-defined ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 while (*dbp && !isspace (*dbp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3479 && *dbp != ':' && *dbp != '(' && *dbp != ')');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 if (*dbp == ':')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 while (*dbp == ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 if (L_isdef (dbp - 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 while (!isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 L_getit ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3496 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3497 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3500 /*
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3501 * Postscript tag functions
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3502 * Just look for lines where the first character is '/'
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3503 * Richard Mlynarik <mly@adoc.xerox.com>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3504 */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3505 void
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3506 Postscript_functions (inf)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3507 FILE *inf;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3508 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3509 lineno = 0;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3510 charno = 0;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3511
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3512 while (!feof (inf))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3513 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3514 lineno++;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3515 linecharno = charno;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3516 charno += readline (&lb, inf);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3517 dbp = lb.buffer;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3518 if (dbp[0] == '/')
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3519 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3520 register char *cp;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3521 for (cp = dbp+1;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3522 *cp != '\0' && *cp != ' ' && *cp != '{';
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3523 cp++)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3524 continue;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3525 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3526 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3527 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3528 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3529 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3530
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3531
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3532 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3533 * Scheme tag functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3534 * look for (def... xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3535 * look for (def... (xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3536 * look for (def ... ((...(xyzzy ....
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3537 * look for (set! xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3538 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3539
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3540 void get_scheme ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3542 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3543 Scheme_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3544 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3545 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3546 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3547 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3548
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3549 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3550 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3551 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3552 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3553 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3554 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3555 if (dbp[0] == '(' &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3556 (dbp[1] == 'D' || dbp[1] == 'd') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3557 (dbp[2] == 'E' || dbp[2] == 'e') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3558 (dbp[3] == 'F' || dbp[3] == 'f'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3559 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3560 while (!isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3561 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3562 /* Skip over open parens and white space */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3563 while (*dbp && (isspace (*dbp) || *dbp == '('))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3564 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3565 get_scheme ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3566 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3567 if (dbp[0] == '(' &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3568 (dbp[1] == 'S' || dbp[1] == 's') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3569 (dbp[2] == 'E' || dbp[2] == 'e') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3570 (dbp[3] == 'T' || dbp[3] == 't') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3571 (dbp[4] == '!' || dbp[4] == '!') &&
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3572 (isspace (dbp[5])))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3573 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3574 while (!isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3575 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3576 /* Skip over white space */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3577 while (isspace (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3578 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3579 get_scheme ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3580 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3581 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3582 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3584 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3585 get_scheme ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3586 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3587 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3589 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3590 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3591 /* Go till you get to white space or a syntactic break */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3592 for (cp = dbp + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3593 *cp && *cp != '(' && *cp != ')' && !isspace (*cp);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3594 cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3595 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3596 pfnote ((CTAGS) ? savenstr (dbp, cp-dbp) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3597 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3598 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3600 /* Find tags in TeX and LaTeX input files. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3601
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3602 /* TEX_toktab is a table of TeX control sequences that define tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3603 Each TEX_tabent records one such control sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3604 CONVERT THIS TO USE THE Stab TYPE!! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3605 struct TEX_tabent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3606 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3607 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3608 int len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3609 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3611 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3613 /* Default set of control sequences to put into TEX_toktab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3614 The value of environment var TEXTAGS is prepended to this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3615
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3616 char *TEX_defenv = "\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3617 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3618 :part:appendix:entry:index";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3619
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3620 void TEX_mode ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3621 struct TEX_tabent *TEX_decode_env ();
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3622 int TEX_Token ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3624 char TEX_esc = '\\';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3625 char TEX_opgrp = '{';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3626 char TEX_clgrp = '}';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3628 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3629 * TeX/LaTeX scanning loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3630 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3631 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3632 TeX_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3633 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3634 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3635 char *lasthit;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3636 register int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3637
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3638 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3639 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3641 /* Select either \ or ! as escape character. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3642 TEX_mode (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3643
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3644 /* Initialize token table once from environment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3645 if (!TEX_toktab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3646 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3648 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3649 { /* Scan each line in file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3650 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3651 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3652 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3653 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3654 lasthit = dbp;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3655 while (dbp = etags_strchr (dbp, TEX_esc)) /* Look at each esc in line */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3656 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3657 if (!*(++dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3658 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3659 linecharno += dbp - lasthit;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3660 lasthit = dbp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3661 i = TEX_Token (lasthit);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3662 if (i >= 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3663 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3664 /* We seem to include the TeX command in the tag name.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3665 register char *p;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3666 for (p = lasthit + TEX_toktab[i].len;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3667 *p != '\0' && *p != TEX_clgrp;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3668 p++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3669 continue; */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3670 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
3671 lb.buffer, lb.len, lineno, linecharno);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3672 break; /* We only tag a line once */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3673 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3674 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3675 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3676 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3677
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3678 #define TEX_LESC '\\'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3679 #define TEX_SESC '!'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 #define TEX_cmt '%'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 chars accordingly. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3684 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3685 TEX_mode (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3686 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3687 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3688 int c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3690 while ((c = getc (inf)) != EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692 /* Skip to next line if we hit the TeX comment char. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 if (c == TEX_cmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3694 while (c != '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695 c = getc (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 else if (c == TEX_LESC || c == TEX_SESC )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3698 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3700 if (c == TEX_LESC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 TEX_esc = TEX_LESC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3703 TEX_opgrp = '{';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 TEX_clgrp = '}';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 TEX_esc = TEX_SESC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709 TEX_opgrp = '<';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 TEX_clgrp = '>';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3712 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3714
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 /* Read environment and prepend it to the default string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3716 Build token table. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 struct TEX_tabent *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3718 TEX_decode_env (evarname, defenv)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3719 char *evarname;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3720 char *defenv;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3722 register char *env, *p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3724 struct TEX_tabent *tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3725 int size, i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3727 /* Append default string to environment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3728 env = getenv (evarname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3729 if (!env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3730 env = defenv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3731 else
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3732 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3733 char *oldenv = env;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3734 env = concat (oldenv, defenv, "");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3735 free (oldenv);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3736 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3738 /* Allocate a token table */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3739 for (size = 1, p = env; p;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3740 if ((p = etags_strchr (p, ':')) && *(++p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3741 size++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3742 /* Add 1 to leave room for null terminator. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3743 tab = xnew (size + 1, struct TEX_tabent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3744
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3745 /* Unpack environment string into token table. Be careful about */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3746 /* zero-length strings (leading ':', "::" and trailing ':') */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3747 for (i = 0; *env;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3748 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3749 p = etags_strchr (env, ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3750 if (!p) /* End of environment string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3751 p = env + strlen (env);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3752 if (p - env > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3753 { /* Only non-zero strings. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3754 tab[i].name = savenstr (env, p - env);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3755 tab[i].len = strlen (tab[i].name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3756 i++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3757 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3758 if (*p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3759 env = p + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3760 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3761 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3762 tab[i].name = NULL; /* Mark end of table. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3763 tab[i].len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3764 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3765 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3766 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3767 return tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3768 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3770 /* If the text at CP matches one of the tag-defining TeX command names,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3771 return the pointer to the first occurrence of that command in TEX_toktab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3772 Otherwise return -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3773 Keep the capital `T' in `Token' for dumb truncating compilers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3774 (this distinguishes it from `TEX_toktab' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3775 int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3776 TEX_Token (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3777 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3778 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3779 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3781 for (i = 0; TEX_toktab[i].len > 0; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3782 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3783 return i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3784 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3785 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3786
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3787 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3788 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3789 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3790 * Assumes that the predicate starts at column 0.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3791 * Only the first clause of a predicate is added.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3792 */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3793 int prolog_pred ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3794 void prolog_skip_comment ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3795 int prolog_atom ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3796 int eat_white ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3797
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3798 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3799 Prolog_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3800 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3802 char * last;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3803 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3804 int allocated;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3805
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3806 allocated = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3807 len = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3808 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3809
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3810 lineno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3811 linecharno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3812 charno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3813
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3817 linecharno += charno;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3818 charno = readline (&lb, inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3819 dbp = lb.buffer;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3820 if (dbp[0] == '\0') /* Empty line */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3821 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3822 else if (isspace (dbp[0])) /* Not a predicate */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3823 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3824 else if (dbp[0] == '/' && dbp[1] == '*') /* comment. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3825 prolog_skip_comment (&lb, inf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3826 else if (len = prolog_pred (dbp, last))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3827 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3828 /* Predicate. Store the function name so that we only
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
3829 generate a tag for the first clause. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3830 if (last == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3831 last = xnew(len + 1, char);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3832 else if (len + 1 > allocated)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3833 last = (char *) xrealloc(last, len + 1);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3834 allocated = len + 1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3835 strncpy (last, dbp, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3836 last[len] = '\0';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3837 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3838 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3839 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3840
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3841
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3842 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3843 prolog_skip_comment (plb, inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3844 struct linebuffer *plb;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3845 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851 for (cp = plb->buffer; *cp != '\0'; cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852 if (cp[0] == '*' && cp[1] == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853 return;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3854 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3855 linecharno += readline (plb, inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3856 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3857 while (!feof(inf));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3859
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3860 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3861 * A predicate definition is added if it matches:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3862 * <beginning of line><Prolog Atom><whitespace>(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3863 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3864 * It is added to the tags database if it doesn't match the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3865 * name of the previous clause header.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3866 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3867 * Return the size of the name of the predicate, or 0 if no header
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3868 * was found.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3869 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3870 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3871 prolog_pred (s, last)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3872 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3873 char *last; /* Name of last clause. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3874 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3875 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3876 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3877
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3878 pos = prolog_atom (s, 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3879 if (pos < 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3880 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3881
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3882 len = pos;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3883 pos += eat_white (s, pos);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3884
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3885 if ((s[pos] == '(') || (s[pos] == '.'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3886 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3887 if (s[pos] == '(')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3888 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3889
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3890 /* Save only the first clause. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3891 if (last == NULL
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3892 || len != strlen (last)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3893 || !strneq (s, last, len))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3894 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3895 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3896 s, pos, lineno, linecharno);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3897 return len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3898 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3899 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3900 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3901 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3902
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3903 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3904 * Consume a Prolog atom.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3905 * Return the number of bytes consumed, or -1 if there was an error.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3906 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3907 * A prolog atom, in this context, could be one of:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3908 * - An alphanumeric sequence, starting with a lower case letter.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3909 * - A quoted arbitrary string. Single quotes can escape themselves.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3910 * Backslash quotes everything.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3911 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3912 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3913 prolog_atom (s, pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3914 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3915 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3916 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3917 int origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3918
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3919 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3920
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3921 if (islower(s[pos]) || (s[pos] == '_'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3922 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3923 /* The atom is unquoted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3924 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3925 while (isalnum(s[pos]) || (s[pos] == '_'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3926 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3927 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3928 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3929 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3930 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3931 else if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3932 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3933 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3934
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3935 while (1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3936 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3937 if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3938 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3939 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3940 if (s[pos] != '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3941 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3942 pos++; /* A double quote */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3943 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3944 else if (s[pos] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3945 /* Multiline quoted atoms are ignored. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3946 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3947 else if (s[pos] == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3948 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3949 if (s[pos+1] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3950 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3951 pos += 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3952 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3953 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3954 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3955 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3956 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3957 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3958 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3959 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3960 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3961
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3962 /* Consume whitespace. Return the number of bytes eaten. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3963 int
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3964 eat_white (s, pos)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3965 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3966 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3967 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3968 int origpos = pos;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3969
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3970 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3971
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3972 while (isspace (s[pos]))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3973 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3974
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3975 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3976 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3977
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3978 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3979 * Support for Erlang -- Anders Lindgren, Feb 1996.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3980 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3981 * Generates tags for functions, defines, and records.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3982 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3983 * Assumes that Erlang functions start at column 0.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3984 */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3985 int erlang_func ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3986 void erlang_attribute ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3987 int erlang_atom ();
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3988
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3989 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3990 Erlang_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3991 FILE *inf;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3992 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3993 char * last;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3994 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3995 int allocated;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3996
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3997 allocated = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3998 len = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3999 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4000
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4001 lineno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4002 linecharno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4003 charno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4004
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4005 while (!feof (inf))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4006 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4007 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4008 linecharno += charno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4009 charno = readline (&lb, inf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4010 dbp = lb.buffer;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4011 if (dbp[0] == '\0') /* Empty line */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4012 continue;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4013 else if (isspace (dbp[0])) /* Not function nor attribute */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4014 continue;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4015 else if (dbp[0] == '%') /* comment */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4016 continue;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4017 else if (dbp[0] == '"') /* Sometimes, strings start in column one */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4018 continue;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4019 else if (dbp[0] == '-') /* attribute, e.g. "-define" */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4020 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4021 erlang_attribute (dbp);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4022 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4023 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4024 else if (len = erlang_func (dbp, last))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4025 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4026 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4027 * Function. Store the function name so that we only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4028 * generates a tag for the first clause.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4029 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4030 if (last == NULL)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4031 last = xnew (len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4032 else if (len + 1 > allocated)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4033 last = (char *) xrealloc (last, len + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4034 allocated = len + 1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4035 strncpy (last, dbp, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4036 last[len] = '\0';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4037 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4038 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4039 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4040
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4041
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4042 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4043 * A function definition is added if it matches:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4044 * <beginning of line><Erlang Atom><whitespace>(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4045 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4046 * It is added to the tags database if it doesn't match the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4047 * name of the previous clause header.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4048 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4049 * Return the size of the name of the function, or 0 if no function
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4050 * was found.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4051 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4052 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4053 erlang_func (s, last)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4054 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4055 char *last; /* Name of last clause. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4056 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4057 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4058 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4059
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4060 pos = erlang_atom (s, 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4061 if (pos < 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4062 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4063
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4064 len = pos;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4065 pos += eat_white (s, pos);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4066
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4067 /* Save only the first clause. */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4068 if (s[pos++] == '('
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4069 && (last == NULL
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4070 || len != strlen (last)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4071 || !strneq (s, last, len)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4072 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4073 pfnote ((CTAGS) ? savenstr (s, len) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4074 s, pos, lineno, linecharno);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4075 return len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4076 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4077
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4078 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4079 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4080
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4081
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4082 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4083 * Handle attributes. Currently, tags are generated for defines
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4084 * and records.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4085 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4086 * They are on the form:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4087 * -define(foo, bar).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4088 * -define(Foo(M, N), M+N).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4089 * -record(graph, {vtab = notable, cyclic = true}).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4090 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4091 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4092 erlang_attribute (s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4093 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4094 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4095 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4096 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4097
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4098 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4099 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4100 pos = 7 + eat_white (s, pos);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4101 if (s[pos++] == '(')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4102 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4103 pos += eat_white (s, pos);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4104 if (len = erlang_atom (s, pos))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4105 pfnote ((CTAGS) ? savenstr (& s[pos], len) : NULL, TRUE,
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4106 s, pos + len, lineno, linecharno);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4107 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4108 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4109 return;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4110 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4111
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4112
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4113 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4114 * Consume an Erlang atom (or variable).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4115 * Return the number of bytes consumed, or -1 if there was an error.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4116 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4117 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4118 erlang_atom (s, pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4119 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4120 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4121 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4122 int origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4123
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4124 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4125
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4126 if (isalpha (s[pos]) || s[pos] == '_')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4127 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4128 /* The atom is unquoted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4129 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4130 while (isalnum (s[pos]) || s[pos] == '_')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4131 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4132 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4133 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4134 else if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4135 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4136 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4137
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4138 while (1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4139 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4140 if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4141 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4142 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4143 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4144 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4145 else if (s[pos] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4146 /* Multiline quoted atoms are ignored. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4147 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4148 else if (s[pos] == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4149 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4150 if (s[pos+1] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4151 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4152 pos += 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4153 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4154 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4155 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4156 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4157 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4158 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4159 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4160 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4161 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 /* Take a string like "/blah/" and turn it into "blah", making sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165 that the first and last characters are the same, and handling
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4166 quoted separator characters. Actually, stops on the occurrence of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4167 an unquoted separator. Also turns "\t" into a Tab character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4168 Returns pointer to terminating separator. Works in place. Null
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4169 terminates name string. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4170 char *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4171 scan_separators (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4172 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4174 char sep = name[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4175 char *copyto = name;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
4176 bool quoted = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 for (++name; *name != '\0'; ++name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180 if (quoted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4182 if (*name == 't')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4183 *copyto++ = '\t';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 else if (*name == sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4185 *copyto++ = sep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4186 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4188 /* Something else is quoted, so preserve the quote. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4189 *copyto++ = '\\';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4190 *copyto++ = *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4192 quoted = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4193 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4194 else if (*name == '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 quoted = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 else if (*name == sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 *copyto++ = *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202 /* Terminate copied string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 *copyto = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204 return name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4206
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4207 /* Look at the argument of --regex or --no-regex and do the right
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4208 thing. */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4209 void
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4210 analyse_regex (regex_arg)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4211 char *regex_arg;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4212 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4213 struct stat stat_buf;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4214
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4215 if (regex_arg == NULL)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4216 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4217 /* Remove existing regexps. */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4218 num_patterns = 0;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4219 patterns = NULL;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4220 return;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4221 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4222 if (regex_arg[0] == '\0')
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4223 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4224 error ("missing regexp", (char *)NULL);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4225 return;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4226 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4227 if (regex_arg[0] == '@'
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4228 && stat (regex_arg + 1, &stat_buf) == 0)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4229 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4230 FILE *regexfp;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4231 struct linebuffer regexbuf;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4232 char *regexfile = regex_arg + 1;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4233
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4234 /* regexfile is a file containing regexps, one per line. */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4235 regexfp = fopen (regexfile, "r");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4236 if (regexfp == NULL)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4237 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4238 perror (regexfile);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4239 return;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4240 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4241 initbuffer (&regexbuf);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4242 while (readline_internal (&regexbuf, regexfp))
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4243 add_regex (regexbuf.buffer);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4244 free (regexbuf.buffer);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4245 fclose (regexfp);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4246 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4247 else
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4248 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4249 add_regex (regex_arg);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4250 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4251 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4252
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4253 /* Turn a name, which is an ed-style (but Emacs syntax) regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 expression, into a real regular expression by compiling it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4255 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4256 add_regex (regexp_pattern)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4257 char *regexp_pattern;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4258 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4259 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4260 const char *err;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4261 struct re_pattern_buffer *patbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4262
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4263
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4264 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4265 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 error ("%s: unterminated regexp", regexp_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 name = scan_separators (regexp_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270 if (regexp_pattern[0] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4272 error ("null regexp", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 (void) scan_separators (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4277 patbuf = xnew (1, struct re_pattern_buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4278 patbuf->translate = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4279 patbuf->fastmap = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280 patbuf->buffer = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 patbuf->allocated = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4283 re_syntax_options = RE_INTERVALS;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 if (err != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4287 error ("%s while compiling pattern", err);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 num_patterns += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292 if (num_patterns == 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293 patterns = xnew (1, struct pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295 patterns = ((struct pattern *)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 xrealloc (patterns,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297 (num_patterns * sizeof (struct pattern))));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298 patterns[num_patterns - 1].pattern = patbuf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 patterns[num_patterns - 1].name_pattern = savestr (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300 patterns[num_patterns - 1].error_signaled = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304 * Do the substitutions indicated by the regular expression and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4305 * arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4306 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4307 char *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4308 substitute (in, out, regs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4309 char *in, *out;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4310 struct re_registers *regs;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4312 char *result, *t;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4313 int size, dig, diglen;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4314
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4315 result = NULL;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4316 size = strlen (out);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4317
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4318 /* Pass 1: figure out how much to allocate by finding all \N strings. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4319 if (out[size - 1] == '\\')
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4320 fatal ("pattern error in \"%s\"", out);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4321 for (t = etags_strchr (out, '\\');
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4322 t != NULL;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4323 t = etags_strchr (t + 2, '\\'))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4324 if (isdigit (t[1]))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4325 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4326 dig = t[1] - '0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4327 diglen = regs->end[dig] - regs->start[dig];
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4328 size += diglen - 2;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4329 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4330 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4331 size -= 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 /* Allocate space and do the substitutions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4334 result = xnew (size + 1, char);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4335
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4336 for (t = result; *out != '\0'; out++)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4337 if (*out == '\\' && isdigit (*++out))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4338 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4339 /* Using "dig2" satisfies my debugger. Bleah. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4340 dig = *out - '0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4341 diglen = regs->end[dig] - regs->start[dig];
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4342 strncpy (t, in + regs->start[dig], diglen);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4343 t += diglen;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4344 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4345 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4346 *t++ = *out;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4347 *t = '\0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4348
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4349 if (DEBUG && (t > result + size || t - result != strlen (result)))
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4350 abort ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 /* Initialize a linebuffer for use */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4358 initbuffer (linebuffer)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4359 struct linebuffer *linebuffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361 linebuffer->size = 200;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362 linebuffer->buffer = xnew (200, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4365 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366 * Read a line of text from `stream' into `linebuffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4367 * Return the number of characters read from `stream',
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 * which is the length of the line including the newline, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4369 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4370 long
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4371 readline_internal (linebuffer, stream)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4372 struct linebuffer *linebuffer;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4373 register FILE *stream;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 char *buffer = linebuffer->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376 register char *p = linebuffer->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377 register char *pend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378 int chars_deleted;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4380 pend = p + linebuffer->size; /* Separate to avoid 386/IX compiler bug. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4382 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4383 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4384 register int c = getc (stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4385 if (p == pend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4386 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4387 linebuffer->size *= 2;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4388 buffer = (char *) xrealloc (buffer, linebuffer->size);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4389 p += buffer - linebuffer->buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4390 pend = buffer + linebuffer->size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4391 linebuffer->buffer = buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4392 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4393 if (c == EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4395 *p = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4396 chars_deleted = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4397 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4398 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4399 if (c == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4400 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4401 if (p > buffer && p[-1] == '\r')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4402 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4403 p -= 1;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4404 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4405 /* Assume CRLF->LF translation will be performed by Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4406 when loading this file, so CRs won't appear in the buffer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4407 It would be cleaner to compensate within Emacs;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4408 however, Emacs does not know how many CRs were deleted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4409 before any given point in the file. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4410 chars_deleted = 1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4411 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4412 chars_deleted = 2;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4413 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4414 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4415 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4416 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4417 chars_deleted = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4418 }
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4419 *p = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4420 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4421 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4422 *p++ = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 }
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4424 linebuffer->len = p - buffer;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4425
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4426 return linebuffer->len + chars_deleted;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4427 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4429 /*
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4430 * Like readline_internal, above, but in addition try to match the
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4431 * input line against any existing regular expressions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433 long
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4434 readline (linebuffer, stream)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4435 struct linebuffer *linebuffer;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4436 FILE *stream;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4438 /* Read new line. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4439 long result = readline_internal (linebuffer, stream);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4440 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4441 int i;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4442
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 /* Match against all listed patterns. */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4444 if (linebuffer->len > 0)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4445 for (i = 0; i < num_patterns; ++i)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4446 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4447 int match = re_match (patterns[i].pattern, linebuffer->buffer,
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4448 linebuffer->len, 0, &patterns[i].regs);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4449 switch (match)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4450 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4451 case -2:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4452 /* Some error. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4453 if (!patterns[i].error_signaled)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4454 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4455 error ("error while matching pattern %d", i);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4456 patterns[i].error_signaled = TRUE;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4457 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4458 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4459 case -1:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4460 /* No match. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4461 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4462 default:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4463 /* Match occurred. Construct a tag. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4464 if (patterns[i].name_pattern[0] != '\0')
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4465 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4466 /* Make a named tag. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4467 char *name = substitute (linebuffer->buffer,
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4468 patterns[i].name_pattern,
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4469 &patterns[i].regs);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4470 if (name != NULL)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4471 pfnote (name, TRUE,
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4472 linebuffer->buffer, match, lineno, linecharno);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4473 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4474 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4475 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4476 /* Make an unnamed tag. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4477 pfnote ((char *)NULL, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4478 linebuffer->buffer, match, lineno, linecharno);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4479 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4480 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4481 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4482 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4483 #endif /* ETAGS_REGEXPS */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4484
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4485 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4486 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4488 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4489 * Read a file, but do no processing. This is used to do regexp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4490 * matching on files that have no language defined.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4491 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4492 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4493 just_read_file (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4494 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4495 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4496 lineno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4497 charno = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4498
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4499 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4500 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4501 ++lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4502 linecharno = charno;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4503 charno += readline (&lb, inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4504 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4505 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4506
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4508 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4509 * Return a pointer to a space of size strlen(cp)+1 allocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4510 * with xnew where the string CP has been copied.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4511 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4512 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4513 savestr (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4514 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4515 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4516 return savenstr (cp, strlen (cp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4517 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4518
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4519 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4520 * Return a pointer to a space of size LEN+1 allocated with xnew where
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4521 * the string CP has been copied for at most the first LEN characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4522 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4523 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4524 savenstr (cp, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4525 char *cp;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4526 int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4527 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4528 register char *dp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4530 dp = xnew (len + 1, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4531 strncpy (dp, cp, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4532 dp[len] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4533 return dp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4534 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4536 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4537 * Return the ptr in sp at which the character c last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4538 * appears; NULL if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4539 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4540 * Identical to System V strrchr, included for portability.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4541 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4542 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4543 etags_strrchr (sp, c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4544 register char *sp, c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4545 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4546 register char *r;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4547
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4548 r = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4549 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4550 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4551 if (*sp == c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4552 r = sp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4553 } while (*sp++);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4554 return r;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4555 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4557
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4558 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4559 * Return the ptr in sp at which the character c first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4560 * appears; NULL if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4561 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4562 * Identical to System V strchr, included for portability.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4563 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4564 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4565 etags_strchr (sp, c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4566 register char *sp, c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4567 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4568 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4569 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4570 if (*sp == c)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4571 return sp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4572 } while (*sp++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4573 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4574 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4575
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4576 /* Print error message and exit. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4577 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4578 fatal (s1, s2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4579 char *s1, *s2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4580 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4581 error (s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4582 exit (BAD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4583 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4584
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4585 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4586 pfatal (s1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4587 char *s1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4588 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4589 perror (s1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4590 exit (BAD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4591 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4592
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4593 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4594 suggest_asking_for_help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4595 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4596 fprintf (stderr, "\tTry `%s --help' for a complete list of options.\n",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4597 progname);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4598 exit (BAD);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4599 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4600
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4601 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4602 void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4603 error (s1, s2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4604 char *s1, *s2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4605 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4606 fprintf (stderr, "%s: ", progname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4607 fprintf (stderr, s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4608 fprintf (stderr, "\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4609 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4610
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4611 /* Return a newly-allocated string whose contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4612 concatenate those of s1, s2, s3. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4613 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4614 concat (s1, s2, s3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4615 char *s1, *s2, *s3;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4616 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4617 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4618 char *result = xnew (len1 + len2 + len3 + 1, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4620 strcpy (result, s1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4621 strcpy (result + len1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4622 strcpy (result + len1 + len2, s3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4623 result[len1 + len2 + len3] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4624
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4625 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4626 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4628 /* Does the same work as the system V getcwd, but does not need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4629 guess the buffer size in advance. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4630 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4631 etags_getcwd ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4632 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4633 #ifdef HAVE_GETCWD
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4634 int bufsize = 200;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4635 char *path = xnew (bufsize, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4636
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4637 while (getcwd (path, bufsize) == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4638 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4639 if (errno != ERANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4640 pfatal ("getcwd");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4641 bufsize *= 2;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4642 free (path);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4643 path = xnew (bufsize, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4644 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4645
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4646 #if WINDOWSNT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4647 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4648 /* Convert backslashes to slashes. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4649 char *p;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4650 for (p = path; *p != '\0'; p++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4651 if (*p == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4652 *p = '/';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4653 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4654 #endif
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4655
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4656 return path;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4657
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4658 #else /* not HAVE_GETCWD */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4659 #ifdef MSDOS
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4660 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4661
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4662 getwd (path);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4663
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4664 for (p = path; *p != '\0'; p++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4665 if (*p == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4666 *p = '/';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4667 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4668 *p = lowcase (*p);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4669
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4670 return strdup (path);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4671 #else /* not MSDOS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4672 struct linebuffer path;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4673 FILE *pipe;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4674
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4675 initbuffer (&path);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4676 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4677 if (pipe == NULL || readline_internal (&path, pipe) == 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4678 pfatal ("pwd");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4679 pclose (pipe);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4680
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4681 return path.buffer;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4682 #endif /* not MSDOS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4683 #endif /* not HAVE_GETCWD */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4684 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4685
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4686 /* Return a newly allocated string containing the file name
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4687 of FILE relative to the absolute directory DIR (which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4688 should end with a slash). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4689 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4690 relative_filename (file, dir)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4691 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4692 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4693 char *fp, *dp, *abs, *res;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4694 int i;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4695
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4696 /* Find the common root of file and dir (with a trailing slash). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4697 abs = absolute_filename (file, cwd);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4698 fp = abs;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4699 dp = dir;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4700 while (*fp++ == *dp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4701 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4702 fp--, dp--; /* back to the first differing char */
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4703 do /* look at the equal chars until '/' */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4704 fp--, dp--;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4705 while (*fp != '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4706
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4707 /* Build a sequence of "../" strings for the resulting relative file name. */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4708 i = 0;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4709 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4710 i += 1;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4711 res = xnew (3*i + strlen (fp + 1) + 1, char);
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4712 res[0] = '\0';
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4713 while (i-- > 0)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4714 strcat (res, "../");
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4715
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4716 /* Add the file name relative to the common root of file and dir. */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4717 strcat (res, fp + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4718 free (abs);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4719
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4720 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4721 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4723 /* Return a newly allocated string containing the
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4724 absolute file name of FILE given CWD (which should
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4725 end with a slash). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4726 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4727 absolute_filename (file, cwd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4728 char *file, *cwd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4729 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4730 char *slashp, *cp, *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4731
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4732 if (absolutefn (file))
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4733 res = savestr (file);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4734 #ifdef DOS_NT
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4735 /* We don't support non-absolute file names with a drive
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4736 letter, like `d:NAME' (it's too much hassle). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4737 else if (file[1] == ':')
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4738 fatal ("%s: relative file names with drive letters not supported", file);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4739 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4740 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4741 res = concat (cwd, file, "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4742
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4743 /* Delete the "/dirname/.." and "/." substrings. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4744 slashp = etags_strchr (res, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4745 while (slashp != NULL && slashp[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4746 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4747 if (slashp[1] == '.')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4748 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4749 if (slashp[2] == '.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4750 && (slashp[3] == '/' || slashp[3] == '\0'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4751 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4752 cp = slashp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4753 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4754 cp--;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4755 while (cp >= res && !absolutefn (cp));
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4756 if (cp < res)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4757 cp = slashp; /* the absolute name begins with "/.." */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4758 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4759 /* Under MSDOS and NT we get `d:/NAME' as absolute
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4760 file name, so the luser could say `d:/../NAME'.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4761 We silently treat this as `d:/NAME'. */
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4762 else if (cp[0] != '/')
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4763 cp = slashp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4764 #endif
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4765 strcpy (cp, slashp + 3);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4766 slashp = cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4767 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4768 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4769 else if (slashp[2] == '/' || slashp[2] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4770 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4771 strcpy (slashp, slashp + 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4772 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4773 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4774 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4775
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4776 slashp = etags_strchr (slashp + 1, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4777 }
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4778
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4779 if (res[0] == '\0')
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4780 return savestr ("/");
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4781 else
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4782 return res;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4783 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4784
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4785 /* Return a newly allocated string containing the absolute
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4786 file name of dir where FILE resides given CWD (which should
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4787 end with a slash). */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4788 char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4789 absolute_dirname (file, cwd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4790 char *file, *cwd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4791 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4792 char *slashp, *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4793 char save;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4794 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4795 char *p;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4796
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4797 for (p = file; *p != '\0'; p++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4798 if (*p == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4799 *p = '/';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4800 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4802 slashp = etags_strrchr (file, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4803 if (slashp == NULL)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4804 return savestr (cwd);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4805 save = slashp[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4806 slashp[1] = '\0';
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4807 res = absolute_filename (file, cwd);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4808 slashp[1] = save;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4809
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4810 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4811 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4812
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4813 /* Increase the size of a linebuffer. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4814 void
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4815 grow_linebuffer (bufp, toksize)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4816 struct linebuffer *bufp;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4817 int toksize;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4818 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4819 while (bufp->size < toksize)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4820 bufp->size *= 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4821 bufp->buffer = (char *) xrealloc (bufp->buffer, bufp->size);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4822 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4823
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4824 /* Like malloc but get fatal error if memory is exhausted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4825 long *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4826 xmalloc (size)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4827 unsigned int size;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4828 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4829 long *result = (long *) malloc (size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4830 if (result == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4831 fatal ("virtual memory exhausted", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4832 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4833 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4834
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4835 long *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4836 xrealloc (ptr, size)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4837 char *ptr;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4838 unsigned int size;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4839 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4840 long *result = (long *) realloc (ptr, size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4841 if (result == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4842 fatal ("virtual memory exhausted", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4843 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4844 }