annotate lib-src/etags.c @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents cc15677e0335
children 2f8bb876ab1d
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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95, 98, 99
0
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 *
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
31 * Francesco Potorti` (pot@gnu.org) 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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
34 char pot_etags_version[] = "@(#) pot revision number is 13.44";
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 201
diff changeset
35
0
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
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
43 #if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
44 # define P_(proto) proto
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
45 #else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
46 # define P_(proto) ()
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
47 #endif
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
48
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
49 #ifdef HAVE_CONFIG_H
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
50 # include <config.h>
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
51 /* On some systems, Emacs defines static as nothing for the sake
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
52 of unexec. We don't want that here since we don't use unexec. */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
53 # undef static
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
54 # define ETAGS_REGEXPS /* use the regexp features */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
55 # define LONG_OPTIONS /* accept long options */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
56 #endif /* HAVE_CONFIG_H */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
57
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
58 #ifndef _GNU_SOURCE
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
59 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
60 #endif
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
61
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
62 #ifdef MSDOS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
63 # undef MSDOS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
64 # define MSDOS TRUE
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
65 # include <fcntl.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
66 # include <sys/param.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
67 # include <io.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
68 # ifndef HAVE_CONFIG_H
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
69 # define DOS_NT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
70 # include <sys/config.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
71 # endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
72 #else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
73 # define MSDOS FALSE
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
74 #endif /* MSDOS */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
75
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
76 #ifdef WINDOWSNT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
77 # include <stdlib.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
78 # include <fcntl.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
79 # include <string.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
80 # include <direct.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
81 # include <io.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
82 # define MAXPATHLEN _MAX_PATH
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
83 # ifdef HAVE_CONFIG_H
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
84 # undef HAVE_NTGUI
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
85 # else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
86 # define DOS_NT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
87 # endif /* not HAVE_CONFIG_H */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
88 # ifndef HAVE_GETCWD
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
89 # define HAVE_GETCWD
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
90 # endif /* undef HAVE_GETCWD */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
91 #else /* !WINDOWSNT */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
92 # ifdef STDC_HEADERS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
93 # include <stdlib.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
94 # include <string.h>
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
95 # else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
96 extern char *getenv ();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
97 # endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
98 #endif /* !WINDOWSNT */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
99
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
100 #ifdef HAVE_UNISTD_H
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
101 # include <unistd.h>
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
102 #else
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
103 # if defined (HAVE_GETCWD) && !WINDOWSNT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
104 extern char *getcwd (char *buf, size_t size);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
105 # endif
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
106 #endif /* HAVE_UNISTD_H */
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
107
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #include <stdio.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 #include <ctype.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 #include <errno.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 #ifndef errno
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
112 extern int errno;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 #include <sys/types.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 #include <sys/stat.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 #if !defined (S_ISREG) && defined (S_IFREG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
121 #ifdef LONG_OPTIONS
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
122 # include <getopt.h>
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
123 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
124 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
125 extern char *optarg;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
126 extern int optind, opterr;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
127 #endif /* LONG_OPTIONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 #ifdef ETAGS_REGEXPS
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
130 # include <regex.h>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 /* 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
134 Leave it undefined to make the program "etags", which makes emacs-style
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 tag tables and tags typedefs, #defines and struct/union/enum by default. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 #ifdef CTAGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 # undef CTAGS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 # define CTAGS TRUE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 # define CTAGS FALSE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 /* Exit codes for success and failure. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 #ifdef VMS
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
145 # define GOOD 1
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
146 # define BAD 0
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 #else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
148 # define GOOD 0
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
149 # define BAD 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 /* C extensions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 #define C_PLPL 0x00001 /* C++ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 #define C_STAR 0x00003 /* C* */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
155 #define C_JAVA 0x00005 /* JAVA */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 #define YACC 0x10000 /* yacc file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
158 #define streq(s,t) ((DEBUG && (s) == NULL && (t) == NULL \
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
159 && (abort (), 1)) || !strcmp (s, t))
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
160 #define strneq(s,t,n) ((DEBUG && (s) == NULL && (t) == NULL \
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
161 && (abort (), 1)) || !strncmp (s, t, n))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
162
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
163 #define lowcase(c) tolower ((char)c)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
164
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
165 #define CHARS 256 /* 2^sizeof(char) */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
166 #define CHAR(x) ((unsigned int)x & (CHARS - 1))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
167 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
168 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
169 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
170 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
171 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
175 * xnew, xrnew -- allocate, reallocate storage
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 * SYNOPSIS: Type *xnew (int n, Type);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
178 * Type *xrnew (OldPointer, int n, Type);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
180 #ifdef chkmalloc
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
181 # include "chkmalloc.h"
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
182 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
183 (n) * sizeof (Type)))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
184 # define xrnew(op,n,Type) ((Type *) trace_realloc (__FILE__, __LINE__, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
185 (op), (n) * sizeof (Type)))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
186 #else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
187 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
188 # define xrnew(op,n,Type) ((Type *) xrealloc ((op), (n) * sizeof (Type)))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
189 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
191 typedef int bool;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
193 typedef void Lang_function P_((FILE *));
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
194
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
195 typedef struct
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
196 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
197 char *suffix;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
198 char *command; /* Takes one arg and decompresses to stdout */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
199 } compressor;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
200
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
201 typedef struct
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
202 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
203 char *name;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
204 Lang_function *function;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
205 char **suffixes;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
206 char **interpreters;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
207 } language;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
208
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
209 typedef struct node_st
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
210 { /* sorting structure */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
211 char *name; /* function or type name */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
212 char *file; /* file name */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
213 bool is_func; /* use pattern or line no */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
214 bool been_warned; /* set if noticed dup */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
215 int lno; /* line number tag is on */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
216 long cno; /* character number line starts on */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
217 char *pat; /* search pattern */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
218 struct node_st *left, *right; /* left and right sons */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
219 } node;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
220
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
221 /*
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
222 * A `linebuffer' is a structure which holds a line of text.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
223 * `readline_internal' reads a line from a stream into a linebuffer
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
224 * and works regardless of the length of the line.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
225 * SIZE is the size of BUFFER, LEN is the length of the string in
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
226 * BUFFER after readline reads it.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
227 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
228 typedef struct
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
229 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
230 long size;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
231 int len;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
232 char *buffer;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
233 } linebuffer;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
234
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
235 /* Many compilers barf on this:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
236 Lang_function Ada_funcs;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
237 so let's write it this way */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
238 static void Ada_funcs P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
239 static void Asm_labels P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
240 static void C_entries P_((int c_ext, FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
241 static void default_C_entries P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
242 static void plain_C_entries P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
243 static void Cjava_entries P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
244 static void Cobol_paragraphs P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
245 static void Cplusplus_entries P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
246 static void Cstar_entries P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
247 static void Erlang_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
248 static void Fortran_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
249 static void Yacc_entries P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
250 static void Lisp_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
251 static void Pascal_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
252 static void Perl_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
253 static void Postscript_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
254 static void Prolog_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
255 static void Python_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
256 static void Scheme_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
257 static void TeX_functions P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
258 static void just_read_file P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
259
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
260 static void print_language_names P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
261 static void print_version P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
262 static void print_help P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
263 int main P_((int, char **));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
264 static int number_len P_((long));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
265
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
266 static compressor *get_compressor_from_suffix P_((char *, char **));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
267 static language *get_language_from_name P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
268 static language *get_language_from_interpreter P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
269 static language *get_language_from_suffix P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
270 static int total_size_of_entries P_((node *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
271 static long readline P_((linebuffer *, FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
272 static long readline_internal P_((linebuffer *, FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
273 static void get_tag P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
274
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 #ifdef ETAGS_REGEXPS
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
276 static void analyse_regex P_((char *, bool));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
277 static void add_regex P_((char *, bool, language *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
278 static void free_patterns P_((void));
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
279 #endif /* ETAGS_REGEXPS */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
280 static void error P_((const char *, const char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
281 static void suggest_asking_for_help P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
282 static void fatal P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
283 static void pfatal P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
284 static void add_node P_((node *, node **));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
285
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
286 static void init P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
287 static void initbuffer P_((linebuffer *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
288 static void find_entries P_((char *, FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
289 static void free_tree P_((node *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
290 static void pfnote P_((char *, bool, char *, int, int, long));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
291 static void new_pfnote P_((char *, int, bool, char *, int, int, long));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
292 static void process_file P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
293 static void put_entries P_((node *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
294 static void takeprec P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
295
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
296 static char *concat P_((char *, char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
297 static char *skip_spaces P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
298 static char *skip_non_spaces P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
299 static char *savenstr P_((char *, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
300 static char *savestr P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
301 static char *etags_strchr P_((const char *, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
302 static char *etags_strrchr P_((const char *, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
303 static char *etags_getcwd P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
304 static char *relative_filename P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
305 static char *absolute_filename P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
306 static char *absolute_dirname P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
307 static bool filename_is_absolute P_((char *f));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
308 static void canonicalize_filename P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
309 static void grow_linebuffer P_((linebuffer *, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
310 static long *xmalloc P_((unsigned int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
311 static long *xrealloc P_((char *, unsigned int));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 char searchar = '/'; /* use /.../ searches */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 char *tagfile; /* output file */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
317 char *progname; /* name this program was invoked with */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 char *cwd; /* current working directory */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 char *tagfiledir; /* directory of tagfile */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 FILE *tagf; /* ioptr for tags file */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
321
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
322 char *curfile; /* current input file name */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
323 language *curlang; /* current language */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
324
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
325 int lineno; /* line number of current line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
326 long charno; /* current character number */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
327 long linecharno; /* charno of start of current line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
328 char *dbp; /* pointer to start of current tag */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
329
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
330 node *head; /* the head of the binary tree of tags */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
331
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
332 linebuffer lb; /* the current line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
333 linebuffer token_name; /* used by C_entries as a temporary area */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 long linepos;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
337 linebuffer lb; /* used by C_entries instead of lb */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 } lbs[2];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 /* boolean "functions" (see init) */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
341 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
342 char
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
343 /* white chars */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
344 *white = " \f\t\n\r\v",
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
345 /* not in a name */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
346 *nonam = " \f\t\n\r(=,[;",
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
347 /* token ending chars */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
348 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
349 /* token starting chars */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
350 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
351 /* valid in-token chars */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
352 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
354 bool append_to_tagfile; /* -a: append to tags */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
355 /* The following four default to TRUE for etags, but to FALSE for ctags. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
356 bool typedefs; /* -t: create tags for C and Ada typedefs */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
357 bool typedefs_and_cplusplus; /* -T: create tags for C typedefs, level */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 /* 0 struct/enum/union decls, and C++ */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 /* member functions. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
360 bool constantypedefs; /* -d: create tags for C #define, enum */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
361 /* constants and variables. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 /* -D: opposite of -d. Default under ctags. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
363 bool declarations; /* --declarations: tag them and extern in C&Co*/
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
364 bool globals; /* create tags for global variables */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
365 bool members; /* create tags for C member variables */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
366 bool update; /* -u: update tags */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
367 bool vgrind_style; /* -v: create vgrind style index output */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
368 bool no_warnings; /* -w: suppress warnings */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
369 bool cxref_style; /* -x: create cxref style output */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
370 bool cplusplus; /* .[hc] means C++, not C */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
371 bool noindentypedefs; /* -I: ignore indentation in C */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
372 bool packages_only; /* --packages-only: in Ada, only tag packages*/
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
373
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
374 #ifdef LONG_OPTIONS
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 struct option longopts[] =
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
377 { "packages-only", no_argument, &packages_only, TRUE },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
378 { "append", no_argument, NULL, 'a' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
379 { "backward-search", no_argument, NULL, 'B' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
380 { "c++", no_argument, NULL, 'C' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
381 { "cxref", no_argument, NULL, 'x' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
382 { "defines", no_argument, NULL, 'd' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
383 { "declarations", no_argument, &declarations, TRUE },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
384 { "no-defines", no_argument, NULL, 'D' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
385 { "globals", no_argument, &globals, TRUE },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
386 { "no-globals", no_argument, &globals, FALSE },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
387 { "help", no_argument, NULL, 'h' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
388 { "help", no_argument, NULL, 'H' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
389 { "ignore-indentation", no_argument, NULL, 'I' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
390 { "include", required_argument, NULL, 'i' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
391 { "language", required_argument, NULL, 'l' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
392 { "members", no_argument, &members, TRUE },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
393 { "no-members", no_argument, &members, FALSE },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
394 { "no-warn", no_argument, NULL, 'w' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
395 { "output", required_argument, NULL, 'o' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
396 #ifdef ETAGS_REGEXPS
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
397 { "regex", required_argument, NULL, 'r' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
398 { "no-regex", no_argument, NULL, 'R' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
399 { "ignore-case-regex", required_argument, NULL, 'c' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
400 #endif /* ETAGS_REGEXPS */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
401 { "typedefs", no_argument, NULL, 't' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
402 { "typedefs-and-c++", no_argument, NULL, 'T' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
403 { "update", no_argument, NULL, 'u' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
404 { "version", no_argument, NULL, 'V' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
405 { "vgrind", no_argument, NULL, 'v' },
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
406 { NULL }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 };
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
408 #endif /* LONG_OPTIONS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 /* Structure defining a regular expression. Elements are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 the compiled pattern, and the name string. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
413 typedef struct pattern
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
415 struct pattern *p_next;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
416 language *language;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
417 char *regex;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 struct re_pattern_buffer *pattern;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 struct re_registers regs;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 char *name_pattern;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
421 bool error_signaled;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
422 } pattern;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
424 /* List of all regexps. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
425 pattern *p_head = NULL;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
426
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
427 /* How many characters in the character set. (From regex.c.) */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
428 #define CHAR_SET_SIZE 256
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
429 /* Translation table for case-insensitive matching. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
430 char lc_trans[CHAR_SET_SIZE];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
433 compressor compressors[] =
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
434 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
435 { "z", "gzip -d -c"},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
436 { "Z", "gzip -d -c"},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
437 { "gz", "gzip -d -c"},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
438 { "GZ", "gzip -d -c"},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
439 { "bz2", "bzip2 -d -c" },
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
440 { NULL }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
441 };
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
442
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 * Language stuff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 /* Non-NULL if language fixed. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
448 language *forced_lang = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
450 /* Ada code */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
451 char *Ada_suffixes [] =
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
452 { "ads", "adb", "ada", NULL };
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
453
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 /* Assembly code */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
455 char *Asm_suffixes [] = { "a", /* Unix assembler */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 "asm", /* Microcontroller assembly */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "def", /* BSO/Tasking definition includes */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 "inc", /* Microcontroller include files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "ins", /* Microcontroller include files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 "s", "sa", /* Unix assembler */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
461 "S", /* cpp-processed Unix assembler */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "src", /* BSO/Tasking C compiler output */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 NULL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 /* 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
467 given. That is why default_C_entries is called here. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
468 char *default_C_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 { "c", "h", NULL };
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 char *Cplusplus_suffixes [] =
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
472 { "C", "H", "c++", "cc", "cpp", "cxx", "h++", "hh", "hpp", "hxx",
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
473 "M", /* Objective C++ */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
474 "pdb", /* Postscript with C syntax */
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
475 NULL };
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
476
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
477 char *Cjava_suffixes [] =
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
478 { "java", NULL };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
479
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
480 char *Cobol_suffixes [] =
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
481 { "COB", "cob", NULL };
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
482
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
483 char *Cstar_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 { "cs", "hs", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
486 char *Erlang_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
487 { "erl", "hrl", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
488
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
489 char *Fortran_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 { "F", "f", "f90", "for", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
492 char *Lisp_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 { "cl", "clisp", "el", "l", "lisp", "lsp", "ml", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
495 char *Pascal_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 { "p", "pas", NULL };
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 char *Perl_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 { "pl", "pm", NULL };
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
500 char *Perl_interpreters [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
501 { "perl", "@PERL@", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
502
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
503 char *plain_C_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
504 { "pc", /* Pro*C file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
505 "m", /* Objective C file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
506 "lm", /* Objective lex file */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
507 NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
508
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
509 char *Postscript_suffixes [] =
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
510 { "ps", "psw", NULL }; /* .psw is for PSWrap */
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
511
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
512 char *Prolog_suffixes [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 { "prolog", NULL };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
515 char *Python_suffixes [] =
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
516 { "py", NULL };
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
517
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
518 /* Can't do the `SCM' or `scm' prefix with a version number. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
519 char *Scheme_suffixes [] =
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
520 { "SCM", "SM", "oak", "sch", "scheme", "scm", "sm", "ss", "t", NULL };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
522 char *TeX_suffixes [] =
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
523 { "TeX", "bib", "clo", "cls", "ltx", "sty", "tex", NULL };
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
524
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
525 char *Yacc_suffixes [] =
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
526 { "y", "ym", "yy", "yxx", "y++", NULL }; /* .ym is Objective yacc file */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
528 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
529 * Table of languages.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
530 *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
531 * It is ok for a given function to be listed under more than one
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
532 * name. I just didn't.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
533 */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
534
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
535 language lang_names [] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
537 { "ada", Ada_funcs, Ada_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
538 { "asm", Asm_labels, Asm_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
539 { "c", default_C_entries, default_C_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
540 { "c++", Cplusplus_entries, Cplusplus_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
541 { "c*", Cstar_entries, Cstar_suffixes, NULL },
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
542 { "cobol", Cobol_paragraphs, Cobol_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
543 { "erlang", Erlang_functions, Erlang_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
544 { "fortran", Fortran_functions, Fortran_suffixes, NULL },
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
545 { "java", Cjava_entries, Cjava_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
546 { "lisp", Lisp_functions, Lisp_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
547 { "pascal", Pascal_functions, Pascal_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
548 { "perl", Perl_functions, Perl_suffixes, Perl_interpreters },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
549 { "postscript", Postscript_functions, Postscript_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
550 { "proc", plain_C_entries, plain_C_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
551 { "prolog", Prolog_functions, Prolog_suffixes, NULL },
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
552 { "python", Python_functions, Python_suffixes, NULL },
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
553 { "scheme", Scheme_functions, Scheme_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
554 { "tex", TeX_functions, TeX_suffixes, NULL },
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
555 { "yacc", Yacc_entries, Yacc_suffixes, NULL },
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
556 { "auto", NULL }, /* default guessing scheme */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
557 { "none", just_read_file }, /* regexp matching only */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
558 { NULL, NULL } /* end of list */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
561 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
562 print_language_names ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
564 language *lang;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
565 char **ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 puts ("\nThese are the currently supported languages, along with the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 default file name suffixes:");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 printf ("\t%s\t", lang->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 if (lang->suffixes != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 for (ext = lang->suffixes; *ext != NULL; ext++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 printf (" .%s", *ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 puts ("");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 puts ("Where `auto' means use default language for files based on file\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 name suffix, and `none' means only do regexp processing on files.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 If no language is specified and no matching suffix is found,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 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
581 followed by the name of an interpreter. If no such sequence is found,\n\
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
582 Fortran is tried first; if no tags are found, C is tried next.\n\
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
583 Compressed files are supported using gzip and bzip2.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
586 #ifndef EMACS_NAME
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
587 # define EMACS_NAME "GNU Emacs"
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
588 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 #ifndef VERSION
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
590 # define VERSION "21"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
592 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
593 print_version ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
595 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
596 puts ("Copyright (C) 1999 Free Software Foundation, Inc. and Ken Arnold");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
597 puts ("This program is distributed under the same terms as Emacs");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
602 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
603 print_help ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
605 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
606 \n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
607 These are the options accepted by %s.\n", progname, progname);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
608 #ifdef LONG_OPTIONS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
609 puts ("You may use unambiguous abbreviations for the long option names.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
610 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
611 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
612 linked with GNU getopt.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
613 #endif /* LONG_OPTIONS */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
614 puts ("A - as file name means read names from stdin (one per line).");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
615 if (!CTAGS)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
616 printf (" Absolute names are stored in the output file as they are.\n\
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
617 Relative ones are stored relative to the output file's directory.");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
618 puts ("\n");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 puts ("-a, --append\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 Append tag entries to existing tags file.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
623 puts ("--packages-only\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
624 For Ada files, only generate tags for packages .");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
625
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 puts ("-B, --backward-search\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 Write the search commands for the tag entries using '?', the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 backward-search command instead of '/', the forward-search command.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 puts ("-C, --c++\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 Treat files whose name suffix defaults to C language as C++ files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
634 puts ("--declarations\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
635 In C and derived languages, create tags for function declarations,");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
636 if (CTAGS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
637 puts ("\tand create tags for extern variables if --globals is used.");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
638 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
639 puts
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
640 ("\tand create tags for extern variables unless --no-globals is used.");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
641
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 puts ("-d, --defines\n\
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
644 Create tag entries for C #define constants and enum constants, too.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 puts ("-D, --no-defines\n\
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
647 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
648 This makes the tags file smaller.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 puts ("-i FILE, --include=FILE\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 Include a note in tag file indicating that, when searching for\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 a tag, one should also consult the tags file FILE after\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 checking the current file.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 puts ("-l LANG, --language=LANG\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 Force the following files to be considered as written in the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 named language up to the next --language=LANG option.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
661 if (CTAGS)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
662 puts ("--globals\n\
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
663 Create tag entries for global variables in some languages.");
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
664 else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
665 puts ("--no-globals\n\
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
666 Do not create tag entries for global variables in some\n\
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
667 languages. This makes the tags file smaller.");
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
668 puts ("--members\n\
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
669 Create tag entries for member variables in C and derived languages.");
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
670
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 #ifdef ETAGS_REGEXPS
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
672 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
673 Make a tag for each line matching pattern REGEXP in the following\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
674 files. {LANGUAGE}/REGEXP/ uses REGEXP for LANGUAGE files only.\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
675 regexfile is a file containing one REGEXP per line.\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
676 REGEXP is anchored (as if preceded by ^).\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
677 The form /REGEXP/NAME/ creates a named tag.\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
678 For example Tcl named tags can be created with:\n\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 --regex=/proc[ \\t]+\\([^ \\t]+\\)/\\1/.");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
680 puts ("-c /REGEXP/, --ignore-case-regex=/REGEXP/ or --ignore-case-regex=@regexfile\n\
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
681 Like -r, --regex but ignore case when matching expressions.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 puts ("-R, --no-regex\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 Don't create tags from regexps for the following files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 puts ("-o FILE, --output=FILE\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 Write the tags to FILE.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 puts ("-I, --ignore-indentation\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 Don't rely on indentation quite as much as normal. Currently,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 this means not to assume that a closing brace in the first\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 column is the final brace of a function or structure\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 definition in C and C++.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 if (CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 puts ("-t, --typedefs\n\
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
696 Generate tag entries for C and Ada typedefs.");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 puts ("-T, --typedefs-and-c++\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 and C++ member functions.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 puts ("-u, --update\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 Update the tag entries for the given files, leaving tag\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 entries for other files in place. Currently, this is\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 implemented by deleting the existing entries for the given\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 files and then rewriting the new entries at the end of the\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 tags file. It is often faster to simply rebuild the entire\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 tag file than to use this.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 puts ("-v, --vgrind\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 Generates an index of items intended for human consumption,\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 similar to the output of vgrind. The index is sorted, and\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 gives the page number of each item.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 puts ("-w, --no-warn\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 Suppress warning messages about entries defined in multiple\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 files.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 puts ("-x, --cxref\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 The output uses line numbers instead of page numbers, but\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 beyond that the differences are cosmetic; try both to see\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 which you like.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 puts ("-V, --version\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 Print the version of the program.\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 -h, --help\n\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 Print this help message.");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 print_language_names ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
728 puts ("");
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
729 puts ("Report bugs to bug-gnu-emacs@gnu.org");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
730
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 enum argument_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 at_language,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 at_regexp,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
739 at_filename,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
740 at_icregexp
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
743 /* This structure helps us allow mixing of --lang and file names. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 typedef struct
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 enum argument_type arg_type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 char *what;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
748 language *lang; /* language of the regexp */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 } argument;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 #ifdef VMS /* VMS specific functions */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 #define EOS '\0'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 /* This is a BUG! ANY arbitrary limit is a BUG!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 Won't someone please fix this? */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 #define MAX_FILE_SPEC_LEN 255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 typedef struct {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 short curlen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 char body[MAX_FILE_SPEC_LEN + 1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 } vspec;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 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
765 returning in each successive call the next file name matching the input
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 spec. The function expects that each in_spec passed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 to it will be processed to completion; in particular, up to and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 including the call following that in which the last matching name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 is returned, the function ignores the value of in_spec, and will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 only start processing a new spec with the following call.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 If an error occurs, on return out_spec contains the value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 of in_spec when the error occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
774 With each successive file name returned in out_spec, the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 function's return value is one. When there are no more matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 names the function returns zero. If on the first call no file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 matches in_spec, or there is any other error, -1 is returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 #include <rmsdef.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 #include <descrip.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 #define OUTSIZE MAX_FILE_SPEC_LEN
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
783 static short
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
784 fn_exp (out, in)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
785 vspec *out;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
786 char *in;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 static long context = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 static struct dsc$descriptor_s o;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 static struct dsc$descriptor_s i;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
791 static bool pass1 = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 long status;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 short retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 if (pass1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 pass1 = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 o.dsc$a_pointer = (char *) out;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 o.dsc$w_length = (short)OUTSIZE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 i.dsc$a_pointer = in;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 i.dsc$w_length = (short)strlen(in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 i.dsc$b_dtype = DSC$K_DTYPE_T;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 i.dsc$b_class = DSC$K_CLASS_S;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 o.dsc$b_dtype = DSC$K_DTYPE_VT;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 o.dsc$b_class = DSC$K_CLASS_VS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 out->body[out->curlen] = EOS;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 else if (status == RMS$_NMF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 retval = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 strcpy(out->body, in);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 retval = -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 lib$find_file_end(&context);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 pass1 = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 return retval;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 name of each file specified by the provided arg expanding wildcards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
828 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
829 gfnames (arg, p_error)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
830 char *arg;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
831 bool *p_error;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 switch (fn_exp (&filename, arg))
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:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 *p_error = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 return filename.body;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 *p_error = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 *p_error = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 return filename.body;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 #ifndef OLD /* Newer versions of VMS do provide `system'. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
850 system (cmd)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
851 char *cmd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
853 error ("%s", "system() function not implemented under VMS");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 #define VERSION_DELIM ';'
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
858 char *massage_name (s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
859 char *s;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 char *start = s;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 for ( ; *s; s++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 if (*s == VERSION_DELIM)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 *s = EOS;
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 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 *s = lowcase (*s);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 return start;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 #endif /* VMS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
876 int
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
877 main (argc, argv)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
878 int argc;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
879 char *argv[];
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 int i;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
882 unsigned int nincluded_files;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
883 char **included_files;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 char *this_file;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 argument *argbuffer;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
886 int current_arg, file_count;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
887 linebuffer filename_lb;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 #ifdef VMS
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
889 bool got_err;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 #ifdef DOS_NT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 _fmode = O_BINARY; /* all of files are treated as binary files */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 #endif /* DOS_NT */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 progname = argv[0];
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
897 nincluded_files = 0;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
898 included_files = xnew (argc, char *);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
899 current_arg = 0;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
900 file_count = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 /* Allocate enough no matter what happens. Overkill, but each one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 is small. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 argbuffer = xnew (argc, argument);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 /* Set syntax for regular expression routines. */
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
908 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
909 /* Translation table for case-insensitive search. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
910 for (i = 0; i < CHAR_SET_SIZE; i++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
911 lc_trans[i] = lowcase (i);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 * If etags, always find typedefs and structure tags. Why not?
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
916 * Also default is to find macro constants, enum constants and
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
917 * global variables.
0
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 (!CTAGS)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
920 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
921 typedefs = typedefs_and_cplusplus = constantypedefs = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
922 globals = TRUE;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
923 members = FALSE;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
924 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
928 int opt;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
929 char *optstring;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
930
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
931 #ifdef ETAGS_REGEXPS
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
932 optstring = "-aCdDf:Il:o:r:c:RStTi:BuvxwVhH";
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
933 #else
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
934 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
935 #endif /* ETAGS_REGEXPS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
936
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
937 #ifndef LONG_OPTIONS
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
938 optstring = optstring + 1;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
939 #endif /* LONG_OPTIONS */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
940
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
941 opt = getopt_long (argc, argv, optstring, longopts, 0);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 if (opt == EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 switch (opt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 case 0:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 /* If getopt returns 0, then it has already processed a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 long-named option. We should do nothing. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 case 1:
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
953 /* This means that a file name has been seen. Record it. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 argbuffer[current_arg].arg_type = at_filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 argbuffer[current_arg].what = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ++file_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 /* Common options. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
961 case 'a': append_to_tagfile = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
962 case 'C': cplusplus = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
963 case 'd': constantypedefs = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
964 case 'D': constantypedefs = FALSE; break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 case 'f': /* for compatibility with old makefiles */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 case 'o':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 if (tagfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
969 error ("-o option may only be given once.", (char *)NULL);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
970 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 tagfile = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 case 'I':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 case 'S': /* for backward compatibility */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 noindentypedefs = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 case 'l':
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
979 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
980 language *lang = get_language_from_name (optarg);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
981 if (lang != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
982 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
983 argbuffer[current_arg].lang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
984 argbuffer[current_arg].arg_type = at_language;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
985 ++current_arg;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
986 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
987 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 case 'r':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 argbuffer[current_arg].arg_type = at_regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 argbuffer[current_arg].what = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 case 'R':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 argbuffer[current_arg].arg_type = at_regexp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 argbuffer[current_arg].what = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 break;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1000 case 'c':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1001 argbuffer[current_arg].arg_type = at_icregexp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1002 argbuffer[current_arg].what = optarg;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1003 ++current_arg;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1004 break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 case 'V':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 print_version ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 case 'h':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 case 'H':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 print_help ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 case 't':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 typedefs = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 case 'T':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 typedefs = typedefs_and_cplusplus = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 #if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 /* Etags options */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 included_files[nincluded_files++] = optarg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 #else /* CTAGS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 /* Ctags options. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1026 case 'B': searchar = '?'; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1027 case 'u': update = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1028 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1029 case 'x': cxref_style = TRUE; break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1030 case 'w': no_warnings = TRUE; break;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 #endif /* CTAGS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 default:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1033 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 for (; optind < argc; ++optind)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 argbuffer[current_arg].arg_type = at_filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 argbuffer[current_arg].what = argv[optind];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 ++current_arg;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 ++file_count;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 if (nincluded_files == 0 && file_count == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1047 error ("no input files specified.", (char *)NULL);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1048 suggest_asking_for_help ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 if (tagfile == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1052 tagfile = CTAGS ? "tags" : "TAGS";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 cwd = etags_getcwd (); /* the current working directory */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1054 if (cwd[strlen (cwd) - 1] != '/')
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1055 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1056 char *oldcwd = cwd;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1057 cwd = concat (oldcwd, "/", "");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1058 free (oldcwd);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
1059 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 if (streq (tagfile, "-"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1061 tagfiledir = cwd;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1063 tagfiledir = absolute_dirname (tagfile, cwd);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 init (); /* set up boolean "functions" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 initbuffer (&lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 initbuffer (&token_name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 initbuffer (&lbs[0].lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 initbuffer (&lbs[1].lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 initbuffer (&filename_lb);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 if (streq (tagfile, "-"))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1076 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1077 tagf = stdout;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1078 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1079 /* Switch redirected `stdout' to binary mode (setting `_fmode'
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1080 doesn't take effect until after `stdout' is already open). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1081 if (!isatty (fileno (stdout)))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1082 setmode (fileno (stdout), O_BINARY);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1083 #endif /* DOS_NT */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1084 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 if (tagf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 pfatal (tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 * Loop through files finding functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 for (i = 0; i < current_arg; ++i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 switch (argbuffer[i].arg_type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098 case at_language:
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1099 forced_lang = argbuffer[i].lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 #ifdef ETAGS_REGEXPS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 case at_regexp:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1103 analyse_regex (argbuffer[i].what, FALSE);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1104 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1105 case at_icregexp:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1106 analyse_regex (argbuffer[i].what, TRUE);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 case at_filename:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 if (got_err)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1115 error ("can't find file %s\n", this_file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 argc--, argv++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 this_file = massage_name (this_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 this_file = argbuffer[i].what;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 /* Input file named "-" means read file names from stdin
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1126 (one per line) and use them. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 if (streq (this_file, "-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 while (readline_internal (&filename_lb, stdin) > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 process_file (filename_lb.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 process_file (this_file);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 #ifdef VMS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1139 #ifdef ETAGS_REGEXPS
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1140 free_patterns ();
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1141 #endif /* ETAGS_REGEXPS */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1142
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 while (nincluded_files-- > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 fprintf (tagf, "\f\n%s,include\n", *included_files++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 fclose (tagf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 /* If CTAGS, we are here. process_file did not write the tags yet,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 because we want them ordered. Let's do it now. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 if (cxref_style)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 put_entries (head);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1157 free_tree (head);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1158 head = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 exit (GOOD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 if (update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 char cmd[BUFSIZ];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 for (i = 0; i < current_arg; ++i)
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 (argbuffer[i].arg_type != at_filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 sprintf (cmd,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 tagfile, argbuffer[i].what, tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 if (system (cmd) != GOOD)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1173 fatal ("failed to execute shell command", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 append_to_tagfile = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 if (tagf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 pfatal (tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 put_entries (head);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1182 free_tree (head);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1183 head = NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 fclose (tagf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 if (update)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 char cmd[BUFSIZ];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 exit (system (cmd));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1192 return GOOD;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1196
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1197 /*
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1198 * Return a compressor given the file name. If EXTPTR is non-zero,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1199 * return a pointer into FILE where the compressor-specific
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1200 * extension begins. If no compressor is found, NULL is returned
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1201 * and EXTPTR is not significant.
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1202 * Idea by Vladimir Alexiev <vladimir@cs.ualberta.ca>
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1203 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1204 static compressor *
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1205 get_compressor_from_suffix (file, extptr)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1206 char *file;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1207 char **extptr;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1208 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1209 compressor *compr;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1210 char *slash, *suffix;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1211
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1212 /* This relies on FN to be after canonicalize_filename,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1213 so we don't need to consider backslashes on DOS_NT. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1214 slash = etags_strrchr (file, '/');
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1215 suffix = etags_strrchr (file, '.');
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1216 if (suffix == NULL || suffix < slash)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1217 return NULL;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1218 if (extptr != NULL)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1219 *extptr = suffix;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1220 suffix += 1;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1221 /* Let those poor souls who live with DOS 8+3 file name limits get
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1222 some solace by treating foo.cgz as if it were foo.c.gz, etc.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1223 Only the first do loop is run if not MSDOS */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1224 do
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1225 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1226 for (compr = compressors; compr->suffix != NULL; compr++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1227 if (streq (compr->suffix, suffix))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1228 return compr;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1229 if (!MSDOS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1230 break; /* do it only once: not really a loop */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1231 if (extptr != NULL)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1232 *extptr = ++suffix;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1233 } while (*suffix != '\0');
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1234 return NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1235 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1236
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1237
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1238
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1240 * Return a language given the name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1242 static language *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1243 get_language_from_name (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1244 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1246 language *lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1247
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1248 if (name == NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1249 error ("empty language name", (char *)NULL);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1250 else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1251 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1252 for (lang = lang_names; lang->name != NULL; lang++)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1253 if (streq (name, lang->name))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1254 return lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1255 error ("unknown language \"%s\"", name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1256 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1257
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1258 return NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1263 * Return a language given the interpreter name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1265 static language *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1266 get_language_from_interpreter (interpreter)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1267 char *interpreter;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1269 language *lang;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1270 char **iname;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 if (interpreter == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 if (lang->interpreters != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 for (iname = lang->interpreters; *iname != NULL; iname++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 if (streq (*iname, interpreter))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1278 return lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 /*
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1286 * Return a language given the file name.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1288 static language *
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1289 get_language_from_suffix (file)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1290 char *file;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1292 language *lang;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1293 char **ext, *suffix;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1294
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1295 suffix = etags_strrchr (file, '.');
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 if (suffix == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 return NULL;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1298 suffix += 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 for (lang = lang_names; lang->name != NULL; lang++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 if (lang->suffixes != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 for (ext = lang->suffixes; *ext != NULL; ext++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 if (streq (*ext, suffix))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1303 return lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1308
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 * This routine is called on each file argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1312 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1313 process_file (file)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1314 char *file;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 struct stat stat_buf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 FILE *inf;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1318 compressor *compr;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1319 char *compressed_name, *uncompressed_name;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1320 char *ext, *real_name;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1321
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1322
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1323 canonicalize_filename (file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 if (streq (file, tagfile) && !streq (tagfile, "-"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1326 error ("skipping inclusion of %s in self.", file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1329 if ((compr = get_compressor_from_suffix (file, &ext)) == NULL)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1330 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1331 compressed_name = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1332 real_name = uncompressed_name = savestr (file);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1333 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1334 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1335 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1336 real_name = compressed_name = savestr (file);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1337 uncompressed_name = savenstr (file, ext - file);
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1338 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1339
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1340 /* If the canonicalised uncompressed name has already be dealt with,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1341 skip it silently, else add it to the list. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1342 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1343 typedef struct processed_file
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1344 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1345 char *filename;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1346 struct processed_file *next;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1347 } processed_file;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1348 static processed_file *pf_head = NULL;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1349 register processed_file *fnp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1350
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1351 for (fnp = pf_head; fnp != NULL; fnp = fnp->next)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1352 if (streq (uncompressed_name, fnp->filename))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1353 goto exit;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1354 fnp = pf_head;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1355 pf_head = xnew (1, struct processed_file);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1356 pf_head->filename = savestr (uncompressed_name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1357 pf_head->next = fnp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1358 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1359
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1360 if (stat (real_name, &stat_buf) != 0)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1361 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1362 /* Reset real_name and try with a different name. */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1363 real_name = NULL;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1364 if (compressed_name != NULL) /* try with the given suffix */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1365 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1366 if (stat (uncompressed_name, &stat_buf) == 0)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1367 real_name = uncompressed_name;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1368 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1369 else /* try all possible suffixes */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1370 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1371 for (compr = compressors; compr->suffix != NULL; compr++)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1372 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1373 compressed_name = concat (file, ".", compr->suffix);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1374 if (stat (compressed_name, &stat_buf) != 0)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1375 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1376 if (MSDOS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1377 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1378 char *suf = compressed_name + strlen (file);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1379 size_t suflen = strlen (compr->suffix) + 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1380 for ( ; suf[1]; suf++, suflen--)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1381 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1382 memmove (suf, suf + 1, suflen);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1383 if (stat (compressed_name, &stat_buf) == 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1384 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1385 real_name = compressed_name;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1386 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1387 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1388 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1389 if (real_name != NULL)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1390 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1391 } /* MSDOS */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1392 free (compressed_name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1393 compressed_name = NULL;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1394 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1395 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1396 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1397 real_name = compressed_name;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1398 break;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1399 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1400 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1401 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1402 if (real_name == NULL)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1403 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1404 perror (file);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1405 goto exit;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1406 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1407 } /* try with a different name */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1408
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1409 if (!S_ISREG (stat_buf.st_mode))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1410 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1411 error ("skipping %s: it is not a regular file.", real_name);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1412 goto exit;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1413 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1414 if (real_name == compressed_name)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1415 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1416 char *cmd = concat (compr->command, " ", real_name);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1417 inf = popen (cmd, "r");
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1418 free (cmd);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1419 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1420 else
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1421 inf = fopen (real_name, "r");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 if (inf == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1424 perror (real_name);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1425 goto exit;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1428 find_entries (uncompressed_name, inf);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1429
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1430 if (real_name == compressed_name)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1431 pclose (inf);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1432 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1433 fclose (inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 char *filename;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1439 if (filename_is_absolute (uncompressed_name))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 {
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
1441 /* file is an absolute file name. Canonicalise it. */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1442 filename = absolute_filename (uncompressed_name, cwd);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 {
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
1446 /* file is a file name relative to cwd. Make it relative
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 to the directory of the tags file. */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1448 filename = relative_filename (uncompressed_name, tagfiledir);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 free (filename);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 put_entries (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 free_tree (head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 head = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1456
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1457 exit:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1458 if (compressed_name) free(compressed_name);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1459 if (uncompressed_name) free(uncompressed_name);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1460 return;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 * This routine sets up the boolean pseudo-functions which work
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1465 * by setting boolean flags dependent upon the corresponding character.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 * 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
1467 * all of the array "_wht" is set to FALSE, and then the elements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 * of a char is TRUE if it is the string "white", else FALSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1471 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1472 init ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1474 register char *sp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 register int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1477 for (i = 0; i < CHARS; i++)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1478 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1479 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1480 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1481 notinname('\0') = notinname('\n');
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1482 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1483 begtoken('\0') = begtoken('\n');
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1484 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1485 intoken('\0') = intoken('\n');
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1486 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1487 endtoken('\0') = endtoken('\n');
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 }
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 * This routine opens the specified file and calls the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 * which finds the function and type definitions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1494 node *last_node = NULL;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1495
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1496 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1497 find_entries (file, inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1498 char *file;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1499 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 char *cp;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1502 language *lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1503 node *old_last_node;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1504
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1505 /* Memory leakage here: the string pointed by curfile is
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1506 never released, because curfile is copied into np->file
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1507 for each node, to be used in CTAGS mode. The amount of
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1508 memory leaked here is the sum of the lengths of the
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1509 file names. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 curfile = savestr (file);
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 user specified a language, use it. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1513 lang = forced_lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1514 if (lang != NULL && lang->function != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1516 curlang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1517 lang->function (inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1521 /* Try to guess the language given the file name. */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1522 lang = get_language_from_suffix (file);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1523 if (lang != NULL && lang->function != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1525 curlang = lang;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1526 lang->function (inf);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1527 return;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 /* Look for sharp-bang as the first two characters. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1531 if (readline_internal (&lb, inf) > 0
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
1532 && lb.len >= 2
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 && lb.buffer[0] == '#'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 && lb.buffer[1] == '!')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 char *lp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 /* 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
1539 line or, if no slashes, at the first nonblank. Then set cp to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 the first successive blank and terminate the string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 lp = etags_strrchr (lb.buffer+2, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 if (lp != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 lp += 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1545 lp = skip_spaces (lb.buffer + 2);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1546 cp = skip_non_spaces (lp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 *cp = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1549 if (strlen (lp) > 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1551 lang = get_language_from_interpreter (lp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1552 if (lang != NULL && lang->function != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1554 curlang = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1555 lang->function (inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1560 /* We rewind here, even if inf may be a pipe. We fail if the
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1561 length of the first line is longer than the pipe block size,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1562 which is unlikely. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 /* Try Fortran. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 old_last_node = last_node;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1567 curlang = get_language_from_name ("fortran");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 Fortran_functions (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 /* No Fortran entries found. Try C. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 if (old_last_node == last_node)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1573 /* We do not tag if rewind fails.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1574 Only the file name will be recorded in the tags file. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 rewind (inf);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1576 curlang = get_language_from_name (cplusplus ? "c++" : "c");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 default_C_entries (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 /* Record a tag. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1583 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1584 pfnote (name, is_func, linestart, linelen, lno, cno)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1585 char *name; /* tag name, or NULL if unnamed */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1586 bool is_func; /* tag is a function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 char *linestart; /* start of the line where tag is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 int linelen; /* length of the line where tag is */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 int lno; /* line number */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 long cno; /* character number */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1592 register node *np;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1593
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1594 if (CTAGS && name == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1595 return;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1596
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1597 np = xnew (1, node);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 /* If ctags mode, change name "main" to M<thisfilename>. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 if (CTAGS && !cxref_style && streq (name, "main"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 register char *fp = etags_strrchr (curfile, '/');
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1603 np->name = concat ("M", fp == NULL ? curfile : fp + 1, "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 fp = etags_strrchr (np->name, '.');
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1605 if (fp != NULL && fp[1] != '\0' && fp[2] == '\0')
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1606 fp[0] = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 np->name = name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 np->been_warned = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 np->file = curfile;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 np->is_func = is_func;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 np->lno = lno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 /* Our char numbers are 0-base, because of C language tradition?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 ctags compatibility? old versions compatibility? I don't know.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1616 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
1617 of the difference. If we wanted to have 1-based numbers, we would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 uncomment the +1 below. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 np->cno = cno /* + 1 */ ;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 np->left = np->right = NULL;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1621 if (CTAGS && !cxref_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1622 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1623 if (strlen (linestart) < 50)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1624 np->pat = concat (linestart, "$", "");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1625 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1626 np->pat = savenstr (linestart, 50);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1627 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1628 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1629 np->pat = savenstr (linestart, linelen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 add_node (np, &head);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1634 /* Date: Wed, 22 Jan 1997 02:56:31 -0500 [last amended 18 Sep 1997]
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1635 * From: Sam Kendall <kendall@mv.mv.com>
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1636 * Subject: Proposal for firming up the TAGS format specification
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1637 * To: F.Potorti@cnuce.cnr.it
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1638 *
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1639 * pfnote should emit the optimized form [unnamed tag] only if:
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1640 * 1. name does not contain any of the characters " \t\r\n(),;";
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1641 * 2. linestart contains name as either a rightmost, or rightmost but
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1642 * one character, substring;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1643 * 3. the character, if any, immediately before name in linestart must
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1644 * be one of the characters " \t(),;";
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1645 * 4. the character, if any, immediately after name in linestart must
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1646 * also be one of the characters " \t(),;".
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1647 *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1648 * The real implementation uses the notinname() macro, which recognises
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1649 * characters slightly different form " \t\r\n(),;". See the variable
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1650 * `nonam'.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1651 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1652 #define traditional_tag_style TRUE
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1653 static void
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1654 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1655 char *name; /* tag name, or NULL if unnamed */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1656 int namelen; /* tag length */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1657 bool is_func; /* tag is a function */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1658 char *linestart; /* start of the line where tag is */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1659 int linelen; /* length of the line where tag is */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1660 int lno; /* line number */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1661 long cno; /* character number */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1662 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1663 register char *cp;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1664 bool named;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1665
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1666 named = TRUE;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1667 if (!CTAGS)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1668 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1669 for (cp = name; !notinname (*cp); cp++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1670 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1671 if (*cp == '\0') /* rule #1 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1672 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1673 cp = linestart + linelen - namelen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1674 if (notinname (linestart[linelen-1]))
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1675 cp -= 1; /* rule #4 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1676 if (cp >= linestart /* rule #2 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1677 && (cp == linestart
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1678 || notinname (cp[-1])) /* rule #3 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1679 && strneq (name, cp, namelen)) /* rule #2 */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1680 named = FALSE; /* use unnamed tag */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1681 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1682 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1683
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1684 if (named)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1685 name = savenstr (name, namelen);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1686 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1687 name = NULL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1688 pfnote (name, is_func, linestart, linelen, lno, cno);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1689 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1690
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 * free_tree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 * recurse on left children, iterate on right children.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1695 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1696 free_tree (np)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1697 register node *np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1699 while (np)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1701 register node *node_right = np->right;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1702 free_tree (np->left);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1703 if (np->name != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1704 free (np->name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1705 free (np->pat);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1706 free (np);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1707 np = node_right;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 * add_node ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 * 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
1714 * it sorted; we just keep a linear list. In ctags mode, maintain
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 * an ordered tree, with no attempt at balancing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 * add_node is the only function allowed to add nodes, so it can
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 * maintain state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1720 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1721 add_node (np, cur_node_p)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1722 node *np, **cur_node_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 register int dif;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1725 register node *cur_node = *cur_node_p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 if (cur_node == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1729 *cur_node_p = np;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1730 last_node = np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 if (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 /* Etags Mode */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 if (last_node == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1738 fatal ("internal error in add_node", (char *)NULL);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1739 last_node->right = np;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1740 last_node = np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 /* Ctags Mode */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1745 dif = strcmp (np->name, cur_node->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 * If this tag name matches an existing one, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749 * do not add the node, but maybe print a warning.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 if (!dif)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1753 if (streq (np->file, cur_node->file))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 if (!no_warnings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1758 np->file, lineno, np->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 fprintf (stderr, "Second entry ignored\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 else if (!cur_node->been_warned && !no_warnings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 fprintf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 (stderr,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 "Duplicate entry in files %s and %s: %s (Warning only)\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1767 np->file, cur_node->file, np->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 cur_node->been_warned = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 /* Actually add the node */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1774 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1778 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1779 put_entries (np)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1780 register node *np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 register char *sp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1784 if (np == NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 /* Output subentries that precede this one */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1788 put_entries (np->left);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 /* Output this entry */
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 (!CTAGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1794 if (np->name != NULL)
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1795 fprintf (tagf, "%s\177%s\001%d,%ld\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1796 np->pat, np->name, np->lno, np->cno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 else
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1798 fprintf (tagf, "%s\177%d,%ld\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1799 np->pat, np->lno, np->cno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1801 else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1803 if (np->name == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1804 error ("internal error: NULL name in ctags mode.", (char *)NULL);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1805
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1806 if (cxref_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1807 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1808 if (vgrind_style)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1809 fprintf (stdout, "%s %s %d\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1810 np->name, np->file, (np->lno + 63) / 64);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1811 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1812 fprintf (stdout, "%-16s %3d %-16s %s\n",
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1813 np->name, np->lno, np->file, np->pat);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 else
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1816 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1817 fprintf (tagf, "%s\t%s\t", np->name, np->file);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1818
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1819 if (np->is_func)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1820 { /* a function */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1821 putc (searchar, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1822 putc ('^', tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1823
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1824 for (sp = np->pat; *sp; sp++)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1825 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1826 if (*sp == '\\' || *sp == searchar)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1827 putc ('\\', tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1828 putc (*sp, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1829 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1830 putc (searchar, tagf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1831 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1832 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1833 { /* a typedef; text pattern inadequate */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1834 fprintf (tagf, "%d", np->lno);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1835 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1836 putc ('\n', tagf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 /* Output subentries that follow this one */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1841 put_entries (np->right);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 /* Length of a number's decimal representation. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1845 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1846 number_len (num)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1847 long num;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1849 int len = 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1850 while ((num /= 10) > 0)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1851 len += 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 return len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 * Return total number of characters that put_entries will output for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 * the nodes in the subtree of the specified node. Works only if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 * we are not ctags, but called only in that case. This count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 * is irrelevant with the new tags.el, but is still supplied for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 * backward compatibility.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1862 static int
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1863 total_size_of_entries (np)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1864 register node *np;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 register int total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1868 if (np == NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1871 for (total = 0; np != NULL; np = np->right)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 /* Count left subentries. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1874 total += total_size_of_entries (np->left);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 /* Count this entry */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1877 total += strlen (np->pat) + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1878 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1879 if (np->name != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
1880 total += 1 + strlen (np->name); /* \001name */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 return total;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 * The C symbol tables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 enum sym_type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1891 st_none,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1892 st_C_objprot, st_C_objimpl, st_C_objend,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1893 st_C_gnumacro,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1894 st_C_ignore,
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1895 st_C_javastruct,
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1896 st_C_operator,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1897 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1900 static unsigned int hash P_((const char *, unsigned int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1901 static struct C_stab_entry * in_word_set P_((const char *, unsigned int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1902 static enum sym_type C_symtype P_((char *, int, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1903
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 /* Feed stuff between (but not including) %[ and %] lines to:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1905 gperf -c -k 1,3 -o -p -r -t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 %[
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1907 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
1908 %%
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1909 if, 0, st_C_ignore
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1910 for, 0, st_C_ignore
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1911 while, 0, st_C_ignore
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1912 switch, 0, st_C_ignore
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1913 return, 0, st_C_ignore
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1914 @interface, 0, st_C_objprot
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1915 @protocol, 0, st_C_objprot
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1916 @implementation,0, st_C_objimpl
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1917 @end, 0, st_C_objend
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1918 import, C_JAVA, st_C_ignore
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1919 package, C_JAVA, st_C_ignore
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
1920 friend, C_PLPL, st_C_ignore
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1921 extends, C_JAVA, st_C_javastruct
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
1922 implements, C_JAVA, st_C_javastruct
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
1923 interface, C_JAVA, st_C_struct
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
1924 class, C_PLPL, st_C_struct
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1925 namespace, C_PLPL, st_C_struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 domain, C_STAR, st_C_struct
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
1927 union, 0, st_C_struct
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 struct, 0, st_C_struct
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1929 extern, 0, st_C_extern
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 enum, 0, st_C_enum
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 typedef, 0, st_C_typedef
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 define, 0, st_C_define
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1933 operator, C_PLPL, st_C_operator
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1934 bool, C_PLPL, st_C_typespec
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 long, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 short, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 int, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 char, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 float, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 double, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 signed, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 unsigned, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 auto, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 void, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 static, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 const, 0, st_C_typespec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 volatile, 0, st_C_typespec
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1948 explicit, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1949 mutable, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1950 typename, C_PLPL, st_C_typespec
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1951 # 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
1952 DEFUN, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1953 SYSCALL, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1954 ENTRY, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1955 PSEUDO, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1956 # These are defined inside C functions, so currently they are not met.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1957 # EXFUN used in glibc, DEFVAR_* in emacs.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1958 #EXFUN, 0, st_C_gnumacro
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1959 #DEFVAR_, 0, st_C_gnumacro
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 %]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 and replace lines between %< and %> with its output. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 /*%<*/
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1963 /* C code produced by gperf version 2.7.1 (19981006 egcs) */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1964 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1965 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
1966
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1967 #define TOTAL_KEYWORDS 46
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1968 #define MIN_WORD_LENGTH 2
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1969 #define MAX_WORD_LENGTH 15
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1970 #define MIN_HASH_VALUE 13
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1971 #define MAX_HASH_VALUE 123
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1972 /* maximum key range = 111, duplicates = 0 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1973
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1974 #ifdef __GNUC__
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1975 __inline
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1976 #endif
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1977 static unsigned int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
1978 hash (str, len)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1979 register const char *str;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1980 register unsigned int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
1982 static unsigned char asso_values[] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1984 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1985 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1986 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1987 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1988 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1989 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1990 124, 124, 124, 124, 3, 124, 124, 124, 43, 6,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1991 11, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1992 11, 124, 124, 58, 7, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1993 124, 124, 124, 124, 124, 124, 124, 57, 7, 42,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1994 4, 14, 52, 0, 124, 53, 124, 124, 29, 11,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1995 6, 35, 32, 124, 29, 34, 59, 58, 51, 24,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1996 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1997 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1998 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
1999 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2000 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2001 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2002 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2003 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2004 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2005 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2006 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2007 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2008 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2009 124, 124, 124, 124, 124, 124
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2010 };
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2011 register int hval = len;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2012
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2013 switch (hval)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2014 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2015 default:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2016 case 3:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2017 hval += asso_values[(unsigned char)str[2]];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2018 case 2:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2019 case 1:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2020 hval += asso_values[(unsigned char)str[0]];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2021 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2022 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2023 return hval;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2026 #ifdef __GNUC__
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2027 __inline
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2028 #endif
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2029 static struct C_stab_entry *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2030 in_word_set (str, len)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2031 register const char *str;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2032 register unsigned int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2034 static struct C_stab_entry wordlist[] =
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2036 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2037 {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2038 {"@end", 0, st_C_objend},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2039 {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2040 {"ENTRY", 0, st_C_gnumacro},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2041 {"@interface", 0, st_C_objprot},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2042 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2043 {"domain", C_STAR, st_C_struct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2044 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2045 {"PSEUDO", 0, st_C_gnumacro},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2046 {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2047 {"namespace", C_PLPL, st_C_struct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2048 {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2049 {"@implementation",0, st_C_objimpl},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2050 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2051 {"long", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2052 {"signed", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2053 {"@protocol", 0, st_C_objprot},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2054 {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2055 {"bool", C_PLPL, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2056 {""}, {""}, {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2057 {"const", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2058 {"explicit", C_PLPL, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2059 {"if", 0, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2060 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2061 {"operator", C_PLPL, st_C_operator},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2062 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2063 {"DEFUN", 0, st_C_gnumacro},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2064 {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2065 {"define", 0, st_C_define},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2066 {""}, {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2067 {"double", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2068 {"struct", 0, st_C_struct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2069 {""}, {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2070 {"short", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2071 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2072 {"enum", 0, st_C_enum},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2073 {"mutable", C_PLPL, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2074 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2075 {"extern", 0, st_C_extern},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2076 {"extends", C_JAVA, st_C_javastruct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2077 {"package", C_JAVA, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2078 {"while", 0, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2079 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2080 {"for", 0, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2081 {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2082 {"volatile", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2083 {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2084 {"import", C_JAVA, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2085 {"float", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2086 {"switch", 0, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2087 {"return", 0, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2088 {"implements", C_JAVA, st_C_javastruct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2089 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2090 {"static", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2091 {"typedef", 0, st_C_typedef},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2092 {"typename", C_PLPL, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2093 {"unsigned", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2094 {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2095 {"char", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2096 {"class", C_PLPL, st_C_struct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2097 {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2098 {"void", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2099 {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2100 {"friend", C_PLPL, st_C_ignore},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2101 {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2102 {"int", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2103 {"union", 0, st_C_struct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2104 {""}, {""}, {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2105 {"auto", 0, st_C_typespec},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2106 {"interface", C_JAVA, st_C_struct},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2107 {""},
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2108 {"SYSCALL", 0, st_C_gnumacro}
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 register int key = hash (str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2115 if (key <= MAX_HASH_VALUE && key >= 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2117 register const char *s = wordlist[key].name;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2118
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2119 if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120 return &wordlist[key];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 /*%>*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2127 static enum sym_type
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2128 C_symtype (str, len, c_ext)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2129 char *str;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2130 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2131 int c_ext;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2133 register struct C_stab_entry *se = in_word_set (str, len);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 return st_none;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137 return se->type;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 /*
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2141 * C functions and variables are recognized using a simple
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2142 * finite automaton. fvdef is its state variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2144 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2146 fvnone, /* nothing seen */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2147 foperator, /* func: operator keyword seen (cplpl) */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2148 fvnameseen, /* function or variable name seen */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2149 fstartlist, /* func: just after open parenthesis */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2150 finlist, /* func: in parameter list */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2151 flistseen, /* func: after parameter list */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2152 fignore, /* func: before open brace */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2153 vignore /* var-like: ignore until ';' */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2154 } fvdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2156 bool fvextern; /* func or var: extern keyword seen; */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 * typedefs are recognized using a simple finite automaton.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2160 * typdef is its state variable.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2162 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 tnone, /* nothing seen */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2165 tkeyseen, /* typedef keyword seen */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2166 ttypeseen, /* defined type seen */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2167 tinbody, /* inside typedef body */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168 tend, /* just before typedef tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 tignore /* junk after typedef tag */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2170 } typdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 * struct-like structures (enum, struct and union) are recognized
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175 * using another simple finite automaton. `structdef' is its state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 * variable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2178 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 snone, /* nothing seen yet */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 skeyseen, /* struct-like keyword seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 stagseen, /* struct-like tag seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183 scolonseen, /* colon seen after struct-like tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 sinbody /* in struct body: recognize member func defs*/
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2185 } structdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 * When structdef is stagseen, scolonseen, or sinbody, structtag is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 * struct tag, and structtype is the type of the preceding struct-like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190 * keyword.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2192 char *structtag = "<uninited>";
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 enum sym_type structtype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2196 * 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
2197 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2198 char *objtag = "<uninited>";
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2199
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2200 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 * Yet another little state machine to deal with preprocessor lines.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2203 enum
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 dnone, /* nothing seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 dsharpseen, /* '#' seen as first char on line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 ddefineseen, /* '#' and 'define' seen */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 dignorerest /* ignore rest of line */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2209 } definedef;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2210
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2211 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2212 * State machine for Objective C protocols and implementations.
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2213 * Tom R.Hageman <tom@basil.icce.rug.nl>
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2214 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2215 enum
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2216 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2217 onone, /* nothing seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2218 oprotocol, /* @interface or @protocol seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2219 oimplementation, /* @implementations seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2220 otagseen, /* class name seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2221 oparenseen, /* parenthesis before category seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2222 ocatseen, /* category name seen */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2223 oinbody, /* in @implementation body */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2224 omethodsign, /* in @implementation body, after +/- */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2225 omethodtag, /* after method name */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2226 omethodcolon, /* after method colon */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2227 omethodparm, /* after method parameter */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2228 oignore /* wait for @end */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2229 } objdef;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
2231
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2232 /*
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2233 * 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
2234 * 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
2235 */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2236 typedef struct
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2237 {
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2238 bool valid;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2239 char *str;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2240 bool named;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2241 int linelen;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2242 int lineno;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2243 long linepos;
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2244 char *buffer;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2245 } token;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2246
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2247 token tok; /* latest token read */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2248
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 * Set this to TRUE, and the next token considered is called a function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 * Used only for GNU emacs's function-defining macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2253 bool next_token_is_func;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 * 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
2257 */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2258 bool yacc_rules;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2261 * methodlen is the length of the method name stored in token_name.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2262 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2263 int methodlen;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2264
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2265 static bool consider_token P_((char *, int, int, int, int, int, bool *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2266 static void make_C_tag P_((bool));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2267
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2268 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 * consider_token ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 * 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
2271 * function or variable, or corresponds to a typedef, or
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2272 * is a struct/union/enum tag, or #define, or an enum constant.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2274 * *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
2275 * with args. C_EXT is which language we are looking at.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 * Globals
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2278 * fvdef IN OUT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 * structdef IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 * definedef IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 * typdef IN OUT
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2282 * objdef IN OUT
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 * next_token_is_func IN OUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2285
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2286 static bool
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2287 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
2288 register char *str; /* IN: token pointer */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 register int len; /* IN: token length */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2290 register int c; /* IN: first char after the token */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 int c_ext; /* IN: C extensions mask */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 int cblev; /* IN: curly brace level */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2293 int parlev; /* IN: parenthesis level */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2294 bool *is_func_or_var; /* OUT: function or variable found */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 enum sym_type toktype = C_symtype (str, len, c_ext);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 * Advance the definedef state machine.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 switch (definedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 case dnone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 /* We're not on a preprocessor line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 case dsharpseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 if (toktype == st_C_define)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 definedef = ddefineseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 definedef = dignorerest;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 case ddefineseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 * Make a tag for any macro, unless it is a constant
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 * and constantypedefs is FALSE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 definedef = dignorerest;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2322 *is_func_or_var = (c == '(');
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2323 if (!*is_func_or_var && !constantypedefs)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 case dignorerest:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 default:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2330 error ("internal error: definedef value.", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 * Now typedefs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 case tnone:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 if (toktype == st_C_typedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 if (typedefs)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2342 typdef = tkeyseen;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2343 fvextern = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2344 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 break;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2348 case tkeyseen:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 case st_none:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 case st_C_typespec:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 case st_C_enum:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2355 typdef = ttypeseen;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 /* Do not return here, so the structdef stuff has a chance. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 case tend:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 switch (toktype)
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 st_C_typespec:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 case st_C_enum:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 * This structdef business is currently only invoked when cblev==0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 * It should be recursively invoked whatever the curly brace level,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 * and a stack of states kept, to allow for definitions of structs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 * within structs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 * This structdef business is NOT invoked when we are ctags and the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 * 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
2379 * name as another tag, and this loses with ctags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2383 case st_C_javastruct:
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2384 if (structdef == stagseen)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2385 structdef = scolonseen;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2386 return FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 case st_C_struct:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 case st_C_enum:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2389 if (typdef == tkeyseen
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 || (typedefs_and_cplusplus && cblev == 0 && structdef == snone))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 structdef = skeyseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 structtype = toktype;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2397
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 if (structdef == skeyseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2400 /* Save the tag for struct/union/class, for functions and variables
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2401 that may be defined inside. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 if (structtype == st_C_struct)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 structtag = savenstr (str, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 structtag = "<enum>";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 structdef = stagseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 if (typdef != tnone)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2411 definedef = dnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2413 /* Detect GNU macros.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2414
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2415 Writers of emacs code are recommended to put the
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2416 first two args of a DEFUN on the same line.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2417
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2418 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
2419 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
2420 is a C function name. Since etags skips strings, the second arg
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2421 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
2422 first arg. The simplest way to deal with this problem would be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2423 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
2424 removing the initial 'F' character and substituting '-' for '_'.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2425 Anyway, this assumes that the conventions of naming lisp
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2426 functions will never change. Currently, this method is not
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2427 implemented. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2428 if (definedef == dnone && toktype == st_C_gnumacro)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2429 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2430 next_token_is_func = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2431 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2432 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 if (next_token_is_func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 next_token_is_func = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2436 fvdef = fignore;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2437 *is_func_or_var = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2441 /* Detect Objective C constructs. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2442 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2443 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2444 case onone:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2445 switch (toktype)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2446 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2447 case st_C_objprot:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2448 objdef = oprotocol;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2449 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2450 case st_C_objimpl:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2451 objdef = oimplementation;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2452 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2453 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2454 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2455 case oimplementation:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2456 /* Save the class tag for functions or variables defined inside. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2457 objtag = savenstr (str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2458 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2459 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2460 case oprotocol:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2461 /* Save the class tag for categories. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2462 objtag = savenstr (str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2463 objdef = otagseen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2464 *is_func_or_var = TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2465 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2466 case oparenseen:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2467 objdef = ocatseen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2468 *is_func_or_var = TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2469 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2470 case oinbody:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2471 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2472 case omethodsign:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2473 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2474 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2475 objdef = omethodtag;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2476 methodlen = len;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2477 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2478 strncpy (token_name.buffer, str, len);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2479 token_name.buffer[methodlen] = '\0';
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2480 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2481 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2482 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2483 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2484 case omethodcolon:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2485 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2486 objdef = omethodparm;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2487 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2488 case omethodparm:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2489 if (parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2490 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2491 objdef = omethodtag;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2492 methodlen += len;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2493 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2494 strncat (token_name.buffer, str, len);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2495 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2496 return TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2497 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2498 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2499 case oignore:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2500 if (toktype == st_C_objend)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2501 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2502 /* Memory leakage here: the string pointed by objtag is
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2503 never released, because many tests would be needed to
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2504 avoid breaking on incorrect input code. The amount of
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2505 memory leaked here is the sum of the lengths of the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2506 class tags.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2507 free (objtag); */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2508 objdef = onone;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2509 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2510 return FALSE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2511 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2512
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2513 /* A function, variable or enum constant? */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 switch (toktype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2516 case st_C_extern:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2517 fvextern = TRUE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2518 /* FALLTHRU */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 case st_C_typespec:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2520 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2521 fvdef = fvnone; /* should be useless */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2522 return FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2523 case st_C_ignore:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2524 fvextern = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2525 fvdef = vignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 return FALSE;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2527 case st_C_operator:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2528 fvdef = foperator;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2529 *is_func_or_var = TRUE;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2530 return TRUE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2531 case st_none:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2532 if ((c_ext & C_PLPL) && strneq (str+len-10, "::operator", 10))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2533 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2534 fvdef = foperator;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2535 *is_func_or_var = TRUE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2536 return TRUE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2537 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2538 if (constantypedefs && structdef == sinbody && structtype == st_C_enum)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2539 return TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2540 if (fvdef == fvnone)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2542 fvdef = fvnameseen; /* function or variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2543 *is_func_or_var = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2546 break;
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
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 * C_entries ()
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2554 * This routine finds functions, variables, typedefs,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2555 * #define's, enum constants and struct/union/enum definitions in
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2556 * C syntax and adds them to the list.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 #define current_lb_is_new (newndx == curndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 #define switch_line_buffers() (curndx = 1 - curndx)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 #define curlb (lbs[curndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 #define othlb (lbs[1-curndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 #define newlb (lbs[newndx].lb)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 #define curlinepos (lbs[curndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 #define othlinepos (lbs[1-curndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 #define newlinepos (lbs[newndx].linepos)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2568 #define CNL_SAVE_DEFINEDEF() \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 do { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 curlinepos = charno; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 lineno++; \
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2572 linecharno = charno; \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 charno += readline (&curlb, inf); \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 lp = curlb.buffer; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 quotednl = FALSE; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 newndx = curndx; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2579 #define CNL() \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 do { \
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2581 CNL_SAVE_DEFINEDEF(); \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 if (savetok.valid) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 { \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 tok = savetok; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 savetok.valid = FALSE; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 } \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 definedef = dnone; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2590
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2591 static void
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2592 make_C_tag (isfun)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2593 bool isfun;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2594 {
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2595 /* This function should never be called when tok.valid is FALSE, but
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2596 we must protect against invalid input or internal errors. */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2597 if (tok.valid)
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2598 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2599 if (traditional_tag_style)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2600 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2601 /* This was the original code. Now we call new_pfnote instead,
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2602 which uses the new method for naming tags (see new_pfnote). */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2603 char *name = NULL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2604
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2605 if (CTAGS || tok.named)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2606 name = savestr (token_name.buffer);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2607 pfnote (name, isfun,
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2608 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2609 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2610 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2611 new_pfnote (token_name.buffer, token_name.len, isfun,
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2612 tok.buffer, tok.linelen, tok.lineno, tok.linepos);
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2613 tok.valid = FALSE;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2614 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2615 else if (DEBUG)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2616 abort ();
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2617 }
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
2618
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2619
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2620 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2621 C_entries (c_ext, inf)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2622 int c_ext; /* extension of C */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2623 FILE *inf; /* input file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2624 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2625 register char c; /* latest char read; '\0' for end of line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2626 register char *lp; /* pointer one beyond the character `c' */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2627 int curndx, newndx; /* indices for current and new lb */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2628 register int tokoff; /* offset in line of start of current token */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2629 register int toklen; /* length of current token */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2630 char *qualifier; /* string used to qualify names */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2631 int qlen; /* length of qualifier */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2632 int cblev; /* current curly brace level */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2633 int parlev; /* current parenthesis level */
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2634 bool incomm, inquote, inchar, quotednl, midtoken;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2635 bool purec, cplpl, cjava;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2636 token savetok; /* token saved during preprocessor handling */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2637
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2638
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2639 tokoff = toklen = 0; /* keep compiler quiet */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2640 curndx = newndx = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2641 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2642 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2643 lp = curlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2644 *lp = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2645
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2646 fvdef = fvnone; fvextern = FALSE; typdef = tnone;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2647 structdef = snone; definedef = dnone; objdef = onone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2648 next_token_is_func = yacc_rules = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2649 midtoken = inquote = inchar = incomm = quotednl = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2650 tok.valid = savetok.valid = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2651 cblev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2652 parlev = 0;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2653 purec = !(c_ext & ~YACC); /* no extensions (apart from possibly yacc) */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2654 cplpl = (c_ext & C_PLPL) == C_PLPL;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2655 cjava = (c_ext & C_JAVA) == C_JAVA;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2656 if (cjava)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2657 { qualifier = "."; qlen = 1; }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2658 else
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2659 { qualifier = "::"; qlen = 2; }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2660
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2661 while (!feof (inf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2662 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2663 c = *lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2664 if (c == '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2665 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2666 /* 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
2667 '\0'; don't skip it, because it's the thing that tells us
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2668 to read the next line. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2669 if (*lp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2670 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2671 quotednl = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2672 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2673 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2674 lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2675 c = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2676 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2677 else if (incomm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2678 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2679 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2680 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2681 case '*':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2682 if (*lp == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2683 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2684 c = *lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2685 incomm = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2686 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2687 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2688 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2689 /* Newlines inside comments do not end macro definitions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2690 traditional cpp. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2691 CNL_SAVE_DEFINEDEF ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2692 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2693 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2694 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2695 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2696 else if (inquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2697 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2698 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2699 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2700 case '"':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2701 inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2702 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2703 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2704 /* Newlines inside strings do not end macro definitions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2705 in traditional cpp, even though compilers don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2706 usually accept them. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2707 CNL_SAVE_DEFINEDEF ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2708 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2709 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2710 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2711 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2712 else if (inchar)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2713 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2714 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2715 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2716 case '\0':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2717 /* Hmmm, something went wrong. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
2718 CNL ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2719 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2720 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2721 inchar = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2722 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2723 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2724 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2725 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2726 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2727 switch (c)
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 '"':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2730 inquote = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2731 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2732 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2733 fvextern = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2734 fvdef = fvnone;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2735 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2736 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2737 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2738 inchar = TRUE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2739 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2740 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2741 fvextern = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2742 fvdef = fvnone;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2743 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2744 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2745 case '/':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2746 if (*lp == '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2747 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2748 lp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2749 incomm = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2750 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2751 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2752 else if (/* cplpl && */ *lp == '/')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2753 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2754 c = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2755 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2756 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2757 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2758 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2759 case '%':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2760 if ((c_ext & YACC) && *lp == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2761 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2762 /* entering or exiting rules section in yacc file */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2763 lp++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2764 definedef = dnone; fvdef = fvnone; fvextern = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2765 typdef = tnone; structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2766 next_token_is_func = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2767 midtoken = inquote = inchar = incomm = quotednl = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2768 cblev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2769 yacc_rules = !yacc_rules;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2770 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2772 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2773 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2774 case '#':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2775 if (definedef == dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2776 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2777 char *cp;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2778 bool cpptoken = TRUE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2779
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2780 /* Look back on this line. If all blanks, or nonblanks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2781 followed by an end of comment, this is a preprocessor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2782 token. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2783 for (cp = newlb.buffer; cp < lp-1; cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2784 if (!iswhite (*cp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2785 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2786 if (*cp == '*' && *(cp+1) == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2787 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2788 cp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2789 cpptoken = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2790 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2791 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2792 cpptoken = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2793 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2794 if (cpptoken)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2795 definedef = dsharpseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2796 } /* if (definedef == dnone) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2797
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2798 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2799 } /* switch (c) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2801
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2802 /* Consider token only if some complicated conditions are satisfied. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2803 if ((definedef != dnone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2804 || (cblev == 0 && structdef != scolonseen)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2805 || (cblev == 1 && cplpl && structdef == sinbody)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2806 || (structdef == sinbody && purec))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2807 && typdef != tignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2808 && definedef != dignorerest
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2809 && fvdef != finlist)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2810 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2811 if (midtoken)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2812 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2813 if (endtoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2814 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2815 bool funorvar = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2816
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2817 if (c == ':' && cplpl && *lp == ':' && begtoken (lp[1]))
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 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2820 * This handles :: in the middle, but not at the
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2821 * beginning of an identifier. Also, space-separated
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2822 * :: is not recognised.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2823 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2824 lp += 2;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2825 toklen += 2;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2826 c = lp[-1];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2827 goto intok;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2828 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2829 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2830 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2831 if (yacc_rules
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2832 || consider_token (newlb.buffer + tokoff, toklen, c,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2833 c_ext, cblev, parlev, &funorvar))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2834 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2835 if (fvdef == foperator)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2836 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2837 char *oldlp = lp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2838 lp = skip_spaces (lp-1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2839 if (*lp != '\0')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2840 lp += 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2841 while (*lp != '\0'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2842 && !iswhite (*lp) && *lp != '(')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2843 lp += 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2844 c = *lp++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2845 toklen += lp - oldlp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2846 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2847 tok.named = FALSE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2848 if (!purec
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2849 && funorvar
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2850 && definedef == dnone
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2851 && structdef == sinbody)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2852 /* function or var defined in C++ class body */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2853 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2854 int len = strlen (structtag) + qlen + toklen;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2855 grow_linebuffer (&token_name, len + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2856 strcpy (token_name.buffer, structtag);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2857 strcat (token_name.buffer, qualifier);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2858 strncat (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2859 newlb.buffer + tokoff, toklen);
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2860 token_name.len = len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2861 tok.named = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2862 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2863 else if (objdef == ocatseen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2864 /* Objective C category */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2865 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2866 int len = strlen (objtag) + 2 + toklen;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2867 grow_linebuffer (&token_name, len + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2868 strcpy (token_name.buffer, objtag);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2869 strcat (token_name.buffer, "(");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2870 strncat (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2871 newlb.buffer + tokoff, toklen);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2872 strcat (token_name.buffer, ")");
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2873 token_name.len = len;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2874 tok.named = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2875 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2876 else if (objdef == omethodtag
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2877 || objdef == omethodparm)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2878 /* Objective C method */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2879 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2880 tok.named = TRUE;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2881 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2882 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2883 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2884 grow_linebuffer (&token_name, toklen + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2885 strncpy (token_name.buffer,
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2886 newlb.buffer + tokoff, toklen);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2887 token_name.buffer[toklen] = '\0';
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2888 token_name.len = toklen;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2889 /* Name macros and members. */
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
2890 tok.named = (structdef == stagseen
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2891 || typdef == ttypeseen
282
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
2892 || typdef == tend
c42ec1d1cded Import from CVS: tag r21-0b39
cvs
parents: 278
diff changeset
2893 || (funorvar
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2894 && definedef == dignorerest)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2895 || (funorvar
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2896 && definedef == dnone
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2897 && structdef == sinbody));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2898 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2899 tok.lineno = lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2900 tok.linelen = tokoff + toklen + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2901 tok.buffer = newlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2902 tok.linepos = newlinepos;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2903 tok.valid = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2904
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2905 if (definedef == dnone
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2906 && (fvdef == fvnameseen
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
2907 || fvdef == foperator
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2908 || structdef == stagseen
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2909 || typdef == tend
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2910 || objdef != onone))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2911 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2912 if (current_lb_is_new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2913 switch_line_buffers ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2914 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2915 else
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2916 make_C_tag (funorvar);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2917 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2918 midtoken = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2919 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2920 } /* if (endtoken (c)) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2921 else if (intoken (c))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2922 intok:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2923 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2924 toklen++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2925 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2926 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2927 } /* if (midtoken) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2928 else if (begtoken (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2929 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2930 switch (definedef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2931 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2932 case dnone:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2933 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2934 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2935 case fstartlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2936 fvdef = finlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2937 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2938 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2939 make_C_tag (TRUE); /* a function */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2940 fvdef = fignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2941 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2942 case fvnameseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2943 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2944 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2945 }
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
2946 if (structdef == stagseen && !cjava)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2947 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2948 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2949 case dsharpseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2950 savetok = tok;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2951 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2952 if (!yacc_rules || lp == newlb.buffer + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2953 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2954 tokoff = lp - 1 - newlb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2955 toklen = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2956 midtoken = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2957 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2958 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2959 } /* if (begtoken) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2960 } /* if must look at token */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2961
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2962
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2963 /* Detect end of line, colon, comma, semicolon and various braces
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2964 after having handled a token.*/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2965 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2966 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2967 case ':':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2968 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2969 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2970 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2971 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2972 case otagseen:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2973 objdef = oignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2974 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2975 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2976 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2977 case omethodparm:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2978 objdef = omethodcolon;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2979 methodlen += 1;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2980 grow_linebuffer (&token_name, methodlen + 1);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2981 strcat (token_name.buffer, ":");
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2982 token_name.len = methodlen;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2983 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
2984 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2985 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2986 structdef = scolonseen;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2987 else
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2988 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2989 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
2990 case fvnameseen:
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2991 if (yacc_rules)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2992 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2993 make_C_tag (FALSE); /* a yacc function */
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2994 fvdef = fignore;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2995 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2996 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2997 case fstartlist:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
2998 fvextern = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
2999 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3000 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3001 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3002 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3003 case ';':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3004 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3005 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3006 if (cblev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3007 switch (typdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3008 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3009 case tend:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3010 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3011 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3012 default:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3013 typdef = tnone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3014 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3015 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3016 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3017 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3018 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3019 case fvnameseen:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3020 if ((members && cblev == 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3021 || (globals && cblev == 0 && (!fvextern || declarations)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3022 make_C_tag (FALSE); /* a variable */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3023 fvextern = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3024 fvdef = fvnone;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3025 tok.valid = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3026 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3027 case flistseen:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3028 if (declarations && (cblev == 0 || cblev == 1))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3029 make_C_tag (TRUE); /* a function declaration */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3030 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3031 default:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3032 fvextern = FALSE;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3033 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3034 /* The following instruction invalidates the token.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3035 Probably the token should be invalidated in all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3036 other cases where some state machine is reset. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3037 tok.valid = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3038 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3039 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3040 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3041 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3042 case ',':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3043 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3044 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3045 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3046 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3047 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3048 case omethodparm:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3049 make_C_tag (TRUE); /* an Objective C method */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3050 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3051 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3052 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3053 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3054 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3055 case foperator:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3056 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3057 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3058 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3059 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3060 case fvnameseen:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3061 if ((members && cblev == 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3062 || (globals && cblev == 0 && (!fvextern || declarations)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3063 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3064 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3065 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3066 fvdef = fvnone;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3067 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3068 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3069 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3070 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3071 case '[':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3072 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3073 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3074 if (cblev == 0 && typdef == tend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3075 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3076 typdef = tignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3077 make_C_tag (FALSE); /* a typedef */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3078 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3079 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3080 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3081 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3082 case foperator:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3083 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3084 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3085 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3086 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3087 case fvnameseen:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3088 if ((members && cblev == 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3089 || (globals && cblev == 0 && (!fvextern || declarations)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3090 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3091 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3092 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3093 fvdef = fvnone;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3094 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3095 if (structdef == stagseen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3096 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3097 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3098 case '(':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3099 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3100 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3101 if (objdef == otagseen && parlev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3102 objdef = oparenseen;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3103 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3104 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3105 case fvnameseen:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3106 if (typdef == ttypeseen
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3107 && tok.valid
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3108 && *lp != '*'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3109 && structdef != sinbody)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3110 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3111 /* This handles constructs like:
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3112 typedef void OperatorFun (int fun); */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3113 make_C_tag (FALSE);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3114 typdef = tignore;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3115 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3116 /* FALLTHRU */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3117 case foperator:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3118 fvdef = fstartlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3119 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3120 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3121 fvdef = finlist;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3122 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3123 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3124 parlev++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3125 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3126 case ')':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3127 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3128 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3129 if (objdef == ocatseen && parlev == 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3130 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3131 make_C_tag (TRUE); /* an Objective C category */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3132 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3133 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3134 if (--parlev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3135 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3136 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3137 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3138 case fstartlist:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3139 case finlist:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3140 fvdef = flistseen;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3141 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3142 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3143 if (cblev == 0 && (typdef == tend))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3144 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3145 typdef = tignore;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3146 make_C_tag (FALSE); /* a typedef */
0
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 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3150 parlev = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3151 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3152 case '{':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3153 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3154 break;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3155 if (typdef == ttypeseen)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3156 typdef = tinbody;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3157 switch (structdef)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3158 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3159 case skeyseen: /* unnamed struct */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3160 structdef = sinbody;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3161 structtag = "_anonymous_";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3162 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3163 case stagseen:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3164 case scolonseen: /* named struct */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3165 structdef = sinbody;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3166 make_C_tag (FALSE); /* a struct */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3167 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3168 }
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3169 switch (fvdef)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3170 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3171 case flistseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3172 make_C_tag (TRUE); /* a function */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3173 /* FALLTHRU */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3174 case fignore:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3175 fvdef = fvnone;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3176 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3177 case fvnone:
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3178 switch (objdef)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3179 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3180 case otagseen:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3181 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3182 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3183 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3184 case omethodtag:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3185 case omethodparm:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3186 make_C_tag (TRUE); /* an Objective C method */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3187 objdef = oinbody;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3188 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3189 default:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3190 /* Neutralize `extern "C" {' grot. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3191 if (cblev == 0 && structdef == snone && typdef == tnone)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3192 cblev = -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3193 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3194 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3195 cblev++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3196 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3197 case '*':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3198 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3199 break;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3200 if (fvdef == fstartlist)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3201 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3202 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3203 case '}':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3204 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3205 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3206 if (!noindentypedefs && lp == newlb.buffer + 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3207 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3208 cblev = 0; /* reset curly brace level if first column */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3209 parlev = 0; /* also reset paren level, just in case... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3210 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3211 else if (cblev > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3212 cblev--;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3213 if (cblev == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3214 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3215 if (typdef == tinbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3216 typdef = tend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3217 /* Memory leakage here: the string pointed by structtag is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3218 never released, because I fear to miss something and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3219 break things while freeing the area. The amount of
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3220 memory leaked here is the sum of the lengths of the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3221 struct tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3222 if (structdef == sinbody)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3223 free (structtag); */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3224
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3225 structdef = snone;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3226 structtag = "<error>";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3227 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3228 break;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3229 case '=':
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3230 if (definedef != dnone)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3231 break;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3232 switch (fvdef)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3233 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3234 case foperator:
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3235 case finlist:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3236 case fignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3237 case vignore:
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3238 break;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3239 case fvnameseen:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3240 if ((members && cblev == 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3241 || (globals && cblev == 0 && (!fvextern || declarations)))
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3242 make_C_tag (FALSE); /* a variable */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3243 /* FALLTHRU */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3244 default:
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3245 fvdef = vignore;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3246 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3247 break;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3248 case '+':
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3249 case '-':
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3250 if (objdef == oinbody && cblev == 0)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3251 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3252 objdef = omethodsign;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3253 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3254 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3255 /* FALLTHRU */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3256 case '#': case '~': case '&': case '%': case '/': case '|':
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3257 case '^': case '!': case '<': case '>': case '.': case '?': case ']':
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3258 if (definedef != dnone)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3259 break;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3260 /* These surely cannot follow a function tag in C. */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3261 switch (fvdef)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3262 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3263 case foperator:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3264 case finlist:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3265 case fignore:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3266 case vignore:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3267 break;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3268 default:
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3269 fvdef = fvnone;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3270 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3271 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3272 case '\0':
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3273 if (objdef == otagseen)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3274 {
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3275 make_C_tag (TRUE); /* an Objective C class */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3276 objdef = oignore;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3277 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3278 /* If a macro spans multiple lines don't reset its state. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3279 if (quotednl)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3280 CNL_SAVE_DEFINEDEF ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3281 else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3282 CNL ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3283 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3284 } /* switch (c) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3286 } /* while not eof */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3287 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3289 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3290 * Process either a C++ file or a C file depending on the setting
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3291 * of a global flag.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3292 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3293 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3294 default_C_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3295 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3296 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3297 C_entries (cplusplus ? C_PLPL : 0, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3300 /* Always do plain ANSI C. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3301 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3302 plain_C_entries (inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3303 FILE *inf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3304 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3305 C_entries (0, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3306 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3308 /* Always do C++. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3309 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3310 Cplusplus_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3311 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3312 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3313 C_entries (C_PLPL, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3314 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3315
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3316 /* Always do Java. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3317 static void
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3318 Cjava_entries (inf)
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3319 FILE *inf;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3320 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3321 C_entries (C_JAVA, inf);
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3322 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
3323
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3324 /* Always do C*. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3325 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3326 Cstar_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3327 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3328 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3329 C_entries (C_STAR, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3330 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3332 /* Always do Yacc. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3333 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3334 Yacc_entries (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3335 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3336 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3337 C_entries (YACC, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3338 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3339
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3340 /* A useful macro. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3341 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3342 for (lineno = charno = 0; /* loop initialization */ \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3343 !feof (file_pointer) /* loop test */ \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3344 && (lineno++, /* instructions at start of loop */ \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3345 linecharno = charno, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3346 charno += readline (&line_buffer, file_pointer), \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3347 char_pointer = lb.buffer, \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3348 TRUE); \
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3349 )
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3350
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3351
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3352 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3353 * Read a file, but do no processing. This is used to do regexp
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3354 * matching on files that have no language defined.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3355 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3356 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3357 just_read_file (inf)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3358 FILE *inf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3359 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3360 register char *dummy;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3361
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3362 LOOP_ON_INPUT_LINES (inf, lb, dummy)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3363 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3364 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3365
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3366 /* Fortran parsing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3367
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3368 static bool tail P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3369 static void takeprec P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3370 static void getit P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3371
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3372 static bool
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3373 tail (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3374 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3375 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3376 register int len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3377
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3378 while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len]))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3379 cp++, len++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3380 if (*cp == '\0' && !intoken (dbp[len]))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3382 dbp += len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3383 return TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3384 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3385 return FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3386 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3387
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3388 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3389 takeprec ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3390 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3391 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3392 if (*dbp != '*')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3393 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3394 dbp++;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3395 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3396 if (strneq (dbp, "(*)", 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3397 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3398 dbp += 3;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3399 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3400 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3401 if (!isdigit ((unsigned char) *dbp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3402 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3403 --dbp; /* force failure */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3404 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3405 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3406 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3407 dbp++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3408 while (isdigit ((unsigned char) *dbp));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3409 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3410
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3411 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3412 getit (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3413 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3414 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3415 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3416
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3417 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3418 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3419 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3420 lineno++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3421 linecharno = charno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3422 charno += readline (&lb, inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3423 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3424 if (dbp[5] != '&')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3425 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3426 dbp += 6;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3427 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3428 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3429 if (!isalpha ((unsigned char) *dbp) && *dbp != '_' && *dbp != '$')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3430 return;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3431 for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3432 continue;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3433 pfnote (savenstr (dbp, cp-dbp), TRUE,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3434 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3435 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3436
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3437
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3438 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3439 Fortran_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3440 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3441 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3442 LOOP_ON_INPUT_LINES (inf, lb, dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3443 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3444 if (*dbp == '%')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3445 dbp++; /* Ratfor escape to fortran */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3446 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3447 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3448 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3449 switch (lowcase (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3450 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3451 case 'i':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3452 if (tail ("integer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3453 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3454 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3455 case 'r':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3456 if (tail ("real"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3457 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3458 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3459 case 'l':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3460 if (tail ("logical"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3461 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3462 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3463 case 'c':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3464 if (tail ("complex") || tail ("character"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3465 takeprec ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3466 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3467 case 'd':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3468 if (tail ("double"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3469 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3470 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3471 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3472 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3473 if (tail ("precision"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3474 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3475 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3476 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3477 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3478 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3479 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3480 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3481 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3482 switch (lowcase (*dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3483 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3484 case 'f':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3485 if (tail ("function"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3486 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3487 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3488 case 's':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3489 if (tail ("subroutine"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3490 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3491 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3492 case 'e':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3493 if (tail ("entry"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3494 getit (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3495 continue;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3496 case 'b':
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3497 if (tail ("blockdata") || tail ("block data"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3498 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3499 dbp = skip_spaces (dbp);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3500 if (*dbp == '\0') /* assume un-named */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3501 pfnote (savestr ("blockdata"), TRUE,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3502 lb.buffer, dbp - lb.buffer, lineno, linecharno);
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3503 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3504 getit (inf); /* look for name */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3505 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3506 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3507 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3508 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3509 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3511 /*
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3512 * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be>, 1998-04-24
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3513 * Ada parsing
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3514 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3515
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3516 static void adagetit P_((FILE *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3517
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3518 /* Once we are positioned after an "interesting" keyword, let's get
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3519 the real tag value necessary. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3520 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3521 adagetit (inf, name_qualifier)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3522 FILE *inf;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3523 char *name_qualifier;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3524 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3525 register char *cp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3526 char *name;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3527 char c;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3528
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3529 while (!feof (inf))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3530 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3531 dbp = skip_spaces (dbp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3532 if (*dbp == '\0'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3533 || (dbp[0] == '-' && dbp[1] == '-'))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3534 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3535 lineno++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3536 linecharno = charno;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3537 charno += readline (&lb, inf);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3538 dbp = lb.buffer;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3539 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3540 switch (*dbp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3541 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3542 case 'b':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3543 case 'B':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3544 if (tail ("body"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3545 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3546 /* Skipping body of procedure body or package body or ....
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3547 resetting qualifier to body instead of spec. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3548 name_qualifier = "/b";
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3549 continue;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3550 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3551 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3552 case 't':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3553 case 'T':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3554 /* Skipping type of task type or protected type ... */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3555 if (tail ("type"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3556 continue;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3557 break;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3558 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3559 if (*dbp == '"')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3560 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3561 dbp += 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3562 for (cp = dbp; *cp != '\0' && *cp != '"'; cp++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3563 continue;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3564 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3565 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3566 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3567 dbp = skip_spaces (dbp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3568 for (cp = dbp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3569 (*cp != '\0'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3570 && (isalpha ((unsigned char) *cp) || isdigit ((unsigned char) *cp) || *cp == '_' || *cp == '.'));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3571 cp++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3572 continue;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3573 if (cp == dbp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3574 return;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3575 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3576 c = *cp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3577 *cp = '\0';
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3578 name = concat (dbp, name_qualifier, "");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3579 *cp = c;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3580 pfnote (name, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3581 if (c == '"')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3582 dbp = cp + 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3583 return;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3584 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3585 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3586
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3587 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3588 Ada_funcs (inf)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3589 FILE *inf;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3590 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3591 bool inquote = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3592
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3593 LOOP_ON_INPUT_LINES (inf, lb, dbp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3594 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3595 while (*dbp != '\0')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3596 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3597 /* Skip a string i.e. "abcd". */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3598 if (inquote || (*dbp == '"'))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3599 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3600 dbp = etags_strchr ((inquote) ? dbp : dbp+1, '"');
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3601 if (dbp != NULL)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3602 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3603 inquote = FALSE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3604 dbp += 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3605 continue; /* advance char */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3606 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3607 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3608 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3609 inquote = TRUE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3610 break; /* advance line */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3611 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3612 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3613
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3614 /* Skip comments. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3615 if (dbp[0] == '-' && dbp[1] == '-')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3616 break; /* advance line */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3617
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3618 /* Skip character enclosed in single quote i.e. 'a'
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3619 and skip single quote starting an attribute i.e. 'Image. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3620 if (*dbp == '\'')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3621 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3622 dbp++ ;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3623 if (*dbp != '\0')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3624 dbp++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3625 continue;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3626 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3627
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3628 /* Search for beginning of a token. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3629 if (!begtoken (*dbp))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3630 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3631 dbp++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3632 continue; /* advance char */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3633 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3634
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3635 /* We are at the beginning of a token. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3636 switch (*dbp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3637 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3638 case 'f':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3639 case 'F':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3640 if (!packages_only && tail ("function"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3641 adagetit (inf, "/f");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3642 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3643 break; /* from switch */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3644 continue; /* advance char */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3645 case 'p':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3646 case 'P':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3647 if (!packages_only && tail ("procedure"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3648 adagetit (inf, "/p");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3649 else if (tail ("package"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3650 adagetit (inf, "/s");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3651 else if (tail ("protected")) /* protected type */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3652 adagetit (inf, "/t");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3653 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3654 break; /* from switch */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3655 continue; /* advance char */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3656 case 't':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3657 case 'T':
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3658 if (!packages_only && tail ("task"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3659 adagetit (inf, "/k");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3660 else if (typedefs && !packages_only && tail ("type"))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3661 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3662 adagetit (inf, "/t");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3663 while (*dbp != '\0')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3664 dbp += 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3665 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3666 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3667 break; /* from switch */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3668 continue; /* advance char */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3669 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3670
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3671 /* Look for the end of the token. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3672 while (!endtoken (*dbp))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3673 dbp++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3674
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3675 } /* advance char */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3676 } /* advance line */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3677 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3678
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3679 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3680 * Bob Weiner, Motorola Inc., 4/3/94
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3681 * Unix and microcontroller assembly tag handling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3682 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3683 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3684 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3685 Asm_labels (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 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3689
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3690 LOOP_ON_INPUT_LINES (inf, lb, cp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3691 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3692 /* If first char is alphabetic or one of [_.$], test for colon
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3693 following identifier. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3694 if (isalpha ((unsigned char) *cp) || *cp == '_' || *cp == '.' || *cp == '$')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3695 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3696 /* Read past label. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3697 cp++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3698 while (isalnum ((unsigned char) *cp) || *cp == '_' || *cp == '.' || *cp == '$')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3699 cp++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3700 if (*cp == ':' || iswhite (*cp))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3701 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3702 /* Found end of label, so copy it and add it to the table. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3703 pfnote (savenstr(lb.buffer, cp-lb.buffer), TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3704 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3705 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3706 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3707 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3708 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3710 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3711 * Perl support by Bart Robinson <lomew@cs.utah.edu>
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3712 * enhanced by Michael Ernst <mernst@alum.mit.edu>
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3713 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3714 * Perl variable names: /^(my|local).../
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3715 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3716 static void
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3717 Perl_functions (inf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3718 FILE *inf;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3719 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3720 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3721
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3722 LOOP_ON_INPUT_LINES (inf, lb, cp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3723 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3724 if (*cp++ == 's'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3725 && *cp++ == 'u'
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3726 && *cp++ == 'b' && iswhite (*cp++))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3727 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3728 cp = skip_spaces (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3729 if (*cp != '\0')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3730 {
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3731 char *sp = cp;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3732 while (*cp != '\0'
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3733 && !iswhite (*cp) && *cp != '{' && *cp != '(')
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3734 cp++;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3735 pfnote (savenstr (sp, cp-sp), TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3736 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3737 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3738 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3739 else if (globals /* only if tagging global vars is enabled */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3740 && ((cp = lb.buffer,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3741 *cp++ == 'm'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3742 && *cp++ == 'y')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3743 || (cp = lb.buffer,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3744 *cp++ == 'l'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3745 && *cp++ == 'o'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3746 && *cp++ == 'c'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3747 && *cp++ == 'a'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3748 && *cp++ == 'l'))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3749 && (*cp == '(' || iswhite (*cp)))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3750 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3751 /* After "my" or "local", but before any following paren or space. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3752 char *varname = NULL;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3753
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3754 cp = skip_spaces (cp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3755 if (*cp == '$' || *cp == '@' || *cp == '%')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3756 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3757 char* varstart = ++cp;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3758 while (isalnum ((unsigned char) *cp) || *cp == '_')
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3759 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3760 varname = savenstr (varstart, cp-varstart);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3761 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3762 else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3763 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3764 /* Should be examining a variable list at this point;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3765 could insist on seeing an open parenthesis. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3766 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3767 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3768 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3769
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3770 /* Perhaps I should back cp up one character, so the TAGS table
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3771 doesn't mention (and so depend upon) the following char. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3772 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3773 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3774 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3775 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3776 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3777
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3778 /*
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3779 * Python support by Eric S. Raymond <esr@thyrsus.com>
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3780 * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3781 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3782 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3783 Python_functions (inf)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3784 FILE *inf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3785 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3786 register char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3787
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3788 LOOP_ON_INPUT_LINES (inf, lb, cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3789 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3790 if (*cp++ == 'd'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3791 && *cp++ == 'e'
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3792 && *cp++ == 'f' && iswhite (*cp++))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3793 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3794 cp = skip_spaces (cp);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3795 while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3796 cp++;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3797 pfnote (NULL, TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3798 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3799 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3800
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3801 cp = lb.buffer;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3802 if (*cp++ == 'c'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3803 && *cp++ == 'l'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3804 && *cp++ == 'a'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3805 && *cp++ == 's'
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3806 && *cp++ == 's' && iswhite (*cp++))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3807 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3808 cp = skip_spaces (cp);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3809 while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3810 cp++;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3811 pfnote (NULL, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3812 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3813 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3814 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3815 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3816
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3817 /* Idea by Corny de Souza
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3818 * Cobol tag functions
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3819 * We could look for anything that could be a paragraph name.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3820 * 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
3821 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3822 static void
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3823 Cobol_paragraphs (inf)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3824 FILE *inf;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3825 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3826 register char *bp, *ep;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3827
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3828 LOOP_ON_INPUT_LINES (inf, lb, bp)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3829 {
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3830 if (lb.len < 9)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3831 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3832 bp += 8;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3833
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3834 /* If eoln, compiler option or comment ignore whole line. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3835 if (bp[-1] != ' ' || !isalnum ((unsigned char) bp[0]))
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3836 continue;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3837
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3838 for (ep = bp; isalnum ((unsigned char) *ep) || *ep == '-'; ep++)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3839 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3840 if (*ep++ == '.')
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3841 pfnote (savenstr (bp, ep-bp), TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3842 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3843 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3844 }
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3845
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3846 /* Added by Mosur Mohan, 4/22/88 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3847 /* Pascal parsing */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3849 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3850 * Locates tags for procedures & functions. Doesn't do any type- or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3851 * var-definitions. It does look for the keyword "extern" or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3852 * "forward" immediately following the procedure statement; if found,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3853 * the tag is skipped.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3854 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3855 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3856 Pascal_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3857 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3858 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3859 linebuffer tline; /* mostly copied from C_entries */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3860 long save_lcno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3861 int save_lineno, save_len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3862 char c, *cp, *namebuf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3863
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
3864 bool /* each of these flags is TRUE iff: */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3865 incomment, /* point is inside a comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3866 inquote, /* point is inside '..' string */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3867 get_tagname, /* point is after PROCEDURE/FUNCTION
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3868 keyword, so next item = potential tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3869 found_tag, /* point is after a potential tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3870 inparms, /* point is within parameter-list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3871 verify_tag; /* point has passed the parm-list, so the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3872 next token will determine whether this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3873 is a FORWARD/EXTERN to be ignored, or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3874 whether it is a real tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3875
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3876 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3877 namebuf = NULL; /* keep compiler quiet */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3878 lineno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3879 charno = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3880 dbp = lb.buffer;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3881 *dbp = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3882 initbuffer (&tline);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3884 incomment = inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3885 found_tag = FALSE; /* have a proc name; check if extern */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3886 get_tagname = FALSE; /* have found "procedure" keyword */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3887 inparms = FALSE; /* found '(' after "proc" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3888 verify_tag = FALSE; /* check if "extern" is ahead */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3889
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3890
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
3891 while (!feof (inf)) /* long main loop to get next char */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3892 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3893 c = *dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3894 if (c == '\0') /* if end of line */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3895 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3896 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3897 linecharno = charno;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3898 charno += readline (&lb, inf);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3899 dbp = lb.buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3900 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3901 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3902 if (!((found_tag && verify_tag)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
3903 || get_tagname))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3904 c = *dbp++; /* only if don't need *dbp pointing
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3905 to the beginning of the name of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3906 the procedure or function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3907 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3908 if (incomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3909 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3910 if (c == '}') /* within { } comments */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3911 incomment = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3912 else if (c == '*' && *dbp == ')') /* within (* *) comments */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3913 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3914 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3915 incomment = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3916 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3917 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3918 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3919 else if (inquote)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3920 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3921 if (c == '\'')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3922 inquote = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3923 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3924 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3925 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3926 switch (c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3927 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3928 case '\'':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3929 inquote = TRUE; /* found first quote */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3930 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3931 case '{': /* found open { comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3932 incomment = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3933 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3934 case '(':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3935 if (*dbp == '*') /* found open (* comment */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3936 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3937 incomment = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3938 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3939 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3940 else if (found_tag) /* found '(' after tag, i.e., parm-list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3941 inparms = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3942 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3943 case ')': /* end of parms list */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3944 if (inparms)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3945 inparms = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3946 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3947 case ';':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3948 if (found_tag && !inparms) /* end of proc or fn stmt */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3949 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3950 verify_tag = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3951 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3952 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3953 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3954 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3955 if (found_tag && verify_tag && (*dbp != ' '))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3956 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3957 /* check if this is an "extern" declaration */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3958 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3959 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3960 if (lowcase (*dbp == 'e'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3961 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3962 if (tail ("extern")) /* superfluous, really! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3963 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3964 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3965 verify_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3966 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3967 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3968 else if (lowcase (*dbp) == 'f')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3969 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3970 if (tail ("forward")) /* check for forward reference */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3971 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3972 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3973 verify_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3974 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3975 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3976 if (found_tag && verify_tag) /* not external proc, so make tag */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3977 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3978 found_tag = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3979 verify_tag = FALSE;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
3980 pfnote (namebuf, TRUE,
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3981 tline.buffer, save_len, save_lineno, save_lcno);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3982 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3983 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3984 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3985 if (get_tagname) /* grab name of proc or fn */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3986 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3987 if (*dbp == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3988 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3989
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3990 /* save all values for later tagging */
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
3991 grow_linebuffer (&tline, lb.len + 1);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3992 strcpy (tline.buffer, lb.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3993 save_lineno = lineno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3994 save_lcno = linecharno;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3995
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3996 /* grab block name */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
3997 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3998 continue;
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
3999 namebuf = savenstr (dbp, cp-dbp);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4000 dbp = cp; /* set dbp to e-o-token */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4001 save_len = dbp - lb.buffer + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4002 get_tagname = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4003 found_tag = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4004 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4006 /* and proceed to check for "extern" */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4007 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4008 else if (!incomment && !inquote && !found_tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4009 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4010 /* check for proc/fn keywords */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4011 switch (lowcase (c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4012 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4013 case 'p':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4014 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4015 get_tagname = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4016 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4017 case 'f':
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4018 if (tail ("unction"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4019 get_tagname = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4020 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4021 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4022 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4023 } /* while not eof */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4024
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4025 free (tline.buffer);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4026 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4028 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4029 * lisp tag functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4030 * look for (def or (DEF, quote or QUOTE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4031 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4032
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4033 static int L_isdef P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4034 static int L_isquote P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4035 static void L_getit P_((void));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4036
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4037 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4038 L_isdef (strp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4039 register char *strp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4040 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4041 return ((strp[1] == 'd' || strp[1] == 'D')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4042 && (strp[2] == 'e' || strp[2] == 'E')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4043 && (strp[3] == 'f' || strp[3] == 'F'));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4044 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4045
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4046 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4047 L_isquote (strp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4048 register char *strp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4049 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4050 return ((*++strp == 'q' || *strp == 'Q')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4051 && (*++strp == 'u' || *strp == 'U')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4052 && (*++strp == 'o' || *strp == 'O')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4053 && (*++strp == 't' || *strp == 'T')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4054 && (*++strp == 'e' || *strp == 'E')
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4055 && iswhite (*++strp));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4056 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4057
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4058 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4059 L_getit ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4060 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4061 register char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4062
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4063 if (*dbp == '\'') /* Skip prefix quote */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4064 dbp++;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4065 else if (*dbp == '(')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4066 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4067 if (L_isquote (dbp))
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4068 dbp += 7; /* Skip "(quote " */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4069 else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4070 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4071 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4072 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4073
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4074 for (cp = dbp /*+1*/;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4075 *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4076 cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4077 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4078 if (cp == dbp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4079 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4080
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4081 pfnote (savenstr (dbp, cp-dbp), TRUE,
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4082 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4083 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4084
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4085 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4086 Lisp_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4087 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4088 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4089 LOOP_ON_INPUT_LINES (inf, lb, dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4090 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4091 if (dbp[0] == '(')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4092 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4093 if (L_isdef (dbp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4094 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4095 dbp = skip_non_spaces (dbp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4096 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4097 L_getit ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4098 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4099 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4100 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4101 /* Check for (foo::defmumble name-defined ... */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4102 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4103 dbp++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4104 while (*dbp != '\0' && !iswhite (*dbp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4105 && *dbp != ':' && *dbp != '(' && *dbp != ')');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4106 if (*dbp == ':')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4107 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4108 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4109 dbp++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4110 while (*dbp == ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4111
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4112 if (L_isdef (dbp - 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4113 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4114 dbp = skip_non_spaces (dbp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4115 dbp = skip_spaces (dbp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4116 L_getit ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4117 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4119 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4120 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4121 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4122 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4123
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4124 /*
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4125 * Postscript tag functions
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4126 * Just look for lines where the first character is '/'
371
cc15677e0335 Import from CVS: tag r21-2b1
cvs
parents: 367
diff changeset
4127 * Richard Mlynarik <mly@adoc.xerox.com>
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4128 * Also look at "defineps" for PSWrap
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4129 * suggested by Masatake YAMATO <masata-y@is.aist-nara.ac.jp>
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4130 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4131 static void
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4132 Postscript_functions (inf)
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4133 FILE *inf;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4134 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4135 register char *bp, *ep;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4136
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4137 LOOP_ON_INPUT_LINES (inf, lb, bp)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4138 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4139 if (bp[0] == '/')
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4140 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4141 for (ep = bp+1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4142 *ep != '\0' && *ep != ' ' && *ep != '{';
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4143 ep++)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4144 continue;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4145 pfnote (savenstr (bp, ep-bp), TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4146 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4147 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4148 else if (strneq (bp, "defineps", 8))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4149 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4150 bp = skip_non_spaces (bp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4151 bp = skip_spaces (bp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4152 get_tag (bp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4153 }
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4154 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4155 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4156
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4157
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4158 /*
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4159 * Scheme tag functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4160 * look for (def... xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4161 * look for (def... (xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4162 * look for (def ... ((...(xyzzy ....
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4163 * look for (set! xyzzy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4164 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4165
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4166 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4167 Scheme_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4168 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4169 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4170 register char *bp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4171
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4172 LOOP_ON_INPUT_LINES (inf, lb, bp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4173 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4174 if (bp[0] == '('
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4175 && (bp[1] == 'D' || bp[1] == 'd')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4176 && (bp[2] == 'E' || bp[2] == 'e')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4177 && (bp[3] == 'F' || bp[3] == 'f'))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4178 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4179 bp = skip_non_spaces (bp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4180 /* Skip over open parens and white space */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4181 while (iswhite (*bp) || *bp == '(')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4182 bp++;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4183 get_tag (bp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4184 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4185 if (bp[0] == '('
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4186 && (bp[1] == 'S' || bp[1] == 's')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4187 && (bp[2] == 'E' || bp[2] == 'e')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4188 && (bp[3] == 'T' || bp[3] == 't')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4189 && (bp[4] == '!' || bp[4] == '!')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4190 && (iswhite (bp[5])))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4191 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4192 bp = skip_non_spaces (bp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4193 bp = skip_spaces (bp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4194 get_tag (bp);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4195 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4196 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4197 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4199 /* Find tags in TeX and LaTeX input files. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4201 /* TEX_toktab is a table of TeX control sequences that define tags.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4202 Each TEX_tabent records one such control sequence.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4203 CONVERT THIS TO USE THE Stab TYPE!! */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4204 struct TEX_tabent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4205 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4206 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4207 int len;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4208 };
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4210 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4211
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4212 /* Default set of control sequences to put into TEX_toktab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4213 The value of environment var TEXTAGS is prepended to this. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4214
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4215 char *TEX_defenv = "\
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4216 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4217 :part:appendix:entry:index";
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4218
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4219 static void TEX_mode P_((FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4220 static struct TEX_tabent *TEX_decode_env P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4221 static int TEX_Token P_((char *));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4222
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4223 char TEX_esc = '\\';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4224 char TEX_opgrp = '{';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4225 char TEX_clgrp = '}';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4227 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4228 * TeX/LaTeX scanning loop.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4229 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4230 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4231 TeX_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4232 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4233 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4234 char *cp, *lasthit;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4235 register int i;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4237 /* Select either \ or ! as escape character. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4238 TEX_mode (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4240 /* Initialize token table once from environment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4241 if (!TEX_toktab)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4242 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4243
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4244 LOOP_ON_INPUT_LINES (inf, lb, cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4245 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4246 lasthit = cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4247 /* Look at each esc in line. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4248 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4249 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4250 if (*++cp == '\0')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4251 break;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4252 linecharno += cp - lasthit;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4253 lasthit = cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4254 i = TEX_Token (lasthit);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4255 if (i >= 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4256 {
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4257 /* We seem to include the TeX command in the tag name.
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4258 register char *p;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4259 for (p = lasthit + TEX_toktab[i].len;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4260 *p != '\0' && *p != TEX_clgrp;
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4261 p++)
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4262 continue; */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4263 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4264 lb.buffer, lb.len, lineno, linecharno);
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4265 break; /* We only tag a line once */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4267 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4268 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4269 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4270
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4271 #define TEX_LESC '\\'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4272 #define TEX_SESC '!'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4273 #define TEX_cmt '%'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4275 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4276 chars accordingly. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4277 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4278 TEX_mode (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4279 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4280 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4281 int c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4282
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4283 while ((c = getc (inf)) != EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4284 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4285 /* Skip to next line if we hit the TeX comment char. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4286 if (c == TEX_cmt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4287 while (c != '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4288 c = getc (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4289 else if (c == TEX_LESC || c == TEX_SESC )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4290 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4291 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4293 if (c == TEX_LESC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4294 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4295 TEX_esc = TEX_LESC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4296 TEX_opgrp = '{';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4297 TEX_clgrp = '}';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4298 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4299 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4300 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4301 TEX_esc = TEX_SESC;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4302 TEX_opgrp = '<';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4303 TEX_clgrp = '>';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4304 }
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4305 /* If the input file is compressed, inf is a pipe, and rewind may fail.
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4306 No attempt is made to correct the situation. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4307 rewind (inf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4308 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4310 /* Read environment and prepend it to the default string.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4311 Build token table. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4312 static struct TEX_tabent *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4313 TEX_decode_env (evarname, defenv)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4314 char *evarname;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4315 char *defenv;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4316 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4317 register char *env, *p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4318
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4319 struct TEX_tabent *tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4320 int size, i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4322 /* Append default string to environment. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4323 env = getenv (evarname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4324 if (!env)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4325 env = defenv;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4326 else
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4327 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4328 char *oldenv = env;
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4329 env = concat (oldenv, defenv, "");
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4330 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4332 /* Allocate a token table */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4333 for (size = 1, p = env; p;)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4334 if ((p = etags_strchr (p, ':')) && *++p != '\0')
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4335 size++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4336 /* Add 1 to leave room for null terminator. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4337 tab = xnew (size + 1, struct TEX_tabent);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4339 /* Unpack environment string into token table. Be careful about */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4340 /* zero-length strings (leading ':', "::" and trailing ':') */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4341 for (i = 0; *env;)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4342 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4343 p = etags_strchr (env, ':');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4344 if (!p) /* End of environment string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4345 p = env + strlen (env);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4346 if (p - env > 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4347 { /* Only non-zero strings. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4348 tab[i].name = savenstr (env, p - env);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4349 tab[i].len = strlen (tab[i].name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4350 i++;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4351 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4352 if (*p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4353 env = p + 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4354 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4355 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4356 tab[i].name = NULL; /* Mark end of table. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4357 tab[i].len = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4358 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4359 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4360 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4361 return tab;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4362 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4363
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4364 /* 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
4365 return the pointer to the first occurrence of that command in TEX_toktab.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4366 Otherwise return -1.
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4367 Keep the capital `T' in `token' for dumb truncating compilers
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4368 (this distinguishes it from `TEX_toktab' */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4369 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4370 TEX_Token (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4371 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4372 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4373 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4374
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4375 for (i = 0; TEX_toktab[i].len > 0; i++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4376 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4377 return i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4378 return -1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4379 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4380
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4381 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4382 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4383 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4384 * Assumes that the predicate starts at column 0.
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4385 * Only the first clause of a predicate is added.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4386 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4387 static int prolog_pred P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4388 static void prolog_skip_comment P_((linebuffer *, FILE *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4389 static int prolog_atom P_((char *, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4390
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4391 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4392 Prolog_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4393 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4394 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4395 char *cp, *last;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4396 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4397 int allocated;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4398
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4399 allocated = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4400 len = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4401 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4402
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4403 LOOP_ON_INPUT_LINES (inf, lb, cp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4404 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4405 if (cp[0] == '\0') /* Empty line */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4406 continue;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4407 else if (iswhite (cp[0])) /* Not a predicate */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4408 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4409 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4410 prolog_skip_comment (&lb, inf);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4411 else if ((len = prolog_pred (cp, last)) > 0)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4412 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4413 /* Predicate. Store the function name so that we only
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
4414 generate a tag for the first clause. */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4415 if (last == NULL)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4416 last = xnew(len + 1, char);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4417 else if (len + 1 > allocated)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4418 last = xrnew (last, len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4419 allocated = len + 1;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4420 strncpy (last, cp, len);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4421 last[len] = '\0';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4422 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4423 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4424 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4425
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4426
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4427 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4428 prolog_skip_comment (plb, inf)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4429 linebuffer *plb;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4430 FILE *inf;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4431 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4432 char *cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4434 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4435 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4436 for (cp = plb->buffer; *cp != '\0'; cp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4437 if (cp[0] == '*' && cp[1] == '/')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4438 return;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4439 lineno++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4440 linecharno += readline (plb, inf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4441 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4442 while (!feof(inf));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4443 }
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4444
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4445 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4446 * A predicate definition is added if it matches:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4447 * <beginning of line><Prolog Atom><whitespace>(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4448 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4449 * 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
4450 * name of the previous clause header.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4451 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4452 * 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
4453 * was found.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4454 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4455 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4456 prolog_pred (s, last)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4457 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4458 char *last; /* Name of last clause. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4459 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4460 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4461 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4462
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4463 pos = prolog_atom (s, 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4464 if (pos < 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4465 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4466
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4467 len = pos;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4468 pos = skip_spaces (s + pos) - s;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4469
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4470 if ((s[pos] == '(') || (s[pos] == '.'))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4471 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4472 if (s[pos] == '(')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4473 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4474
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4475 /* Save only the first clause. */
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4476 if (last == NULL
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4477 || len != (int)strlen (last)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4478 || !strneq (s, last, len))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4479 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4480 pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4481 return len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4482 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4483 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4484 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4485 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4486
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4487 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4488 * Consume a Prolog atom.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4489 * 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
4490 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4491 * A prolog atom, in this context, could be one of:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4492 * - An alphanumeric sequence, starting with a lower case letter.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4493 * - A quoted arbitrary string. Single quotes can escape themselves.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4494 * Backslash quotes everything.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4495 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4496 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4497 prolog_atom (s, pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4498 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4499 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4500 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4501 int origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4502
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4503 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4504
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4505 if (islower((unsigned char) s[pos]) || (s[pos] == '_'))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4506 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4507 /* The atom is unquoted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4508 pos++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4509 while (isalnum((unsigned char) s[pos]) || (s[pos] == '_'))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4510 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4511 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4512 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4513 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4514 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4515 else if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4516 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4517 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4518
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4519 while (1)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4520 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4521 if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4522 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4523 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4524 if (s[pos] != '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4525 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4526 pos++; /* A double quote */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4527 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4528 else if (s[pos] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4529 /* Multiline quoted atoms are ignored. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4530 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4531 else if (s[pos] == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4532 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4533 if (s[pos+1] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4534 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4535 pos += 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4536 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4537 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4538 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4539 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4540 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4541 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4542 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4543 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4544 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4545
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4546 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4547 * Support for Erlang -- Anders Lindgren, Feb 1996.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4548 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4549 * Generates tags for functions, defines, and records.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4550 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4551 * Assumes that Erlang functions start at column 0.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4552 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4553 static int erlang_func P_((char *, char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4554 static void erlang_attribute P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4555 static int erlang_atom P_((char *, int));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4556
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4557 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4558 Erlang_functions (inf)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4559 FILE *inf;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4560 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4561 char *cp, *last;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4562 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4563 int allocated;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4564
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4565 allocated = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4566 len = 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4567 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4568
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4569 LOOP_ON_INPUT_LINES (inf, lb, cp)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4570 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4571 if (cp[0] == '\0') /* Empty line */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4572 continue;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4573 else if (iswhite (cp[0])) /* Not function nor attribute */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4574 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4575 else if (cp[0] == '%') /* comment */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4576 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4577 else if (cp[0] == '"') /* Sometimes, strings start in column one */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4578 continue;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4579 else if (cp[0] == '-') /* attribute, e.g. "-define" */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4580 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4581 erlang_attribute (cp);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4582 last = NULL;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4583 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4584 else if ((len = erlang_func (cp, last)) > 0)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4585 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4586 /*
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4587 * Function. Store the function name so that we only
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4588 * generates a tag for the first clause.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4589 */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4590 if (last == NULL)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4591 last = xnew (len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4592 else if (len + 1 > allocated)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4593 last = xrnew (last, len + 1, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4594 allocated = len + 1;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4595 strncpy (last, cp, len);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4596 last[len] = '\0';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4597 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4598 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4599 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4600
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4601
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4602 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4603 * A function definition is added if it matches:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4604 * <beginning of line><Erlang Atom><whitespace>(
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4605 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4606 * 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
4607 * name of the previous clause header.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4608 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4609 * 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
4610 * was found.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4611 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4612 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4613 erlang_func (s, last)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4614 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4615 char *last; /* Name of last clause. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4616 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4617 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4618 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4619
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4620 pos = erlang_atom (s, 0);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4621 if (pos < 1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4622 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4623
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4624 len = pos;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4625 pos = skip_spaces (s + pos) - s;
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4626
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4627 /* Save only the first clause. */
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4628 if (s[pos++] == '('
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4629 && (last == NULL
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4630 || len != (int)strlen (last)
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4631 || !strneq (s, last, len)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4632 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4633 pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4634 return len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4635 }
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4636
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4637 return 0;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4638 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4639
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4640
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4641 /*
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4642 * Handle attributes. Currently, tags are generated for defines
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4643 * and records.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4644 *
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4645 * They are on the form:
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4646 * -define(foo, bar).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4647 * -define(Foo(M, N), M+N).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4648 * -record(graph, {vtab = notable, cyclic = true}).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4649 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4650 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4651 erlang_attribute (s)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4652 char *s;
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 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4655 int len;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4656
153
25f70ba0133c Import from CVS: tag r20-3b3
cvs
parents: 149
diff changeset
4657 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4658 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4659 pos = skip_spaces (s + 7) - s;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4660 if (s[pos++] == '(')
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4661 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4662 pos = skip_spaces (s + pos) - s;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4663 len = erlang_atom (s, pos);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4664 if (len != 0)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4665 pfnote (savenstr (& s[pos], len), TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4666 s, pos + len, lineno, linecharno);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4667 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4668 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4669 return;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4670 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4671
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4672
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4673 /*
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4674 * Consume an Erlang atom (or variable).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4675 * 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
4676 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4677 static int
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4678 erlang_atom (s, pos)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4679 char *s;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4680 int pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4681 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4682 int origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4683
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4684 origpos = pos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4685
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4686 if (isalpha ((unsigned char) s[pos]) || s[pos] == '_')
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4687 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4688 /* The atom is unquoted. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4689 pos++;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4690 while (isalnum ((unsigned char) s[pos]) || s[pos] == '_')
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4691 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4692 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4693 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4694 else if (s[pos] == '\'')
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 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4697
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4698 while (1)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4699 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4700 if (s[pos] == '\'')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4701 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4702 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4703 break;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4704 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4705 else if (s[pos] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4706 /* Multiline quoted atoms are ignored. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4707 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4708 else if (s[pos] == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4709 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4710 if (s[pos+1] == '\0')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4711 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4712 pos += 2;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4713 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4714 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4715 pos++;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4716 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4717 return pos - origpos;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4718 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4719 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4720 return -1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4721 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4722
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4723 #ifdef ETAGS_REGEXPS
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4724
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4725 static char *scan_separators P_((char *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4726 static void analyse_regex P_((char *, bool));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4727 static void add_regex P_((char *, bool, language *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4728 static char *substitute P_((char *, char *, struct re_registers *));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4729
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4730 /* Take a string like "/blah/" and turn it into "blah", making sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4731 that the first and last characters are the same, and handling
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
4732 quoted separator characters. Actually, stops on the occurrence of
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4733 an unquoted separator. Also turns "\t" into a Tab character.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4734 Returns pointer to terminating separator. Works in place. Null
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4735 terminates name string. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4736 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4737 scan_separators (name)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4738 char *name;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4739 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4740 char sep = name[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4741 char *copyto = name;
155
43dd3413c7c7 Import from CVS: tag r20-3b4
cvs
parents: 153
diff changeset
4742 bool quoted = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4744 for (++name; *name != '\0'; ++name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4745 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4746 if (quoted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4747 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4748 if (*name == 't')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4749 *copyto++ = '\t';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4750 else if (*name == sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4751 *copyto++ = sep;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4752 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4753 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4754 /* Something else is quoted, so preserve the quote. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4755 *copyto++ = '\\';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4756 *copyto++ = *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4757 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4758 quoted = FALSE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4759 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4760 else if (*name == '\\')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4761 quoted = TRUE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4762 else if (*name == sep)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4763 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4764 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4765 *copyto++ = *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4766 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4767
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4768 /* Terminate copied string. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4769 *copyto = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4770 return name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4771 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4772
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4773 /* Look at the argument of --regex or --no-regex and do the right
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4774 thing. Same for each line of a regexp file. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4775 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4776 analyse_regex (regex_arg, ignore_case)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4777 char *regex_arg;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4778 bool ignore_case;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4779 {
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4780 if (regex_arg == NULL)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4781 free_patterns (); /* --no-regex: remove existing regexps */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4782
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4783 /* A real --regexp option or a line in a regexp file. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4784 switch (regex_arg[0])
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4785 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4786 /* Comments in regexp file or null arg to --regex. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4787 case '\0':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4788 case ' ':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4789 case '\t':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4790 break;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4791
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4792 /* Read a regex file. This is recursive and may result in a
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4793 loop, which will stop when the file descriptors are exhausted. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4794 case '@':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4795 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4796 FILE *regexfp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4797 linebuffer regexbuf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4798 char *regexfile = regex_arg + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4799
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4800 /* regexfile is a file containing regexps, one per line. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4801 regexfp = fopen (regexfile, "r");
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4802 if (regexfp == NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4803 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4804 pfatal (regexfile);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4805 return;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4806 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4807 initbuffer (&regexbuf);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4808 while (readline_internal (&regexbuf, regexfp) > 0)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4809 analyse_regex (regexbuf.buffer, ignore_case);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4810 free (regexbuf.buffer);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4811 fclose (regexfp);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4812 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4813 break;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4814
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4815 /* Regexp to be used for a specific language only. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4816 case '{':
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4817 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4818 language *lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4819 char *lang_name = regex_arg + 1;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4820 char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4821
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4822 for (cp = lang_name; *cp != '}'; cp++)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4823 if (*cp == '\0')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4824 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4825 error ("unterminated language name in regex: %s", regex_arg);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4826 return;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4827 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4828 *cp = '\0';
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4829 lang = get_language_from_name (lang_name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4830 if (lang == NULL)
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4831 return;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4832 add_regex (cp + 1, ignore_case, lang);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4833 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4834 break;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4835
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4836 /* Regexp to be used for any language. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4837 default:
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4838 add_regex (regex_arg, ignore_case, NULL);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4839 break;
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4840 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4841 }
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4842
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4843 /* Turn a name, which is an ed-style (but Emacs syntax) regular
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4844 expression, into a real regular expression by compiling it. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4845 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4846 add_regex (regexp_pattern, ignore_case, lang)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4847 char *regexp_pattern;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4848 bool ignore_case;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4849 language *lang;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4850 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4851 char *name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4852 const char *err;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4853 struct re_pattern_buffer *patbuf;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4854 pattern *pp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4855
149
538048ae2ab8 Import from CVS: tag r20-3b1
cvs
parents: 142
diff changeset
4856
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4857 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4858 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4859 error ("%s: unterminated regexp", regexp_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4860 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4861 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4862 name = scan_separators (regexp_pattern);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4863 if (regexp_pattern[0] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4864 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4865 error ("null regexp", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4866 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4867 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4868 (void) scan_separators (name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4869
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4870 patbuf = xnew (1, struct re_pattern_buffer);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4871 /* Translation table to fold case if appropriate. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4872 patbuf->translate = (ignore_case) ? lc_trans : NULL;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4873 patbuf->fastmap = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4874 patbuf->buffer = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4875 patbuf->allocated = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4876
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4877 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4878 if (err != NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4879 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4880 error ("%s while compiling pattern", err);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4881 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4882 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4883
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4884 pp = p_head;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4885 p_head = xnew (1, pattern);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4886 p_head->regex = savestr (regexp_pattern);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4887 p_head->p_next = pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4888 p_head->language = lang;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4889 p_head->pattern = patbuf;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4890 p_head->name_pattern = savestr (name);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4891 p_head->error_signaled = FALSE;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4892 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4893
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4894 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4895 * Do the substitutions indicated by the regular expression and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4896 * arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4897 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4898 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4899 substitute (in, out, regs)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4900 char *in, *out;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
4901 struct re_registers *regs;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4902 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4903 char *result, *t;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4904 int size, dig, diglen;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4905
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4906 result = NULL;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4907 size = strlen (out);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4908
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4909 /* 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
4910 if (out[size - 1] == '\\')
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4911 fatal ("pattern error in \"%s\"", out);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4912 for (t = etags_strchr (out, '\\');
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4913 t != NULL;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4914 t = etags_strchr (t + 2, '\\'))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4915 if (isdigit ((unsigned char) t[1]))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4916 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4917 dig = t[1] - '0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4918 diglen = regs->end[dig] - regs->start[dig];
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4919 size += diglen - 2;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4920 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4921 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4922 size -= 1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4923
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4924 /* Allocate space and do the substitutions. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4925 result = xnew (size + 1, char);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4926
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4927 for (t = result; *out != '\0'; out++)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4928 if (*out == '\\' && isdigit ((unsigned char) *++out))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4929 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4930 /* Using "dig2" satisfies my debugger. Bleah. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4931 dig = *out - '0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4932 diglen = regs->end[dig] - regs->start[dig];
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4933 strncpy (t, in + regs->start[dig], diglen);
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4934 t += diglen;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4935 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4936 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4937 *t++ = *out;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4938 *t = '\0';
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4939
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
4940 if (DEBUG && (t > result + size || t - result != (int)strlen (result)))
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
4941 abort ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4942
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4943 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4944 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4945
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4946 /* Deallocate all patterns. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4947 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4948 free_patterns ()
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4949 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4950 pattern *pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4951 while (p_head != NULL)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4952 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4953 pp = p_head->p_next;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4954 free (p_head->regex);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4955 free (p_head->name_pattern);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4956 free (p_head);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4957 p_head = pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4958 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4959 return;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4960 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4961
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4962 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4963 get_tag (bp)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4964 register char *bp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4965 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4966 register char *cp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4967
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4968 if (*bp == '\0')
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4969 return;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4970 /* Go till you get to white space or a syntactic break */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4971 for (cp = bp + 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4972 *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4973 cp++)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4974 continue;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4975 pfnote (savenstr (bp, cp-bp), TRUE,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4976 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4977 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4978
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4979 #endif /* ETAGS_REGEXPS */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4980 /* Initialize a linebuffer for use */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4981 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4982 initbuffer (lbp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4983 linebuffer *lbp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4984 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4985 lbp->size = 200;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4986 lbp->buffer = xnew (200, char);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4987 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4988
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4989 /*
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4990 * Read a line of text from `stream' into `lbp', excluding the
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4991 * newline or CR-NL, if any. Return the number of characters read from
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4992 * `stream', which is the length of the line including the newline.
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4993 *
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4994 * On DOS or Windows we do not count the CR character, if any, before the
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4995 * NL, in the returned length; this mirrors the behavior of emacs on those
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4996 * platforms (for text files, it translates CR-NL to NL as it reads in the
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
4997 * file).
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4998 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
4999 static long
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5000 readline_internal (lbp, stream)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5001 linebuffer *lbp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5002 register FILE *stream;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5003 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5004 char *buffer = lbp->buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5005 register char *p = lbp->buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5006 register char *pend;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5007 int chars_deleted;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5008
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5009 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5010
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5011 while (1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5012 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5013 register int c = getc (stream);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5014 if (p == pend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5015 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5016 /* We're at the end of linebuffer: expand it. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5017 lbp->size *= 2;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5018 buffer = xrnew (buffer, lbp->size, char);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5019 p += buffer - lbp->buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5020 pend = buffer + lbp->size;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5021 lbp->buffer = buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5022 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5023 if (c == EOF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5024 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5025 *p = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5026 chars_deleted = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5027 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5028 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5029 if (c == '\n')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5030 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5031 if (p > buffer && p[-1] == '\r')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5032 {
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5033 p -= 1;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5034 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5035 /* Assume CRLF->LF translation will be performed by Emacs
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5036 when loading this file, so CRs won't appear in the buffer.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5037 It would be cleaner to compensate within Emacs;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5038 however, Emacs does not know how many CRs were deleted
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5039 before any given point in the file. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5040 chars_deleted = 1;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5041 #else
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5042 chars_deleted = 2;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5043 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5044 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5045 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5046 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5047 chars_deleted = 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5048 }
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5049 *p = '\0';
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5050 break;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5051 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5052 *p++ = c;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5053 }
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5054 lbp->len = p - buffer;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5055
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5056 return lbp->len + chars_deleted;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5057 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5058
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5059 /*
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5060 * Like readline_internal, above, but in addition try to match the
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5061 * input line against relevant regular expressions.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5062 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5063 static long
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5064 readline (lbp, stream)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5065 linebuffer *lbp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5066 FILE *stream;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5067 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5068 /* Read new line. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5069 long result = readline_internal (lbp, stream);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5070 #ifdef ETAGS_REGEXPS
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5071 int match;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5072 pattern *pp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5073
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5074 /* Match against relevant patterns. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5075 if (lbp->len > 0)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5076 for (pp = p_head; pp != NULL; pp = pp->p_next)
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5077 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5078 /* Only use generic regexps or those for the current language. */
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5079 if (pp->language != NULL && pp->language != curlang)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5080 continue;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5081
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5082 match = re_match (pp->pattern, lbp->buffer, lbp->len, 0, &pp->regs);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5083 switch (match)
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5084 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5085 case -2:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5086 /* Some error. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5087 if (!pp->error_signaled)
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5088 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5089 error ("error while matching \"%s\"", pp->regex);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5090 pp->error_signaled = TRUE;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5091 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5092 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5093 case -1:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5094 /* No match. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5095 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5096 default:
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5097 /* Match occurred. Construct a tag. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5098 if (pp->name_pattern[0] != '\0')
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5099 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5100 /* Make a named tag. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5101 char *name = substitute (lbp->buffer,
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5102 pp->name_pattern, &pp->regs);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5103 if (name != NULL)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5104 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5105 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5106 else
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5107 {
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5108 /* Make an unnamed tag. */
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5109 pfnote ((char *)NULL, TRUE,
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5110 lbp->buffer, match, lineno, linecharno);
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5111 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5112 break;
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5113 }
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5114 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5115 #endif /* ETAGS_REGEXPS */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5116
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5117 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5120 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5121 * Return a pointer to a space of size strlen(cp)+1 allocated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5122 * with xnew where the string CP has been copied.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5123 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5124 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5125 savestr (cp)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5126 char *cp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5127 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5128 return savenstr (cp, strlen (cp));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5129 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5130
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5131 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5132 * 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
5133 * the string CP has been copied for at most the first LEN characters.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5134 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5135 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5136 savenstr (cp, len)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5137 char *cp;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5138 int len;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5139 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5140 register char *dp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5142 dp = xnew (len + 1, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5143 strncpy (dp, cp, len);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5144 dp[len] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5145 return dp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5146 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5147
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5148 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5149 * Return the ptr in sp at which the character c last
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5150 * appears; NULL if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5151 *
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5152 * Identical to POSIX strrchr, included for portability.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5153 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5154 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5155 etags_strrchr (sp, c)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5156 register const char *sp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5157 register int c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5158 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5159 register const char *r;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5161 r = NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5162 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5163 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5164 if (*sp == c)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5165 r = sp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5166 } while (*sp++);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5167 return (char *)r;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5168 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5169
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5171 /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5172 * Return the ptr in sp at which the character c first
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5173 * appears; NULL if not found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5174 *
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5175 * Identical to POSIX strchr, included for portability.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5176 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5177 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5178 etags_strchr (sp, c)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5179 register const char *sp;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5180 register int c;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5181 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5182 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5183 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5184 if (*sp == c)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5185 return (char *)sp;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5186 } while (*sp++);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5187 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5188 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5189
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5190 /* Skip spaces, return new pointer. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5191 static char *
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5192 skip_spaces (cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5193 char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5194 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5195 while (iswhite (*cp))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5196 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5197 return cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5198 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5199
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5200 /* Skip non spaces, return new pointer. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5201 static char *
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5202 skip_non_spaces (cp)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5203 char *cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5204 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5205 while (*cp != '\0' && !iswhite (*cp))
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5206 cp++;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5207 return cp;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5208 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5209
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5210 /* Print error message and exit. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5211 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5212 fatal (s1, s2)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5213 char *s1, *s2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5214 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5215 error (s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5216 exit (BAD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5217 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5218
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5219 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5220 pfatal (s1)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5221 char *s1;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5222 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5223 perror (s1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5224 exit (BAD);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5225 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5226
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5227 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5228 suggest_asking_for_help ()
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5229 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5230 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5231 progname,
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5232 #ifdef LONG_OPTIONS
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5233 "--help"
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5234 #else
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5235 "-h"
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5236 #endif
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 157
diff changeset
5237 );
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5238 exit (BAD);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5239 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5240
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5241 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5242 static void
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5243 error (s1, s2)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5244 const char *s1, *s2;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5245 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5246 fprintf (stderr, "%s: ", progname);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5247 fprintf (stderr, s1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5248 fprintf (stderr, "\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5249 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5250
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5251 /* Return a newly-allocated string whose contents
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5252 concatenate those of s1, s2, s3. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5253 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5254 concat (s1, s2, s3)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5255 char *s1, *s2, *s3;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5256 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5257 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5258 char *result = xnew (len1 + len2 + len3 + 1, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5260 strcpy (result, s1);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5261 strcpy (result + len1, s2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5262 strcpy (result + len1 + len2, s3);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5263 result[len1 + len2 + len3] = '\0';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5265 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5266 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5268 /* 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
5269 guess the buffer size in advance. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5270 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5271 etags_getcwd ()
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5272 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5273 #ifdef HAVE_GETCWD
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5274 int bufsize = 200;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5275 char *path = xnew (bufsize, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5276
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5277 while (getcwd (path, bufsize) == NULL)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5278 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5279 if (errno != ERANGE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5280 pfatal ("getcwd");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5281 bufsize *= 2;
142
1856695b1fa9 Import from CVS: tag r20-2b5
cvs
parents: 134
diff changeset
5282 free (path);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5283 path = xnew (bufsize, char);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5284 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5285
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5286 canonicalize_filename (path);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5287 return path;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5288
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5289 #else /* not HAVE_GETCWD */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5290 #ifdef MSDOS
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5291 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5292
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5293 getwd (path);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5294
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5295 for (p = path; *p != '\0'; p++)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5296 if (*p == '\\')
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5297 *p = '/';
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5298 else
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5299 *p = lowcase (*p);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5300
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5301 return strdup (path);
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5302 #else /* not MSDOS */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5303 linebuffer path;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5304 FILE *pipe;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5305
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5306 initbuffer (&path);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5307 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5308 if (pipe == NULL || readline_internal (&path, pipe) == 0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5309 pfatal ("pwd");
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5310 pclose (pipe);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5312 return path.buffer;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5313 #endif /* not MSDOS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5314 #endif /* not HAVE_GETCWD */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5315 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5316
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5317 /* Return a newly allocated string containing the file name of FILE
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5318 relative to the absolute directory DIR (which should end with a slash). */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5319 static char *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5320 relative_filename (file, dir)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5321 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5322 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5323 char *fp, *dp, *afn, *res;
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5324 int i;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5325
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5326 /* Find the common root of file and dir (with a trailing slash). */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5327 afn = absolute_filename (file, cwd);
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5328 fp = afn;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5329 dp = dir;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5330 while (*fp++ == *dp++)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5331 continue;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5332 fp--, dp--; /* back to the first differing char */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5333 #ifdef DOS_NT
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5334 if (fp == afn && afn[0] != '/') /* cannot build a relative name */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5335 return afn;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5336 #endif
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5337 do /* look at the equal chars until '/' */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5338 fp--, dp--;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5339 while (*fp != '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5340
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5341 /* Build a sequence of "../" strings for the resulting relative file name. */
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5342 i = 0;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5343 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5344 i += 1;
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5345 res = xnew (3*i + strlen (fp + 1) + 1, char);
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5346 res[0] = '\0';
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5347 while (i-- > 0)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5348 strcat (res, "../");
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5349
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5350 /* 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
5351 strcat (res, fp + 1);
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5352 free (afn);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5354 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5355 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5356
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5357 /* Return a newly allocated string containing the absolute file name
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5358 of FILE given DIR (which should end with a slash). */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5359 static char *
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5360 absolute_filename (file, dir)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5361 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5362 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5363 char *slashp, *cp, *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5364
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5365 if (filename_is_absolute (file))
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5366 res = savestr (file);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5367 #ifdef DOS_NT
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5368 /* We don't support non-absolute file names with a drive
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5369 letter, like `d:NAME' (it's too much hassle). */
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5370 else if (file[1] == ':')
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5371 fatal ("%s: relative file names with drive letters not supported", file);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5372 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5373 else
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5374 res = concat (dir, file, "");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5376 /* Delete the "/dirname/.." and "/." substrings. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5377 slashp = etags_strchr (res, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5378 while (slashp != NULL && slashp[0] != '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5379 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5380 if (slashp[1] == '.')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5381 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5382 if (slashp[2] == '.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5383 && (slashp[3] == '/' || slashp[3] == '\0'))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5384 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5385 cp = slashp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5386 do
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5387 cp--;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5388 while (cp >= res && !filename_is_absolute (cp));
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5389 if (cp < res)
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5390 cp = slashp; /* the absolute name begins with "/.." */
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5391 #ifdef DOS_NT
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5392 /* Under MSDOS and NT we get `d:/NAME' as absolute
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5393 file name, so the luser could say `d:/../NAME'.
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5394 We silently treat this as `d:/NAME'. */
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5395 else if (cp[0] != '/')
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5396 cp = slashp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5397 #endif
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5398 strcpy (cp, slashp + 3);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5399 slashp = cp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5400 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5401 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5402 else if (slashp[2] == '/' || slashp[2] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5403 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5404 strcpy (slashp, slashp + 2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5405 continue;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5406 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5407 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5408
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5409 slashp = etags_strchr (slashp + 1, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5410 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5411
134
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5412 if (res[0] == '\0')
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5413 return savestr ("/");
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5414 else
34a5b81f86ba Import from CVS: tag r20-2b1
cvs
parents: 4
diff changeset
5415 return res;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5416 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5418 /* Return a newly allocated string containing the absolute
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5419 file name of dir where FILE resides given DIR (which should
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5420 end with a slash). */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5421 static char *
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5422 absolute_dirname (file, dir)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5423 char *file, *dir;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5424 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5425 char *slashp, *res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5426 char save;
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5427
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5428 canonicalize_filename (file);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5429 slashp = etags_strrchr (file, '/');
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5430 if (slashp == NULL)
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5431 return savestr (dir);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5432 save = slashp[1];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5433 slashp[1] = '\0';
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5434 res = absolute_filename (file, dir);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5435 slashp[1] = save;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5436
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5437 return res;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5438 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5439
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5440 /* Whether the argument string is an absolute file name. The argument
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5441 string must have been canonicalized with canonicalize_filename. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5442 static bool
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5443 filename_is_absolute (fn)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5444 char *fn;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5445 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5446 return (fn[0] == '/'
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5447 #ifdef DOS_NT
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5448 || (isalpha(fn[0]) && fn[1] == ':' && fn[2] == '/')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5449 #endif
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5450 );
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5451 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5452
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5453 /* Translate backslashes into slashes. Works in place. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5454 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5455 canonicalize_filename (fn)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5456 register char *fn;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5457 {
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5458 #ifdef DOS_NT
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5459 /* Canonicalize drive letter case. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5460 if (islower (fn[0]))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5461 fn[0] = toupper (fn[0]);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5462 /* Convert backslashes to slashes. */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5463 for (; *fn != '\0'; fn++)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5464 if (*fn == '\\')
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5465 *fn = '/';
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5466 #else
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5467 /* No action. */
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 282
diff changeset
5468 fn = NULL; /* shut up the compiler */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5469 #endif
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5470 }
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5471
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5472 /* Increase the size of a linebuffer. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5473 static void
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5474 grow_linebuffer (lbp, toksize)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5475 linebuffer *lbp;
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5476 int toksize;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5477 {
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5478 while (lbp->size < toksize)
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5479 lbp->size *= 2;
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 175
diff changeset
5480 lbp->buffer = xrnew (lbp->buffer, lbp->size, char);
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5481 }
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5482
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5483 /* Like malloc but get fatal error if memory is exhausted. */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5484 static long *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5485 xmalloc (size)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5486 unsigned int size;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5487 {
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5488 long *result = (long *) malloc (size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5489 if (result == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5490 fatal ("virtual memory exhausted", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5491 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5492 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5493
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 371
diff changeset
5494 static long *
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5495 xrealloc (ptr, size)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5496 char *ptr;
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5497 unsigned int size;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5498 {
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5499 long *result = (long *) realloc (ptr, size);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5500 if (result == NULL)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 2
diff changeset
5501 fatal ("virtual memory exhausted", (char *)NULL);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5502 return result;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5503 }