annotate lib-src/etags.c @ 709:1df7a5cfb04a

[xemacs-hg @ 2001-12-20 07:58:18 by yoshiki] Sync etags. <87g0675yes.fsf@u.sanpo.t.u-tokyo.ac.jp>
author yoshiki
date Thu, 20 Dec 2001 07:58:23 +0000
parents 0493e9f3c27f
children add5a821a048
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1 /* Tags file maker to go with GNU Emacs -*- coding: latin-1 -*-
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2 Copyright (C) 1984, 87, 88, 89, 93, 94, 95, 98, 99, 2000, 2001
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 Free Software Foundation, Inc. and Ken Arnold
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is not considered part of GNU Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10 (at your option) any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 GNU General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 along with this program; if not, write to the Free Software Foundation,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 * Authors:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 * Ctags originally by Ken Arnold.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 * Fortran added by Jim Kleckner.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 * Ed Pelegri-Llopart added C typedefs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 * Gnu Emacs TAGS format and modifications by RMS?
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
27 * 1989 Sam Kendall added C++.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
28 * 1993 Francesco Potort́ reorganised C and C++ based on work by Joe Wells.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
29 * 1994 Regexp tags by Tom Tromey.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
30 * 2001 Nested classes by Francesco Potort́ based on work by Mykola Dzyuba.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 *
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
32 * Francesco Potort́ <pot@gnu.org> has maintained it since 1993.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
35 char pot_etags_version[] = "@(#) pot revision number is 14.28";
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 #define TRUE 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 #define FALSE 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
40 #ifdef DEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
41 # undef DEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
42 # define DEBUG TRUE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
43 #else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
44 # define DEBUG FALSE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
45 # define NDEBUG /* disable assert */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 #ifdef HAVE_CONFIG_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 # include <config.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50 /* On some systems, Emacs defines static as nothing for the sake
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 of unexec. We don't want that here since we don't use unexec. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 # undef static
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 # define ETAGS_REGEXPS /* use the regexp features */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 # define LONG_OPTIONS /* accept long options */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
55 # ifndef PTR
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
56 # define PTR void *
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
57 # endif
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
58 #else
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
59 # if defined(__STDC__) && (__STDC__ || defined(__SUNPRO_C))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
60 # define __P(args) args /* use prototypes */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
61 # define PTR void * /* for generic pointers */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
62 # else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
63 # define __P(args) () /* no prototypes */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
64 # define const /* remove const for old compilers' sake */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
65 # define PTR long * /* don't use void* */
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
66 # endif
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
67 #endif /* !HAVE_CONFIG_H */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68
432
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
69 #ifndef _GNU_SOURCE
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
70 # define _GNU_SOURCE 1 /* enables some compiler checks on GNU */
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
71 #endif
3a7e78e1142d Import from CVS: tag r21-2-24
cvs
parents: 428
diff changeset
72
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
73 /* WIN32_NATIVE is for Xemacs.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
74 MSDOS, WINDOWSNT, DOS_NT are for Emacs. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
75 #ifdef WIN32_NATIVE
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
76 # undef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
77 # undef WINDOWSNT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
78 # define WINDOWSNT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
79 #endif /* WIN32_NATIVE */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
80
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
81 #ifdef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
82 # undef MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
83 # define MSDOS TRUE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
84 # include <fcntl.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
85 # include <sys/param.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
86 # include <io.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
87 # ifndef HAVE_CONFIG_H
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
88 # define DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
89 # include <sys/config.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
90 # endif
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
91 #else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
92 # define MSDOS FALSE
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
93 #endif /* MSDOS */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
94
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
95 #ifdef WINDOWSNT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 # include <stdlib.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 # include <fcntl.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 # include <string.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
99 # include <direct.h>
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 # include <io.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 # define MAXPATHLEN _MAX_PATH
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
102 # undef HAVE_NTGUI
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
103 # undef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
104 # define DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 # ifndef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 # define HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 # endif /* undef HAVE_GETCWD */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
108 #else /* !WINDOWSNT */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
109 # ifdef STDC_HEADERS
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
110 # include <stdlib.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
111 # include <string.h>
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
112 # else
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
113 extern char *getenv ();
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
114 # endif
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
115 #endif /* !WINDOWSNT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 #ifdef HAVE_UNISTD_H
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 # include <unistd.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 #else
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
120 # if defined (HAVE_GETCWD) && !defined (WINDOWSNT)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
121 extern char *getcwd (char *buf, size_t size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122 # endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 #endif /* HAVE_UNISTD_H */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 #include <stdio.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 #include <ctype.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 #include <errno.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
128 #ifndef errno
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
129 extern int errno;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
130 #endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 #include <sys/types.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 #include <sys/stat.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
134 #include <assert.h>
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
135 #ifdef NDEBUG
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
136 # undef assert /* some systems have a buggy assert.h */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
137 # define assert(x) ((void) 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
138 #endif
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
139
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 #if !defined (S_ISREG) && defined (S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 # define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 # include <getopt.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 # define getopt_long(argc,argv,optstr,lopts,lind) getopt (argc, argv, optstr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 extern char *optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 extern int optind, opterr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 #ifdef ETAGS_REGEXPS
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
153 # ifndef HAVE_CONFIG_H /* this is a standalone compilation */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
154 # ifdef __CYGWIN__ /* compiling on Cygwin */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
155 !!! NOTICE !!!
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
156 the regex.h distributed with Cygwin is not compatible with etags, alas!
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
157 If you want regular expression support, you should delete this notice and
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
158 arrange to use the GNU regex.h and regex.c.
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
159 # endif
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
160 # endif
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 # include <regex.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 /* Define CTAGS to make the program "ctags" compatible with the usual one.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 Leave it undefined to make the program "etags", which makes emacs-style
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 tag tables and tags typedefs, #defines and struct/union/enum by default. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 #ifdef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 # undef CTAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 # define CTAGS TRUE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 # define CTAGS FALSE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 /* Exit codes for success and failure. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 # define GOOD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 # define BAD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 # define GOOD 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 # define BAD 1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
183 #define streq(s,t) (assert((s)!=NULL || (t)!=NULL), !strcmp (s, t))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
184 #define strneq(s,t,n) (assert((s)!=NULL || (t)!=NULL), !strncmp (s, t, n))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 #define CHARS 256 /* 2^sizeof(char) */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
187 #define CHAR(x) ((unsigned int)(x) & (CHARS - 1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 #define iswhite(c) (_wht[CHAR(c)]) /* c is white */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 #define notinname(c) (_nin[CHAR(c)]) /* c is not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 #define begtoken(c) (_btk[CHAR(c)]) /* c can start token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 #define intoken(c) (_itk[CHAR(c)]) /* c can be in token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 #define endtoken(c) (_etk[CHAR(c)]) /* c ends tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
194 #define ISALNUM(c) isalnum (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
195 #define ISALPHA(c) isalpha (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
196 #define ISDIGIT(c) isdigit (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
197 #define ISLOWER(c) islower (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
198
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
199 #define lowcase(c) tolower (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
200 #define upcase(c) toupper (CHAR(c))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
201
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 * xnew, xrnew -- allocate, reallocate storage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 * SYNOPSIS: Type *xnew (int n, Type);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
207 * void xrnew (OldPointer, int n, Type);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
209 #if DEBUG
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 # include "chkmalloc.h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 # define xnew(n,Type) ((Type *) trace_malloc (__FILE__, __LINE__, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (n) * sizeof (Type)))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
213 # define xrnew(op,n,Type) ((op) = (Type *) trace_realloc (__FILE__, __LINE__, \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
214 (char *) (op), (n) * sizeof (Type)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 # define xnew(n,Type) ((Type *) xmalloc ((n) * sizeof (Type)))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
217 # define xrnew(op,n,Type) ((op) = (Type *) xrealloc ( \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
218 (char *) (op), (n) * sizeof (Type)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
221 #define bool int
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
222
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
223 typedef void Lang_function __P((FILE *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 char *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 char *command; /* Takes one arg and decompresses to stdout */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 } compressor;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 Lang_function *function;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
235 char **filenames;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 char **suffixes;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 char **interpreters;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 } language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 typedef struct node_st
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 { /* sorting structure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 char *name; /* function or type name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 char *file; /* file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244 bool is_func; /* use pattern or line no */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 bool been_warned; /* set if noticed dup */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 int lno; /* line number tag is on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 long cno; /* character number line starts on */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 char *pat; /* search pattern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 struct node_st *left, *right; /* left and right sons */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250 } node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 * A `linebuffer' is a structure which holds a line of text.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 * `readline_internal' reads a line from a stream into a linebuffer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 * and works regardless of the length of the line.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 * SIZE is the size of BUFFER, LEN is the length of the string in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 * BUFFER after readline reads it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 long size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 char *buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 } linebuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 /* Many compilers barf on this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 Lang_function Ada_funcs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 so let's write it this way */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
269 static void Ada_funcs __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
270 static void Asm_labels __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
271 static void C_entries __P((int c_ext, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
272 static void default_C_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
273 static void plain_C_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
274 static void Cjava_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
275 static void Cobol_paragraphs __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
276 static void Cplusplus_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
277 static void Cstar_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
278 static void Erlang_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
279 static void Fortran_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
280 static void Yacc_entries __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
281 static void Lisp_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
282 static void Makefile_targets __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
283 static void Pascal_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
284 static void Perl_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
285 static void PHP_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
286 static void Postscript_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
287 static void Prolog_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
288 static void Python_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
289 static void Scheme_functions __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
290 static void TeX_commands __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
291 static void Texinfo_nodes __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
292 static void just_read_file __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
293
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
294 static void print_language_names __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
295 static void print_version __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
296 static void print_help __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
297 int main __P((int, char **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
298 static int number_len __P((long));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
299
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
300 static compressor *get_compressor_from_suffix __P((char *, char **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
301 static language *get_language_from_langname __P((const char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
302 static language *get_language_from_interpreter __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
303 static language *get_language_from_filename __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
304 static int total_size_of_entries __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
305 static long readline __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
306 static long readline_internal __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
307 static void get_tag __P((char *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309 #ifdef ETAGS_REGEXPS
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
310 static void analyse_regex __P((char *, bool));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
311 static void add_regex __P((char *, bool, language *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
312 static void free_patterns __P((void));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 #endif /* ETAGS_REGEXPS */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
314 static void error __P((const char *, const char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
315 static void suggest_asking_for_help __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
316 void fatal __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
317 static void pfatal __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
318 static void add_node __P((node *, node **));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
319
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
320 static void init __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
321 static void initbuffer __P((linebuffer *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
322 static void find_entries __P((char *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
323 static void free_tree __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
324 static void pfnote __P((char *, bool, char *, int, int, long));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
325 static void new_pfnote __P((char *, int, bool, char *, int, int, long));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
326 static void process_file __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
327 static void put_entries __P((node *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
328 static void takeprec __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
329
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
330 static char *concat __P((char *, char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
331 static char *skip_spaces __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
332 static char *skip_non_spaces __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
333 static char *savenstr __P((char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
334 static char *savestr __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
335 static char *etags_strchr __P((const char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
336 static char *etags_strrchr __P((const char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
337 static char *etags_getcwd __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
338 static char *relative_filename __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
339 static char *absolute_filename __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
340 static char *absolute_dirname __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
341 static bool filename_is_absolute __P((char *f));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
342 static void canonicalize_filename __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
343 static void linebuffer_setlen __P((linebuffer *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
344 PTR xmalloc __P((unsigned int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
345 PTR xrealloc __P((char *, unsigned int));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 char searchar = '/'; /* use /.../ searches */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350 char *tagfile; /* output file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 char *progname; /* name this program was invoked with */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 char *cwd; /* current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 char *tagfiledir; /* directory of tagfile */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 FILE *tagf; /* ioptr for tags file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 char *curfile; /* current input file name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 language *curlang; /* current language */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 int lineno; /* line number of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 long charno; /* current character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 long linecharno; /* charno of start of current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 char *dbp; /* pointer to start of current tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 node *head; /* the head of the binary tree of tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 linebuffer lb; /* the current line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 /* boolean "functions" (see init) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 bool _wht[CHARS], _nin[CHARS], _itk[CHARS], _btk[CHARS], _etk[CHARS];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 char
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 /* white chars */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
372 *white = " \f\t\n\r\v",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 /* not in a name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 *nonam = " \f\t\n\r(=,[;",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 /* token ending chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 *endtk = " \t\n\r\"'#()[]{}=-+%*/&|^~!<>;,.:?",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 /* token starting chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 *begtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$~@",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 /* valid in-token chars */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 *midtk = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz$0123456789";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 bool append_to_tagfile; /* -a: append to tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 /* The following four default to TRUE for etags, but to FALSE for ctags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 bool typedefs; /* -t: create tags for C and Ada typedefs */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
385 bool typedefs_or_cplusplus; /* -T: create tags for C typedefs, level */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 /* 0 struct/enum/union decls, and C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 /* member functions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 bool constantypedefs; /* -d: create tags for C #define, enum */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 /* constants and variables. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 /* -D: opposite of -d. Default under ctags. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 bool declarations; /* --declarations: tag them and extern in C&Co*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 bool globals; /* create tags for global variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 bool members; /* create tags for C member variables */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 bool update; /* -u: update tags */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395 bool vgrind_style; /* -v: create vgrind style index output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 bool no_warnings; /* -w: suppress warnings */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 bool cxref_style; /* -x: create cxref style output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 bool cplusplus; /* .[hc] means C++, not C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 bool noindentypedefs; /* -I: ignore indentation in C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 bool packages_only; /* --packages-only: in Ada, only tag packages*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 struct option longopts[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405 { "packages-only", no_argument, &packages_only, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 { "append", no_argument, NULL, 'a' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 { "backward-search", no_argument, NULL, 'B' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 { "c++", no_argument, NULL, 'C' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 { "cxref", no_argument, NULL, 'x' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 { "defines", no_argument, NULL, 'd' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 { "declarations", no_argument, &declarations, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412 { "no-defines", no_argument, NULL, 'D' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 { "globals", no_argument, &globals, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 { "no-globals", no_argument, &globals, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 { "help", no_argument, NULL, 'h' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 { "help", no_argument, NULL, 'H' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 { "ignore-indentation", no_argument, NULL, 'I' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 { "include", required_argument, NULL, 'i' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 { "language", required_argument, NULL, 'l' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 { "members", no_argument, &members, TRUE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 { "no-members", no_argument, &members, FALSE },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 { "no-warn", no_argument, NULL, 'w' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 { "output", required_argument, NULL, 'o' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 { "regex", required_argument, NULL, 'r' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 { "no-regex", no_argument, NULL, 'R' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427 { "ignore-case-regex", required_argument, NULL, 'c' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 { "typedefs", no_argument, NULL, 't' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 { "typedefs-and-c++", no_argument, NULL, 'T' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 { "update", no_argument, NULL, 'u' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 { "version", no_argument, NULL, 'V' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 { "vgrind", no_argument, NULL, 'v' },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 { NULL }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 /* Structure defining a regular expression. Elements are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440 the compiled pattern, and the name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 typedef struct pattern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 struct pattern *p_next;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
444 language *lang;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 char *regex;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
446 struct re_pattern_buffer *pat;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 struct re_registers regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448 char *name_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 bool error_signaled;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 } pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 /* List of all regexps. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 pattern *p_head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 /* How many characters in the character set. (From regex.c.) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 #define CHAR_SET_SIZE 256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457 /* Translation table for case-insensitive matching. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 char lc_trans[CHAR_SET_SIZE];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 compressor compressors[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 { "z", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 { "Z", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 { "gz", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 { "GZ", "gzip -d -c"},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 { "bz2", "bzip2 -d -c" },
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468 { NULL }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 * Language stuff.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 /* Non-NULL if language fixed. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 language *forced_lang = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 /* Ada code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 char *Ada_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 { "ads", "adb", "ada", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 /* Assembly code */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 char *Asm_suffixes [] = { "a", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 "asm", /* Microcontroller assembly */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485 "def", /* BSO/Tasking definition includes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 "inc", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 "ins", /* Microcontroller include files */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 "s", "sa", /* Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 "S", /* cpp-processed Unix assembler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490 "src", /* BSO/Tasking C compiler output */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494 /* Note that .c and .h can be considered C++, if the --c++ flag was
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
495 given, or if the `class' keyowrd is met inside the file.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
496 That is why default_C_entries is called for these. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 char *default_C_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 { "c", "h", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 char *Cplusplus_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
501 { "C", "c++", "cc", "cpp", "cxx", "H", "h++", "hh", "hpp", "hxx",
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 "M", /* Objective C++ */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 "pdb", /* Postscript with C syntax */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 char *Cjava_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 { "java", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 char *Cobol_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 { "COB", "cob", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 char *Cstar_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 { "cs", "hs", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 char *Erlang_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 { "erl", "hrl", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 char *Fortran_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 { "F", "f", "f90", "for", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 char *Lisp_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
522 { "cl", "clisp", "el", "l", "lisp", "LSP", "lsp", "ml", NULL };
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
523
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
524 char *Makefile_filenames [] =
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
525 { "Makefile", "makefile", "GNUMakefile", "Makefile.in", "Makefile.am", NULL};
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 char *Pascal_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 { "p", "pas", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 char *Perl_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 { "pl", "pm", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 char *Perl_interpreters [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 { "perl", "@PERL@", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
535 char *PHP_suffixes [] =
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
536 { "php", "php3", "php4", NULL };
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
537
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 char *plain_C_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
539 { "lm", /* Objective lex file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 "m", /* Objective C file */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
541 "pc", /* Pro*C file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 char *Postscript_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 { "ps", "psw", NULL }; /* .psw is for PSWrap */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 char *Prolog_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 { "prolog", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 char *Python_suffixes [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 { "py", NULL };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 /* Can't do the `SCM' or `scm' prefix with a version number. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 char *Scheme_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
555 { "oak", "sch", "scheme", "SCM", "scm", "SM", "sm", "ss", "t", NULL };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 char *TeX_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
558 { "bib", "clo", "cls", "ltx", "sty", "TeX", "tex", NULL };
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
559
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
560 char *Texinfo_suffixes [] =
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
561 { "texi", "texinfo", "txi", NULL };
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 char *Yacc_suffixes [] =
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
564 { "y", "y++", "ym", "yxx", "yy", NULL }; /* .ym is Objective yacc file */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 * Table of languages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 * It is ok for a given function to be listed under more than one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 * name. I just didn't.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 language lang_names [] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
575 { "ada", Ada_funcs, NULL, Ada_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
576 { "asm", Asm_labels, NULL, Asm_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
577 { "c", default_C_entries, NULL, default_C_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
578 { "c++", Cplusplus_entries, NULL, Cplusplus_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
579 { "c*", Cstar_entries, NULL, Cstar_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
580 { "cobol", Cobol_paragraphs, NULL, Cobol_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
581 { "erlang", Erlang_functions, NULL, Erlang_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
582 { "fortran", Fortran_functions, NULL, Fortran_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
583 { "java", Cjava_entries, NULL, Cjava_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
584 { "lisp", Lisp_functions, NULL, Lisp_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
585 { "makefile", Makefile_targets, Makefile_filenames, NULL, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
586 { "pascal", Pascal_functions, NULL, Pascal_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
587 { "perl", Perl_functions, NULL, Perl_suffixes, Perl_interpreters },
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
588 { "php", PHP_functions, NULL, PHP_suffixes, NULL },
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
589 { "postscript", Postscript_functions, NULL, Postscript_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
590 { "proc", plain_C_entries, NULL, plain_C_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
591 { "prolog", Prolog_functions, NULL, Prolog_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
592 { "python", Python_functions, NULL, Python_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
593 { "scheme", Scheme_functions, NULL, Scheme_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
594 { "tex", TeX_commands, NULL, TeX_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
595 { "texinfo", Texinfo_nodes, NULL, Texinfo_suffixes, NULL },
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
596 { "yacc", Yacc_entries, NULL, Yacc_suffixes, NULL },
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 { "auto", NULL }, /* default guessing scheme */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 { "none", just_read_file }, /* regexp matching only */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 { NULL, NULL } /* end of list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 };
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
601
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 print_language_names ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 language *lang;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
607 char **name, **ext;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 puts ("\nThese are the currently supported languages, along with the\n\
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
610 default file names and dot suffixes:");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
613 printf (" %-*s", 10, lang->name);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
614 if (lang->filenames != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
615 for (name = lang->filenames; *name != NULL; name++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
616 printf (" %s", *name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619 printf (" .%s", *ext);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622 puts ("Where `auto' means use default language for files based on file\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 name suffix, and `none' means only do regexp processing on files.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 If no language is specified and no matching suffix is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625 the first line of the file is read for a sharp-bang (#!) sequence\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 followed by the name of an interpreter. If no such sequence is found,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 Fortran is tried first; if no tags are found, C is tried next.\n\
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
628 When parsing any C file, a \"class\" keyword switches to C++.\n\
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 Compressed files are supported using gzip and bzip2.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
632 #ifndef EMACS_NAME
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 # define EMACS_NAME "GNU Emacs"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635 #ifndef VERSION
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
636 # define VERSION "21"
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 print_version ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
641 printf ("%s (%s %s)\n", (CTAGS) ? "ctags" : "etags", EMACS_NAME, VERSION);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 puts ("Copyright (C) 1999 Free Software Foundation, Inc. and Ken Arnold");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 puts ("This program is distributed under the same terms as Emacs");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 print_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 printf ("Usage: %s [options] [[regex-option ...] file-name] ...\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 \n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 These are the options accepted by %s.\n", progname, progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 puts ("You may use unambiguous abbreviations for the long option names.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 puts ("Long option names do not work with this executable, as it is not\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 linked with GNU getopt.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 puts ("A - as file name means read names from stdin (one per line).");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 printf (" Absolute names are stored in the output file as they are.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 Relative ones are stored relative to the output file's directory.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 puts ("\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 puts ("-a, --append\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 Append tag entries to existing tags file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669 puts ("--packages-only\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 For Ada files, only generate tags for packages .");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 puts ("-B, --backward-search\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 Write the search commands for the tag entries using '?', the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 backward-search command instead of '/', the forward-search command.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
677 /* This option is mostly obsolete, because etags can now automatically
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
678 detect C++. Retained for backward compatibility and for debugging and
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
679 experimentation. In principle, we could want to tag as C++ even
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
680 before any "class" keyword.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 puts ("-C, --c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 Treat files whose name suffix defaults to C language as C++ files.");
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
683 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 puts ("--declarations\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 In C and derived languages, create tags for function declarations,");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 puts ("\tand create tags for extern variables if --globals is used.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 puts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 ("\tand create tags for extern variables unless --no-globals is used.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 puts ("-d, --defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 Create tag entries for C #define constants and enum constants, too.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 puts ("-D, --no-defines\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 Don't create tag entries for C #define constants and enum constants.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 puts ("-i FILE, --include=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 Include a note in tag file indicating that, when searching for\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 a tag, one should also consult the tags file FILE after\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 checking the current file.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 puts ("-l LANG, --language=LANG\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 Force the following files to be considered as written in the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 named language up to the next --language=LANG option.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 puts ("--globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 Create tag entries for global variables in some languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 puts ("--no-globals\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 Do not create tag entries for global variables in some\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 languages. This makes the tags file smaller.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 puts ("--members\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 Create tag entries for member variables in C and derived languages.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 puts ("-r /REGEXP/, --regex=/REGEXP/ or --regex=@regexfile\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 Make a tag for each line matching pattern REGEXP in the following\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 files. {LANGUAGE}/REGEXP/ uses REGEXP for LANGUAGE files only.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 regexfile is a file containing one REGEXP per line.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 REGEXP is anchored (as if preceded by ^).\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 The form /REGEXP/NAME/ creates a named tag.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 For example Tcl named tags can be created with:\n\
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
730 --regex=\"/proc[ \\t]+\\([^ \\t]+\\)/\\1/.\"");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 puts ("-c /REGEXP/, --ignore-case-regex=/REGEXP/ or --ignore-case-regex=@regexfile\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 Like -r, --regex but ignore case when matching expressions.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 puts ("-R, --no-regex\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 Don't create tags from regexps for the following files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 puts ("-o FILE, --output=FILE\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 Write the tags to FILE.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 puts ("-I, --ignore-indentation\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 Don't rely on indentation quite as much as normal. Currently,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 this means not to assume that a closing brace in the first\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 column is the final brace of a function or structure\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 definition in C and C++.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 if (CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 puts ("-t, --typedefs\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 Generate tag entries for C and Ada typedefs.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 puts ("-T, --typedefs-and-c++\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 Generate tag entries for C typedefs, C struct/enum/union tags,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 and C++ member functions.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 puts ("-u, --update\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 Update the tag entries for the given files, leaving tag\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 entries for other files in place. Currently, this is\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 implemented by deleting the existing entries for the given\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 files and then rewriting the new entries at the end of the\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 tags file. It is often faster to simply rebuild the entire\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 tag file than to use this.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 puts ("-v, --vgrind\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 Generates an index of items intended for human consumption,\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 similar to the output of vgrind. The index is sorted, and\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 gives the page number of each item.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 puts ("-w, --no-warn\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 Suppress warning messages about entries defined in multiple\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 files.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 puts ("-x, --cxref\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 Like --vgrind, but in the style of cxref, rather than vgrind.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 The output uses line numbers instead of page numbers, but\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 beyond that the differences are cosmetic; try both to see\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 which you like.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772 puts ("-V, --version\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 Print the version of the program.\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 -h, --help\n\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 Print this help message.");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 print_language_names ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 puts ("");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 puts ("Report bugs to bug-gnu-emacs@gnu.org");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 enum argument_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 at_language,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 at_regexp,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 at_filename,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 at_icregexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 /* This structure helps us allow mixing of --lang and file names. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 typedef struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 enum argument_type arg_type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 char *what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 language *lang; /* language of the regexp */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 } argument;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 #ifdef VMS /* VMS specific functions */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 #define EOS '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 /* This is a BUG! ANY arbitrary limit is a BUG!
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 Won't someone please fix this? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 #define MAX_FILE_SPEC_LEN 255
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 typedef struct {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 short curlen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 char body[MAX_FILE_SPEC_LEN + 1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 } vspec;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 v1.05 nmm 26-Jun-86 fn_exp - expand specification of list of file names
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 returning in each successive call the next file name matching the input
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817 spec. The function expects that each in_spec passed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 to it will be processed to completion; in particular, up to and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 including the call following that in which the last matching name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 is returned, the function ignores the value of in_spec, and will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821 only start processing a new spec with the following call.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 If an error occurs, on return out_spec contains the value
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 of in_spec when the error occurred.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 With each successive file name returned in out_spec, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 function's return value is one. When there are no more matching
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 names the function returns zero. If on the first call no file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828 matches in_spec, or there is any other error, -1 is returned.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831 #include <rmsdef.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 #include <descrip.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 #define OUTSIZE MAX_FILE_SPEC_LEN
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
834 static short
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835 fn_exp (out, in)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 vspec *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 char *in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 static long context = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 static struct dsc$descriptor_s o;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 static struct dsc$descriptor_s i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842 static bool pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 long status;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 short retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 if (pass1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 pass1 = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 o.dsc$a_pointer = (char *) out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 o.dsc$w_length = (short)OUTSIZE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851 i.dsc$a_pointer = in;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 i.dsc$w_length = (short)strlen(in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 i.dsc$b_dtype = DSC$K_DTYPE_T;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 i.dsc$b_class = DSC$K_CLASS_S;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 o.dsc$b_dtype = DSC$K_DTYPE_VT;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856 o.dsc$b_class = DSC$K_CLASS_VS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858 if ((status = lib$find_file(&i, &o, &context, 0, 0)) == RMS$_NORMAL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 out->body[out->curlen] = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 return 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 else if (status == RMS$_NMF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 retval = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 strcpy(out->body, in);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 retval = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 lib$find_file_end(&context);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 pass1 = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 return retval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 v1.01 nmm 19-Aug-85 gfnames - return in successive calls the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 name of each file specified by the provided arg expanding wildcards.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
879 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 gfnames (arg, p_error)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 char *arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 bool *p_error;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 static vspec filename = {MAX_FILE_SPEC_LEN, "\0"};
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 switch (fn_exp (&filename, arg))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 *p_error = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 *p_error = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 return filename.body;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 #ifndef OLD /* Newer versions of VMS do provide `system'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 system (cmd)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 char *cmd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 error ("%s", "system() function not implemented under VMS");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 #define VERSION_DELIM ';'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 char *massage_name (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 char *start = s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914 for ( ; *s; s++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 if (*s == VERSION_DELIM)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 *s = EOS;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921 *s = lowcase (*s);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
922 return start;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 #endif /* VMS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927 int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 main (argc, argv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 int argc;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930 char *argv[];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 unsigned int nincluded_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 char **included_files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 char *this_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 argument *argbuffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937 int current_arg, file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 linebuffer filename_lb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
939 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 bool got_err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
941 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
943 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 _fmode = O_BINARY; /* all of files are treated as binary files */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
945 #endif /* DOS_NT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 progname = argv[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 nincluded_files = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 included_files = xnew (argc, char *);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 current_arg = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 file_count = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 /* Allocate enough no matter what happens. Overkill, but each one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 is small. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 argbuffer = xnew (argc, argument);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 /* Set syntax for regular expression routines. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
959 re_set_syntax (RE_SYNTAX_EMACS | RE_INTERVALS);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 /* Translation table for case-insensitive search. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 for (i = 0; i < CHAR_SET_SIZE; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 lc_trans[i] = lowcase (i);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 * If etags, always find typedefs and structure tags. Why not?
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
967 * Also default to find macro constants, enum constants and
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 * global variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
972 typedefs = typedefs_or_cplusplus = constantypedefs = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 globals = TRUE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
974 declarations = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975 members = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 int opt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981 char *optstring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
982
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 optstring = "-aCdDf:Il:o:r:c:RStTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986 optstring = "-aCdDf:Il:o:StTi:BuvxwVhH";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 #ifndef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 optstring = optstring + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 #endif /* LONG_OPTIONS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 opt = getopt_long (argc, argv, optstring, longopts, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 if (opt == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 switch (opt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 case 0:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 /* If getopt returns 0, then it has already processed a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1001 long-named option. We should do nothing. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005 /* This means that a file name has been seen. Record it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1006 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1012 /* Common options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1013 case 'a': append_to_tagfile = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 case 'C': cplusplus = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015 case 'd': constantypedefs = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 case 'D': constantypedefs = FALSE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 case 'f': /* for compatibility with old makefiles */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 case 'o':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1019 if (tagfile)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 error ("-o option may only be given once.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 tagfile = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 case 'I':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 case 'S': /* for backward compatibility */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 noindentypedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1032 language *lang = get_language_from_langname (optarg);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 if (lang != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035 argbuffer[current_arg].lang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 argbuffer[current_arg].arg_type = at_language;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 case 'R':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048 argbuffer[current_arg].arg_type = at_regexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 argbuffer[current_arg].what = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1050 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 argbuffer[current_arg].arg_type = at_icregexp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054 argbuffer[current_arg].what = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058 case 'V':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 print_version ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061 case 'h':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 case 'H':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063 print_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1066 typedefs = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1067 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1068 case 'T':
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1069 typedefs = typedefs_or_cplusplus = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1070 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1071 #if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1072 /* Etags options */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1073 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1074 included_files[nincluded_files++] = optarg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1075 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1076 #else /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1077 /* Ctags options. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1078 case 'B': searchar = '?'; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1079 case 'u': update = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1080 case 'v': vgrind_style = TRUE; /*FALLTHRU*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1081 case 'x': cxref_style = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1082 case 'w': no_warnings = TRUE; break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1083 #endif /* CTAGS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1084 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1085 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1086 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1087 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1088
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1089 for (; optind < argc; ++optind)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1090 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1091 argbuffer[current_arg].arg_type = at_filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1092 argbuffer[current_arg].what = argv[optind];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1093 ++current_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1094 ++file_count;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1095 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1096
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1097 if (nincluded_files == 0 && file_count == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1098 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1099 error ("no input files specified.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1100 suggest_asking_for_help ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1101 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1102
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1103 if (tagfile == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1104 tagfile = CTAGS ? "tags" : "TAGS";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1105 cwd = etags_getcwd (); /* the current working directory */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1106 if (cwd[strlen (cwd) - 1] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1107 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1108 char *oldcwd = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1109 cwd = concat (oldcwd, "/", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1110 free (oldcwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1111 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1112 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1113 tagfiledir = cwd;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1114 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1115 tagfiledir = absolute_dirname (tagfile, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1116
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1117 init (); /* set up boolean "functions" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1118
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1119 initbuffer (&lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1120 initbuffer (&filename_lb);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1121
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1122 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1123 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1124 if (streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1125 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1126 tagf = stdout;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1127 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1128 /* Switch redirected `stdout' to binary mode (setting `_fmode'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1129 doesn't take effect until after `stdout' is already open). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1130 if (!isatty (fileno (stdout)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1131 setmode (fileno (stdout), O_BINARY);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1132 #endif /* DOS_NT */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1133 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1134 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1135 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1136 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1137 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1138 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1140 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1141 * Loop through files finding functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1142 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1143 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1144 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1145 switch (argbuffer[i].arg_type)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1147 case at_language:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1148 forced_lang = argbuffer[i].lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1149 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1150 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1151 case at_regexp:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1152 analyse_regex (argbuffer[i].what, FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1153 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1154 case at_icregexp:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1155 analyse_regex (argbuffer[i].what, TRUE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1156 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1157 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1158 case at_filename:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1159 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1160 while ((this_file = gfnames (argbuffer[i].what, &got_err)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1161 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1162 if (got_err)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1163 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1164 error ("can't find file %s\n", this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1165 argc--, argv++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1166 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1167 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1168 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1169 this_file = massage_name (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1171 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1172 this_file = argbuffer[i].what;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1173 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1174 /* Input file named "-" means read file names from stdin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1175 (one per line) and use them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1176 if (streq (this_file, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1177 while (readline_internal (&filename_lb, stdin) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1178 process_file (filename_lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1179 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1180 process_file (this_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1181 #ifdef VMS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1182 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1183 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1184 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1185 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1186 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1188 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1189 free_patterns ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1190 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1192 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1193 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1194 while (nincluded_files-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1195 fprintf (tagf, "\f\n%s,include\n", *included_files++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1197 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1198 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1199 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1200
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1201 /* If CTAGS, we are here. process_file did not write the tags yet,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1202 because we want them ordered. Let's do it now. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1203 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1205 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1206 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1207 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1208 exit (GOOD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1209 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1211 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1212 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1213 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1214 for (i = 0; i < current_arg; ++i)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1215 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1216 if (argbuffer[i].arg_type != at_filename)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1217 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1218 sprintf (cmd,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1219 "mv %s OTAGS;fgrep -v '\t%s\t' OTAGS >%s;rm OTAGS",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1220 tagfile, argbuffer[i].what, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1221 if (system (cmd) != GOOD)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1222 fatal ("failed to execute shell command", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1223 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1224 append_to_tagfile = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1225 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1226
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1227 tagf = fopen (tagfile, append_to_tagfile ? "a" : "w");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1228 if (tagf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1229 pfatal (tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1230 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1231 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1232 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1233 fclose (tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1235 if (update)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1236 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1237 char cmd[BUFSIZ];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1238 sprintf (cmd, "sort %s -o %s", tagfile, tagfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1239 exit (system (cmd));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1240 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1241 return GOOD;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1245
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1246 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1247 * Return a compressor given the file name. If EXTPTR is non-zero,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1248 * return a pointer into FILE where the compressor-specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1249 * extension begins. If no compressor is found, NULL is returned
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1250 * and EXTPTR is not significant.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1251 * Idea by Vladimir Alexiev <vladimir@cs.ualberta.ca> (1998)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1252 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1253 static compressor *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1254 get_compressor_from_suffix (file, extptr)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1255 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1256 char **extptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1257 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1258 compressor *compr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1259 char *slash, *suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1260
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1261 /* This relies on FN to be after canonicalize_filename,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1262 so we don't need to consider backslashes on DOS_NT. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1263 slash = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1264 suffix = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1265 if (suffix == NULL || suffix < slash)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1266 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1267 if (extptr != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1268 *extptr = suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1269 suffix += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1270 /* Let those poor souls who live with DOS 8+3 file name limits get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1271 some solace by treating foo.cgz as if it were foo.c.gz, etc.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1272 Only the first do loop is run if not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1273 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1274 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1275 for (compr = compressors; compr->suffix != NULL; compr++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1276 if (streq (compr->suffix, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1277 return compr;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1278 if (!MSDOS)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1279 break; /* do it only once: not really a loop */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1280 if (extptr != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1281 *extptr = ++suffix;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1282 } while (*suffix != '\0');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1283 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1284 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1285
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1288 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1289 * Return a language given the name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1290 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1291 static language *
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1292 get_language_from_langname (name)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1293 const char *name;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1294 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1295 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1296
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1297 if (name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1298 error ("empty language name", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1299 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1300 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1301 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1302 if (streq (name, lang->name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1303 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1304 error ("unknown language \"%s\"", name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1305 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1306
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1307 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1308 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1310
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1311 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1312 * Return a language given the interpreter name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1313 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1314 static language *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1315 get_language_from_interpreter (interpreter)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1316 char *interpreter;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1317 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1318 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1319 char **iname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1321 if (interpreter == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1322 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1323 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1324 if (lang->interpreters != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1325 for (iname = lang->interpreters; *iname != NULL; iname++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1326 if (streq (*iname, interpreter))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1327 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1328
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1329 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1330 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1331
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1332
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1334 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1335 * Return a language given the file name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1336 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1337 static language *
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1338 get_language_from_filename (file)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1339 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1340 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1341 language *lang;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1342 char **name, **ext, *suffix;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1343
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1344 /* Try whole file name first. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1345 for (lang = lang_names; lang->name != NULL; lang++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1346 if (lang->filenames != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1347 for (name = lang->filenames; *name != NULL; name++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1348 if (streq (*name, file))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1349 return lang;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1350
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1351 /* If not found, try suffix after last dot. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1352 suffix = etags_strrchr (file, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1353 if (suffix == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1354 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1355 suffix += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1356 for (lang = lang_names; lang->name != NULL; lang++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1357 if (lang->suffixes != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1358 for (ext = lang->suffixes; *ext != NULL; ext++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1359 if (streq (*ext, suffix))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1360 return lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1361 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1362 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1363
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1366 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1367 * This routine is called on each file argument.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1368 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1369 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1370 process_file (file)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1371 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1372 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1373 struct stat stat_buf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1374 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1375 compressor *compr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1376 char *compressed_name, *uncompressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1377 char *ext, *real_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1379
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1380 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1381 if (streq (file, tagfile) && !streq (tagfile, "-"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1382 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1383 error ("skipping inclusion of %s in self.", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1384 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1385 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1386 if ((compr = get_compressor_from_suffix (file, &ext)) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1387 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1388 compressed_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1389 real_name = uncompressed_name = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1390 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1391 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1392 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1393 real_name = compressed_name = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1394 uncompressed_name = savenstr (file, ext - file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1395 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1396
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1397 /* If the canonicalised uncompressed name has already be dealt with,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1398 skip it silently, else add it to the list. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1399 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1400 typedef struct processed_file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1401 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1402 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1403 struct processed_file *next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1404 } processed_file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1405 static processed_file *pf_head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1406 register processed_file *fnp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1407
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1408 for (fnp = pf_head; fnp != NULL; fnp = fnp->next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1409 if (streq (uncompressed_name, fnp->filename))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1410 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1411 fnp = pf_head;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1412 pf_head = xnew (1, struct processed_file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1413 pf_head->filename = savestr (uncompressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1414 pf_head->next = fnp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1415 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1417 if (stat (real_name, &stat_buf) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1418 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1419 /* Reset real_name and try with a different name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1420 real_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1421 if (compressed_name != NULL) /* try with the given suffix */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1422 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1423 if (stat (uncompressed_name, &stat_buf) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1424 real_name = uncompressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1425 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1426 else /* try all possible suffixes */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1427 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1428 for (compr = compressors; compr->suffix != NULL; compr++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1429 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1430 compressed_name = concat (file, ".", compr->suffix);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1431 if (stat (compressed_name, &stat_buf) != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1432 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1433 if (MSDOS)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1434 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1435 char *suf = compressed_name + strlen (file);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1436 size_t suflen = strlen (compr->suffix) + 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1437 for ( ; suf[1]; suf++, suflen--)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1438 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1439 memmove (suf, suf + 1, suflen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1440 if (stat (compressed_name, &stat_buf) == 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1441 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1442 real_name = compressed_name;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1443 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1444 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1445 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1446 if (real_name != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1447 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1448 } /* MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1449 free (compressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1450 compressed_name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1451 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1452 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1454 real_name = compressed_name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1455 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1456 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1458 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1459 if (real_name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1460 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1461 perror (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1462 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1463 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1464 } /* try with a different name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1465
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1466 if (!S_ISREG (stat_buf.st_mode))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1467 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1468 error ("skipping %s: it is not a regular file.", real_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1469 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1470 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1471 if (real_name == compressed_name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1472 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1473 char *cmd = concat (compr->command, " ", real_name);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1474 inf = (FILE *) popen (cmd, "r");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1475 free (cmd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1476 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1477 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1478 inf = fopen (real_name, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1479 if (inf == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1480 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1481 perror (real_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1482 goto exit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1483 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1484
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1485 find_entries (uncompressed_name, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1486
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1487 if (real_name == compressed_name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1488 pclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1489 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1490 fclose (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1491
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1492 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1493 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1494 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1495
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1496 if (filename_is_absolute (uncompressed_name))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1498 /* file is an absolute file name. Canonicalise it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1499 filename = absolute_filename (uncompressed_name, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1500 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1501 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1502 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1503 /* file is a file name relative to cwd. Make it relative
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1504 to the directory of the tags file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1505 filename = relative_filename (uncompressed_name, tagfiledir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1506 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1507 fprintf (tagf, "\f\n%s,%d\n", filename, total_size_of_entries (head));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1508 free (filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1509 put_entries (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1510 free_tree (head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1511 head = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1512 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1513
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1514 exit:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1515 if (compressed_name) free(compressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1516 if (uncompressed_name) free(uncompressed_name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1517 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1518 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1519
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1520 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1521 * This routine sets up the boolean pseudo-functions which work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1522 * by setting boolean flags dependent upon the corresponding character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1523 * Every char which is NOT in that string is not a white char. Therefore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1524 * all of the array "_wht" is set to FALSE, and then the elements
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1525 * subscripted by the chars in "white" are set to TRUE. Thus "_wht"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1526 * of a char is TRUE if it is the string "white", else FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1527 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1528 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1529 init ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1530 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1531 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1532 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1533
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1534 for (i = 0; i < CHARS; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1535 iswhite(i) = notinname(i) = begtoken(i) = intoken(i) = endtoken(i) = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1536 for (sp = white; *sp != '\0'; sp++) iswhite (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1537 for (sp = nonam; *sp != '\0'; sp++) notinname (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1538 notinname('\0') = notinname('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1539 for (sp = begtk; *sp != '\0'; sp++) begtoken (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1540 begtoken('\0') = begtoken('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1541 for (sp = midtk; *sp != '\0'; sp++) intoken (*sp) = TRUE;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1542 intoken('\0') = intoken('\n');
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1543 for (sp = endtk; *sp != '\0'; sp++) endtoken (*sp) = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1544 endtoken('\0') = endtoken('\n');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1545 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1547 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1548 * This routine opens the specified file and calls the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1549 * which finds the function and type definitions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1550 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1551 node *last_node = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1552
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1553 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1554 find_entries (file, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1555 char *file;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1556 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1557 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1558 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1559 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1560 node *old_last_node;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1562 /* Memory leakage here: the string pointed by curfile is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1563 never released, because curfile is copied into np->file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1564 for each node, to be used in CTAGS mode. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1565 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1566 file names. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1567 curfile = savestr (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1568
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1569 /* If user specified a language, use it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1570 lang = forced_lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1571 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1573 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1574 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1575 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1576 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1577
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1578 /* Try to guess the language given the file name. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1579 lang = get_language_from_filename (file);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1580 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1581 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1582 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1583 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1584 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1585 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1586
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1587 /* Look for sharp-bang as the first two characters. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1588 if (readline_internal (&lb, inf) > 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1589 && lb.len >= 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1590 && lb.buffer[0] == '#'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1591 && lb.buffer[1] == '!')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1592 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1593 char *lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1594
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1595 /* Set lp to point at the first char after the last slash in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1596 line or, if no slashes, at the first nonblank. Then set cp to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1597 the first successive blank and terminate the string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1598 lp = etags_strrchr (lb.buffer+2, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1599 if (lp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1600 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1601 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1602 lp = skip_spaces (lb.buffer + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1603 cp = skip_non_spaces (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1604 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1605
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1606 if (strlen (lp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1608 lang = get_language_from_interpreter (lp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1609 if (lang != NULL && lang->function != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1610 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1611 curlang = lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1612 lang->function (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1613 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1614 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1615 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1616 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1617 /* We rewind here, even if inf may be a pipe. We fail if the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1618 length of the first line is longer than the pipe block size,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1619 which is unlikely. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1620 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1622 /* Try Fortran. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1623 old_last_node = last_node;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1624 curlang = get_language_from_langname ("fortran");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1625 Fortran_functions (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1626
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1627 /* No Fortran entries found. Try C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1628 if (old_last_node == last_node)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1629 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1630 /* We do not tag if rewind fails.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1631 Only the file name will be recorded in the tags file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1632 rewind (inf);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1633 curlang = get_language_from_langname (cplusplus ? "c++" : "c");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1634 default_C_entries (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1635 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1636 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1637 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1638
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1640 /* Record a tag. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1641 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1642 pfnote (name, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1643 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1644 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1645 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1646 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1647 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1648 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1649 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1650 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1652 if (CTAGS && name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1653 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1654
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1655 np = xnew (1, node);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1656
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1657 /* If ctags mode, change name "main" to M<thisfilename>. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1658 if (CTAGS && !cxref_style && streq (name, "main"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1659 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1660 register char *fp = etags_strrchr (curfile, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1661 np->name = concat ("M", fp == NULL ? curfile : fp + 1, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1662 fp = etags_strrchr (np->name, '.');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1663 if (fp != NULL && fp[1] != '\0' && fp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1664 fp[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1665 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1666 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1667 np->name = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1668 np->been_warned = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1669 np->file = curfile;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1670 np->is_func = is_func;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1671 np->lno = lno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1672 /* Our char numbers are 0-base, because of C language tradition?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1673 ctags compatibility? old versions compatibility? I don't know.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1674 Anyway, since emacs's are 1-base we expect etags.el to take care
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1675 of the difference. If we wanted to have 1-based numbers, we would
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1676 uncomment the +1 below. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1677 np->cno = cno /* + 1 */ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1678 np->left = np->right = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1679 if (CTAGS && !cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1680 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1681 if (strlen (linestart) < 50)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1682 np->pat = concat (linestart, "$", "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1683 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1684 np->pat = savenstr (linestart, 50);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1685 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1686 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1687 np->pat = savenstr (linestart, linelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1688
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1689 add_node (np, &head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1690 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1691
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1692 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1693 * TAGS format specification
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1694 * Idea by Sam Kendall <kendall@mv.mv.com> (1997)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1695 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1696 * pfnote should emit the optimized form [unnamed tag] only if:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1697 * 1. name does not contain any of the characters " \t\r\n(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1698 * 2. linestart contains name as either a rightmost, or rightmost but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1699 * one character, substring;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1700 * 3. the character, if any, immediately before name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1701 * be one of the characters " \t(),;";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1702 * 4. the character, if any, immediately after name in linestart must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1703 * also be one of the characters " \t(),;".
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1704 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1705 * The real implementation uses the notinname() macro, which recognises
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1706 * characters slightly different form " \t\r\n(),;". See the variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1707 * `nonam'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1708 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1709 #define traditional_tag_style TRUE
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1710 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1711 new_pfnote (name, namelen, is_func, linestart, linelen, lno, cno)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1712 char *name; /* tag name, or NULL if unnamed */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1713 int namelen; /* tag length */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1714 bool is_func; /* tag is a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1715 char *linestart; /* start of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1716 int linelen; /* length of the line where tag is */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1717 int lno; /* line number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1718 long cno; /* character number */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1719 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1720 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1721 bool named;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1723 named = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1724 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1725 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1726 for (cp = name; !notinname (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1727 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1728 if (*cp == '\0') /* rule #1 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1729 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1730 cp = linestart + linelen - namelen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1731 if (notinname (linestart[linelen-1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1732 cp -= 1; /* rule #4 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1733 if (cp >= linestart /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1734 && (cp == linestart
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1735 || notinname (cp[-1])) /* rule #3 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1736 && strneq (name, cp, namelen)) /* rule #2 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1737 named = FALSE; /* use unnamed tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1738 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1739 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1741 if (named)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1742 name = savenstr (name, namelen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1743 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1744 name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1745 pfnote (name, is_func, linestart, linelen, lno, cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1746 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1747
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1748 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1749 * free_tree ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1750 * recurse on left children, iterate on right children.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1751 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1752 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1753 free_tree (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1754 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1755 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1756 while (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1757 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1758 register node *node_right = np->right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1759 free_tree (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1760 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1761 free (np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1762 free (np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1763 free (np);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1764 np = node_right;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1765 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1766 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1768 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1769 * add_node ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1770 * Adds a node to the tree of nodes. In etags mode, we don't keep
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1771 * it sorted; we just keep a linear list. In ctags mode, maintain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1772 * an ordered tree, with no attempt at balancing.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1773 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1774 * add_node is the only function allowed to add nodes, so it can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1775 * maintain state.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1776 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1777 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1778 add_node (np, cur_node_p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1779 node *np, **cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1780 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1781 register int dif;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1782 register node *cur_node = *cur_node_p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1784 if (cur_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1785 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1786 *cur_node_p = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1787 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1788 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1789 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1791 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1792 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1793 /* Etags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1794 if (last_node == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1795 fatal ("internal error in add_node", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1796 last_node->right = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1797 last_node = np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1798 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1799 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1800 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1801 /* Ctags Mode */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1802 dif = strcmp (np->name, cur_node->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1804 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1805 * If this tag name matches an existing one, then
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1806 * do not add the node, but maybe print a warning.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1807 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1808 if (!dif)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1810 if (streq (np->file, cur_node->file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1811 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1812 if (!no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1813 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1814 fprintf (stderr, "Duplicate entry in file %s, line %d: %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1815 np->file, lineno, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1816 fprintf (stderr, "Second entry ignored\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1817 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1818 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1819 else if (!cur_node->been_warned && !no_warnings)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1820 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1821 fprintf
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1822 (stderr,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1823 "Duplicate entry in files %s and %s: %s (Warning only)\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1824 np->file, cur_node->file, np->name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1825 cur_node->been_warned = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1826 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1827 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1828 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1829
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1830 /* Actually add the node */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1831 add_node (np, dif < 0 ? &cur_node->left : &cur_node->right);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1832 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1833 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1834
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1835
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1836 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1837 put_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1838 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1839 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1840 register char *sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1841
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1842 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1843 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1844
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1845 /* Output subentries that precede this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1846 put_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1847
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1848 /* Output this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1849
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1850 if (!CTAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1851 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1852 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1853 fprintf (tagf, "%s\177%s\001%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1854 np->pat, np->name, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1855 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1856 fprintf (tagf, "%s\177%d,%ld\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1857 np->pat, np->lno, np->cno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1858 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1859 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1861 if (np->name == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1862 error ("internal error: NULL name in ctags mode.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1863
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1864 if (cxref_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1865 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1866 if (vgrind_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1867 fprintf (stdout, "%s %s %d\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1868 np->name, np->file, (np->lno + 63) / 64);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1869 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1870 fprintf (stdout, "%-16s %3d %-16s %s\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1871 np->name, np->lno, np->file, np->pat);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1872 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1873 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1874 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1875 fprintf (tagf, "%s\t%s\t", np->name, np->file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1876
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1877 if (np->is_func)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1878 { /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1879 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1880 putc ('^', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1881
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1882 for (sp = np->pat; *sp; sp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1883 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1884 if (*sp == '\\' || *sp == searchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1885 putc ('\\', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1886 putc (*sp, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1887 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1888 putc (searchar, tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1889 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1890 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1891 { /* a typedef; text pattern inadequate */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1892 fprintf (tagf, "%d", np->lno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1893 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1894 putc ('\n', tagf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1895 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1896 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1898 /* Output subentries that follow this one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1899 put_entries (np->right);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1900 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1901
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1902 /* Length of a number's decimal representation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1903 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1904 number_len (num)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1905 long num;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1906 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1907 int len = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1908 while ((num /= 10) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1909 len += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1910 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1911 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1912
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1913 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1914 * Return total number of characters that put_entries will output for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1915 * the nodes in the subtree of the specified node. Works only if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1916 * we are not ctags, but called only in that case. This count
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1917 * is irrelevant with the new tags.el, but is still supplied for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1918 * backward compatibility.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1919 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1920 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1921 total_size_of_entries (np)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1922 register node *np;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1923 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1924 register int total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1926 if (np == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1927 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1928
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1929 for (total = 0; np != NULL; np = np->right)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1930 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1931 /* Count left subentries. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1932 total += total_size_of_entries (np->left);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1933
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1934 /* Count this entry */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1935 total += strlen (np->pat) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1936 total += number_len ((long) np->lno) + 1 + number_len (np->cno) + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1937 if (np->name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1938 total += 1 + strlen (np->name); /* \001name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1939 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1940
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1941 return total;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1942 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1943
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1944
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1945 /* C extensions. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1946 #define C_EXT 0x00fff /* C extensions */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1947 #define C_PLAIN 0x00000 /* C */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1948 #define C_PLPL 0x00001 /* C++ */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1949 #define C_STAR 0x00003 /* C* */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1950 #define C_JAVA 0x00005 /* JAVA */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1951 #define C_AUTO 0x01000 /* C, but switch to C++ if `class' is met */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1952 #define YACC 0x10000 /* yacc file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1953
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1954 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1955 * The C symbol tables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1956 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1957 enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1958 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1959 st_none,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1960 st_C_objprot, st_C_objimpl, st_C_objend,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1961 st_C_gnumacro,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1962 st_C_ignore,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1963 st_C_javastruct,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1964 st_C_operator,
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
1965 st_C_class, st_C_template,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1966 st_C_struct, st_C_extern, st_C_enum, st_C_define, st_C_typedef, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1967 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1968
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1969 static unsigned int hash __P((const char *, unsigned int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1970 static struct C_stab_entry * in_word_set __P((const char *, unsigned int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
1971 static enum sym_type C_symtype __P((char *, int, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
1972
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1973 /* Feed stuff between (but not including) %[ and %] lines to:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1974 gperf -c -k 1,3 -o -p -r -t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1975 %[
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1976 struct C_stab_entry { char *name; int c_ext; enum sym_type type; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1977 %%
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1978 if, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1979 for, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1980 while, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1981 switch, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1982 return, 0, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1983 @interface, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1984 @protocol, 0, st_C_objprot
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1985 @implementation,0, st_C_objimpl
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1986 @end, 0, st_C_objend
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1987 import, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1988 package, C_JAVA, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1989 friend, C_PLPL, st_C_ignore
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1990 extends, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1991 implements, C_JAVA, st_C_javastruct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1992 interface, C_JAVA, st_C_struct
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
1993 class, 0, st_C_class
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1994 namespace, C_PLPL, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1995 domain, C_STAR, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1996 union, 0, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1997 struct, 0, st_C_struct
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1998 extern, 0, st_C_extern
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1999 enum, 0, st_C_enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2000 typedef, 0, st_C_typedef
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2001 define, 0, st_C_define
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2002 operator, C_PLPL, st_C_operator
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2003 template, 0, st_C_template
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2004 bool, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2005 long, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2006 short, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2007 int, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2008 char, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2009 float, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2010 double, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2011 signed, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2012 unsigned, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2013 auto, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2014 void, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2015 static, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2016 const, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2017 volatile, 0, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2018 explicit, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2019 mutable, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2020 typename, C_PLPL, st_C_typespec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2021 # DEFUN used in emacs, the next three used in glibc (SYSCALL only for mach).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2022 DEFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2023 SYSCALL, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2024 ENTRY, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2025 PSEUDO, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2026 # These are defined inside C functions, so currently they are not met.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2027 # EXFUN used in glibc, DEFVAR_* in emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2028 #EXFUN, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2029 #DEFVAR_, 0, st_C_gnumacro
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2030 %]
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2031 and replace lines between %< and %> with its output,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2032 then make in_word_set static. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2033 /*%<*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2034 /* C code produced by gperf version 2.7.1 (19981006 egcs) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2035 /* Command-line: gperf -c -k 1,3 -o -p -r -t */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2036 struct C_stab_entry { char *name; int c_ext; enum sym_type type; };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2037
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2038 #define TOTAL_KEYWORDS 47
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2039 #define MIN_WORD_LENGTH 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2040 #define MAX_WORD_LENGTH 15
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2041 #define MIN_HASH_VALUE 18
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2042 #define MAX_HASH_VALUE 138
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2043 /* maximum key range = 121, duplicates = 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2044
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2045 #ifdef __GNUC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2046 __inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2047 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2048 static unsigned int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2049 hash (str, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2050 register const char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2051 register unsigned int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2052 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2053 static unsigned char asso_values[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2054 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2055 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2056 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2057 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2058 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2059 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2060 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2061 139, 139, 139, 139, 63, 139, 139, 139, 33, 44,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2062 62, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2063 42, 139, 139, 12, 32, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2064 139, 139, 139, 139, 139, 139, 139, 34, 59, 37,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2065 24, 58, 33, 3, 139, 16, 139, 139, 42, 60,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2066 18, 11, 39, 139, 23, 57, 4, 63, 6, 20,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2067 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2068 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2069 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2070 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2071 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2072 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2073 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2074 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2075 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2076 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2077 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2078 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2079 139, 139, 139, 139, 139, 139, 139, 139, 139, 139,
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2080 139, 139, 139, 139, 139, 139
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2081 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2082 register int hval = len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2083
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2084 switch (hval)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2085 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2086 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2087 case 3:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2088 hval += asso_values[(unsigned char)str[2]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2089 case 2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2090 case 1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2091 hval += asso_values[(unsigned char)str[0]];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2092 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2093 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2094 return hval;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2095 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2096
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2097 #ifdef __GNUC__
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2098 __inline
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2099 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2100 static struct C_stab_entry *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2101 in_word_set (str, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2102 register const char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2103 register unsigned int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2104 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2105 static struct C_stab_entry wordlist[] =
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2106 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2107 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2108 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2109 {"if", 0, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2110 {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2111 {"int", 0, st_C_typespec},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2112 {""}, {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2113 {"void", 0, st_C_typespec},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2114 {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2115 {"interface", C_JAVA, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2116 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2117 {"SYSCALL", 0, st_C_gnumacro},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2118 {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2119 {"return", 0, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2120 {""}, {""}, {""}, {""}, {""}, {""}, {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2121 {"while", 0, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2122 {"auto", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2123 {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2124 {"float", 0, st_C_typespec},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2125 {"typedef", 0, st_C_typedef},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2126 {"typename", C_PLPL, st_C_typespec},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2127 {""}, {""}, {""},
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2128 {"friend", C_PLPL, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2129 {"volatile", 0, st_C_typespec},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2130 {""}, {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2131 {"for", 0, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2132 {"const", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2133 {"import", C_JAVA, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2134 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2135 {"define", 0, st_C_define},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2136 {"long", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2137 {"implements", C_JAVA, st_C_javastruct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2138 {"signed", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2139 {""},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2140 {"extern", 0, st_C_extern},
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2141 {"extends", C_JAVA, st_C_javastruct},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2142 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2143 {"mutable", C_PLPL, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2144 {"template", 0, st_C_template},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2145 {"short", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2146 {"bool", C_PLPL, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2147 {"char", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2148 {"class", 0, st_C_class},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2149 {"operator", C_PLPL, st_C_operator},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2150 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2151 {"switch", 0, st_C_ignore},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2152 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2153 {"ENTRY", 0, st_C_gnumacro},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2154 {""},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2155 {"package", C_JAVA, st_C_ignore},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2156 {"union", 0, st_C_struct},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2157 {"@end", 0, st_C_objend},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2158 {"struct", 0, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2159 {"namespace", C_PLPL, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2160 {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2161 {"domain", C_STAR, st_C_struct},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2162 {"@interface", 0, st_C_objprot},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2163 {"PSEUDO", 0, st_C_gnumacro},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2164 {"double", 0, st_C_typespec},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2165 {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2166 {"@protocol", 0, st_C_objprot},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2167 {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2168 {"static", 0, st_C_typespec},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2169 {""}, {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2170 {"DEFUN", 0, st_C_gnumacro},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2171 {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2172 {"explicit", C_PLPL, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2173 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2174 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2175 {""},
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2176 {"enum", 0, st_C_enum},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2177 {""}, {""},
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2178 {"unsigned", 0, st_C_typespec},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2179 {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""}, {""},
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2180 {"@implementation",0, st_C_objimpl}
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2181 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2183 if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2184 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2185 register int key = hash (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2186
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2187 if (key <= MAX_HASH_VALUE && key >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2188 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2189 register const char *s = wordlist[key].name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2191 if (*str == *s && !strncmp (str + 1, s + 1, len - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2192 return &wordlist[key];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2193 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2195 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2196 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2197 /*%>*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2199 static enum sym_type
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2200 C_symtype (str, len, c_ext)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2201 char *str;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2202 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2203 int c_ext;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2204 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2205 register struct C_stab_entry *se = in_word_set (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2207 if (se == NULL || (se->c_ext && !(c_ext & se->c_ext)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2208 return st_none;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2209 return se->type;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2210 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2211
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2212
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2213 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2214 * C functions and variables are recognized using a simple
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2215 * finite automaton. fvdef is its state variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2216 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2217 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2218 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2219 fvnone, /* nothing seen */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2220 fdefunkey, /* Emacs DEFUN keyword seen */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2221 fdefunname, /* Emacs DEFUN name seen */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2222 foperator, /* func: operator keyword seen (cplpl) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2223 fvnameseen, /* function or variable name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2224 fstartlist, /* func: just after open parenthesis */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2225 finlist, /* func: in parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2226 flistseen, /* func: after parameter list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2227 fignore, /* func: before open brace */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2228 vignore /* var-like: ignore until ';' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2229 } fvdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2230
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2231 bool fvextern; /* func or var: extern keyword seen; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2232
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2233 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2234 * typedefs are recognized using a simple finite automaton.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2235 * typdef is its state variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2236 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2237 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2238 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2239 tnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2240 tkeyseen, /* typedef keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2241 ttypeseen, /* defined type seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2242 tinbody, /* inside typedef body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2243 tend, /* just before typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2244 tignore /* junk after typedef tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2245 } typdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2246
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2247 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2248 * struct-like structures (enum, struct and union) are recognized
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2249 * using another simple finite automaton. `structdef' is its state
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2250 * variable.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2251 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2252 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2253 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2254 snone, /* nothing seen yet,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2255 or in struct body if cblev > 0 */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2256 skeyseen, /* struct-like keyword seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2257 stagseen, /* struct-like tag seen */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2258 sintemplate, /* inside template (ignore) */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2259 scolonseen /* colon seen after struct-like tag */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2260 } structdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2262 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2263 * When objdef is different from onone, objtag is the name of the class.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2264 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2265 char *objtag = "<uninited>";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2266
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2267 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2268 * Yet another little state machine to deal with preprocessor lines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2269 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2270 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2271 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2272 dnone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2273 dsharpseen, /* '#' seen as first char on line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2274 ddefineseen, /* '#' and 'define' seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2275 dignorerest /* ignore rest of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2276 } definedef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2277
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2278 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2279 * State machine for Objective C protocols and implementations.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2280 * Idea by Tom R.Hageman <tom@basil.icce.rug.nl> (1995)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2281 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2282 enum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2283 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2284 onone, /* nothing seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2285 oprotocol, /* @interface or @protocol seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2286 oimplementation, /* @implementations seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2287 otagseen, /* class name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2288 oparenseen, /* parenthesis before category seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2289 ocatseen, /* category name seen */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2290 oinbody, /* in @implementation body */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2291 omethodsign, /* in @implementation body, after +/- */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2292 omethodtag, /* after method name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2293 omethodcolon, /* after method colon */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2294 omethodparm, /* after method parameter */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2295 oignore /* wait for @end */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2296 } objdef;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2298
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2299 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2300 * Use this structure to keep info about the token read, and how it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2301 * should be tagged. Used by the make_C_tag function to build a tag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2302 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2303 struct tok
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2304 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2305 bool valid;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2306 bool named;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2307 int offset;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2308 int length;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2309 int lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2310 long linepos;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2311 char *line;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2312 } token; /* latest token read */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2313 linebuffer token_name; /* its name */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2314
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2315 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2316 * Variables and functions for dealing with nested structures.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2317 * Idea by Mykola Dzyuba <mdzyuba@yahoo.com> (2001)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2318 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2319 static void pushclass_above __P((int, char *, int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2320 static void popclass_above __P((int));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2321 static void write_classname __P((linebuffer *, char *qualifier));
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2322
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2323 struct {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2324 char **cname; /* nested class names */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2325 int *cblev; /* nested class curly brace level */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2326 int nl; /* class nesting level (elements used) */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2327 int size; /* length of the array */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2328 } cstack; /* stack for nested declaration tags */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2329 /* Current struct nesting depth (namespace, class, struct, union, enum). */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2330 #define nestlev (cstack.nl)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2331 /* After struct keyword or in struct body, not inside an nested function. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2332 #define instruct (structdef == snone && nestlev > 0 \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2333 && cblev == cstack.cblev[nestlev-1] + 1)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2334
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2335 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2336 pushclass_above (cblev, str, len)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2337 int cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2338 char *str;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2339 int len;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2340 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2341 int nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2342
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2343 popclass_above (cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2344 nl = cstack.nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2345 if (nl >= cstack.size)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2346 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2347 int size = cstack.size *= 2;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2348 xrnew (cstack.cname, size, char *);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2349 xrnew (cstack.cblev, size, int);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2350 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2351 assert (nl == 0 || cstack.cblev[nl-1] < cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2352 cstack.cname[nl] = (str == NULL) ? NULL : savenstr (str, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2353 cstack.cblev[nl] = cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2354 cstack.nl = nl + 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2355 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2356
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2357 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2358 popclass_above (cblev)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2359 int cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2360 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2361 int nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2362
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2363 for (nl = cstack.nl - 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2364 nl >= 0 && cstack.cblev[nl] >= cblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2365 nl--)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2366 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2367 if (cstack.cname[nl] != NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2368 free (cstack.cname[nl]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2369 cstack.nl = nl;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2370 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2371 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2372
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2373 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2374 write_classname (cn, qualifier)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2375 linebuffer *cn;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2376 char *qualifier;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2377 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2378 int i, len;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2379 int qlen = strlen (qualifier);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2380
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2381 if (cstack.nl == 0 || cstack.cname[0] == NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2382 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2383 len = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2384 cn->len = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2385 cn->buffer[0] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2386 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2387 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2388 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2389 len = strlen (cstack.cname[0]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2390 linebuffer_setlen (cn, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2391 strcpy (cn->buffer, cstack.cname[0]);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2392 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2393 for (i = 1; i < cstack.nl; i++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2394 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2395 char *s;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2396 int slen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2397
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2398 s = cstack.cname[i];
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2399 if (s == NULL)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2400 continue;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2401 slen = strlen (s);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2402 len += slen + qlen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2403 linebuffer_setlen (cn, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2404 strncat (cn->buffer, qualifier, qlen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2405 strncat (cn->buffer, s, slen);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2406 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2407 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2408
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2409
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2410 static bool consider_token __P((char *, int, int, int *, int, int, bool *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
2411 static void make_C_tag __P((bool));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2412
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2413 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2414 * consider_token ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2415 * checks to see if the current token is at the start of a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2416 * function or variable, or corresponds to a typedef, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2417 * is a struct/union/enum tag, or #define, or an enum constant.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2418 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2419 * *IS_FUNC gets TRUE iff the token is a function or #define macro
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2420 * with args. C_EXTP points to which language we are looking at.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2421 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2422 * Globals
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2423 * fvdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2424 * structdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2425 * definedef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2426 * typdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2427 * objdef IN OUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2428 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2429
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2430 static bool
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2431 consider_token (str, len, c, c_extp, cblev, parlev, is_func_or_var)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2432 register char *str; /* IN: token pointer */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2433 register int len; /* IN: token length */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2434 register int c; /* IN: first char after the token */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2435 int *c_extp; /* IN, OUT: C extensions mask */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2436 int cblev; /* IN: curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2437 int parlev; /* IN: parenthesis level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2438 bool *is_func_or_var; /* OUT: function or variable found */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2439 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2440 /* When structdef is stagseen, scolonseen, or snone with cblev > 0,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2441 structtype is the type of the preceding struct-like keyword, and
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2442 structcblev is the curly brace level where it has been seen. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2443 static enum sym_type structtype;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2444 static int structcblev;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2445 static enum sym_type toktype;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2446
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2447
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2448 toktype = C_symtype (str, len, *c_extp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2449
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2450 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2451 * Advance the definedef state machine.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2452 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2453 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2455 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2456 /* We're not on a preprocessor line. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2457 if (toktype == st_C_gnumacro)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2458 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2459 fvdef = fdefunkey;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2460 return FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2461 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2462 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2463 case dsharpseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2464 if (toktype == st_C_define)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2465 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2466 definedef = ddefineseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2468 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2469 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2470 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2471 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2472 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2473 case ddefineseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2474 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2475 * Make a tag for any macro, unless it is a constant
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2476 * and constantypedefs is FALSE.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2477 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2478 definedef = dignorerest;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2479 *is_func_or_var = (c == '(');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2480 if (!*is_func_or_var && !constantypedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2481 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2482 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2483 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2484 case dignorerest:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2485 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2486 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2487 error ("internal error: definedef value.", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2488 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2489
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2490 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2491 * Now typedefs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2492 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2493 switch (typdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2494 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2495 case tnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2496 if (toktype == st_C_typedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2497 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2498 if (typedefs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2499 typdef = tkeyseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2500 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2501 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2502 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2503 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2504 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2505 case tkeyseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2506 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2507 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2508 case st_none:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2509 case st_C_typespec:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2510 case st_C_class:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2511 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2512 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2513 typdef = ttypeseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2514 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2515 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2516 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2517 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2518 if (structdef == snone && fvdef == fvnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2519 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2520 fvdef = fvnameseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2521 return TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2522 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2523 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2524 case tend:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2525 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2526 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2527 case st_C_typespec:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2528 case st_C_class:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2529 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2530 case st_C_enum:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2531 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2533 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2534 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2535
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2536 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2537 * This structdef business is NOT invoked when we are ctags and the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2538 * file is plain C. This is because a struct tag may have the same
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2539 * name as another tag, and this loses with ctags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2540 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2541 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2542 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2543 case st_C_javastruct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2544 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2545 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2546 return FALSE;
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2547 case st_C_template:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2548 case st_C_class:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2549 if (cblev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2550 && (*c_extp & C_AUTO) /* automatic detection of C++ language */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2551 && definedef == dnone && structdef == snone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2552 && typdef == tnone && fvdef == fvnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2553 *c_extp = (*c_extp | C_PLPL) & ~C_AUTO;
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2554 if (toktype == st_C_template)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2555 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2556 /* FALLTHRU */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2557 case st_C_struct:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2558 case st_C_enum:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2559 if (parlev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2560 && fvdef != vignore
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2561 && (typdef == tkeyseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2562 || (typedefs_or_cplusplus && structdef == snone)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2563 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2564 structdef = skeyseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2565 structtype = toktype;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2566 structcblev = cblev;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2567 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2568 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2569 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2570
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2571 if (structdef == skeyseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2573 structdef = stagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2574 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2575 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2577 if (typdef != tnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2578 definedef = dnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2579
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2580 /* Detect Objective C constructs. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2581 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2582 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2583 case onone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2584 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2585 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2586 case st_C_objprot:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2587 objdef = oprotocol;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2588 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2589 case st_C_objimpl:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2590 objdef = oimplementation;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2591 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2592 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2593 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2594 case oimplementation:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2595 /* Save the class tag for functions or variables defined inside. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2596 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2597 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2598 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2599 case oprotocol:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2600 /* Save the class tag for categories. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2601 objtag = savenstr (str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2602 objdef = otagseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2603 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2604 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2605 case oparenseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2606 objdef = ocatseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2607 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2608 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2609 case oinbody:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2610 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2611 case omethodsign:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2612 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2613 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2614 objdef = omethodtag;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2615 linebuffer_setlen (&token_name, len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2616 strncpy (token_name.buffer, str, len);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2617 token_name.buffer[len] = '\0';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2618 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2619 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2620 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2621 case omethodcolon:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2622 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2623 objdef = omethodparm;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2624 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2625 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2626 if (parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2627 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2628 objdef = omethodtag;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2629 linebuffer_setlen (&token_name, token_name.len + len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2630 strncat (token_name.buffer, str, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2631 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2632 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2633 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2634 case oignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2635 if (toktype == st_C_objend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2636 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2637 /* Memory leakage here: the string pointed by objtag is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2638 never released, because many tests would be needed to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2639 avoid breaking on incorrect input code. The amount of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2640 memory leaked here is the sum of the lengths of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2641 class tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2642 free (objtag); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2643 objdef = onone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2644 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2645 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2646 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2647
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2648 /* A function, variable or enum constant? */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2649 switch (toktype)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2650 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2651 case st_C_extern:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2652 fvextern = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2653 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2654 case st_C_typespec:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2655 if (fvdef != finlist && fvdef != fignore && fvdef != vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2656 fvdef = fvnone; /* should be useless */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2657 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2658 case st_C_ignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2659 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2660 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2661 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2662 case st_C_operator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2663 fvdef = foperator;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2664 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2665 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2666 case st_none:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2667 if (constantypedefs
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2668 && structdef == snone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2669 && structtype == st_C_enum && cblev > structcblev)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2670 return TRUE; /* enum constant */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2671 switch (fvdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2672 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2673 case fdefunkey:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2674 if (cblev > 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2675 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2676 fvdef = fdefunname; /* GNU macro */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2677 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2678 return TRUE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2679 case fvnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2680 if ((strneq (str, "asm", 3) && endtoken (str[3]))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2681 || (strneq (str, "__asm__", 7) && endtoken (str[7])))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2682 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2683 fvdef = vignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2684 return FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2685 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2686 if ((*c_extp & C_PLPL) && strneq (str+len-10, "::operator", 10))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2687 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2688 fvdef = foperator;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2689 *is_func_or_var = TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2690 return TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2691 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2692 if (cblev > 0 && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2693 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2694 fvdef = fvnameseen; /* function or variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2695 *is_func_or_var = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2696 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2697 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2698 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2701 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2702 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2703
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2704
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2705 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2706 * C_entries often keeps pointers to tokens or lines which are older than
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2707 * the line currently read. By keeping two line buffers, and switching
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2708 * them at end of line, it is possible to use those pointers.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2709 */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2710 struct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2711 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2712 long linepos;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2713 linebuffer lb;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2714 } lbs[2];
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2715
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2716 #define current_lb_is_new (newndx == curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2717 #define switch_line_buffers() (curndx = 1 - curndx)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2719 #define curlb (lbs[curndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2720 #define newlb (lbs[newndx].lb)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2721 #define curlinepos (lbs[curndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2722 #define newlinepos (lbs[newndx].linepos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2723
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2724 #define CNL_SAVE_DEFINEDEF() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2725 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2726 curlinepos = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2727 lineno++; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2728 linecharno = charno; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2729 charno += readline (&curlb, inf); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2730 lp = curlb.buffer; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2731 quotednl = FALSE; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2732 newndx = curndx; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2733 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2734
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2735 #define CNL() \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2736 do { \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2737 CNL_SAVE_DEFINEDEF(); \
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2738 if (savetoken.valid) \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2739 { \
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2740 token = savetoken; \
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2741 savetoken.valid = FALSE; \
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2742 } \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2743 definedef = dnone; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2744 } while (0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2747 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2748 make_C_tag (isfun)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2749 bool isfun;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2750 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2751 /* This function should never be called when token.valid is FALSE, but
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2752 we must protect against invalid input or internal errors. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2753 if (DEBUG || token.valid)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2754 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2755 if (traditional_tag_style)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2756 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2757 /* This was the original code. Now we call new_pfnote instead,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2758 which uses the new method for naming tags (see new_pfnote). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2759 char *name = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2760
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2761 if (CTAGS || token.named)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2762 name = savestr (token_name.buffer);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2763 if (DEBUG && !token.valid)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2764 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2765 if (token.named)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2766 name = concat (name, "##invalid##", "");
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2767 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2768 name = savestr ("##invalid##");
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2769 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2770 pfnote (name, isfun, token.line,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2771 token.offset+token.length+1, token.lineno, token.linepos);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2772 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2773 else
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2774 new_pfnote (token_name.buffer, token_name.len, isfun, token.line,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2775 token.offset+token.length+1, token.lineno, token.linepos);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2776 token.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2777 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2778 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2779
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2780
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2781 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2782 * C_entries ()
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2783 * This routine finds functions, variables, typedefs,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2784 * #define's, enum constants and struct/union/enum definitions in
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2785 * C syntax and adds them to the list.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2786 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
2787 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2788 C_entries (c_ext, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2789 int c_ext; /* extension of C */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2790 FILE *inf; /* input file */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2791 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2792 register char c; /* latest char read; '\0' for end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2793 register char *lp; /* pointer one beyond the character `c' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2794 int curndx, newndx; /* indices for current and new lb */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2795 register int tokoff; /* offset in line of start of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2796 register int toklen; /* length of current token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2797 char *qualifier; /* string used to qualify names */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2798 int qlen; /* length of qualifier */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2799 int cblev; /* current curly brace level */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2800 int parlev; /* current parenthesis level */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2801 int typdefcblev; /* cblev where a typedef struct body begun */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2802 bool incomm, inquote, inchar, quotednl, midtoken;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2803 bool cplpl, cjava;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2804 bool yacc_rules; /* in the rules part of a yacc file */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2805 struct tok savetoken; /* token saved during preprocessor handling */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2806
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2807
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2808 initbuffer (&token_name);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2809 initbuffer (&lbs[0].lb);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2810 initbuffer (&lbs[1].lb);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2811 if (cstack.size == 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2812 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2813 cstack.size = (DEBUG) ? 1 : 4;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2814 cstack.nl = 0;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2815 cstack.cname = xnew (cstack.size, char *);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2816 cstack.cblev = xnew (cstack.size, int);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2817 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2818
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
2819 tokoff = toklen = typdefcblev = 0; /* keep compiler quiet */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2820 curndx = newndx = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2821 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2822 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2823 lp = curlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2824 *lp = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2826 fvdef = fvnone; fvextern = FALSE; typdef = tnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2827 structdef = snone; definedef = dnone; objdef = onone;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2828 yacc_rules = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2829 midtoken = inquote = inchar = incomm = quotednl = FALSE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2830 token.valid = savetoken.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2831 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2832 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2833 cplpl = (c_ext & C_PLPL) == C_PLPL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2834 cjava = (c_ext & C_JAVA) == C_JAVA;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2835 if (cjava)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2836 { qualifier = "."; qlen = 1; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2837 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2838 { qualifier = "::"; qlen = 2; }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2839
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2840
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2841 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2842 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2843 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2844 if (c == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2845 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2846 /* If we're at the end of the line, the next character is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2847 '\0'; don't skip it, because it's the thing that tells us
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2848 to read the next line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2849 if (*lp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2850 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2851 quotednl = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2852 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2853 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2854 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2855 c = ' ';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2856 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2857 else if (incomm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2858 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2859 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2860 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2861 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2862 if (*lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2863 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2864 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2865 incomm = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2866 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2867 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2868 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2869 /* Newlines inside comments do not end macro definitions in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2870 traditional cpp. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2871 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2872 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2873 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2874 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2875 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2876 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2877 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2878 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2879 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2880 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2881 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2882 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2883 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2884 /* Newlines inside strings do not end macro definitions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2885 in traditional cpp, even though compilers don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2886 usually accept them. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2887 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2888 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2889 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2890 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2891 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2892 else if (inchar)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2893 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2894 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2895 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2896 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2897 /* Hmmm, something went wrong. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2898 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2899 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2900 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2901 inchar = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2902 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2903 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2904 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2905 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2906 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2907 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2908 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2909 case '"':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2910 inquote = TRUE;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2911 switch (fvdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2912 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2913 case fdefunkey:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2914 case fstartlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2915 case finlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2916 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2917 case vignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2918 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2919 default:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2920 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2921 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2922 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2923 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2924 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2925 inchar = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2926 if (fvdef != finlist && fvdef != fignore && fvdef !=vignore)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2928 fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2929 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2930 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2931 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2932 case '/':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2933 if (*lp == '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2934 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2935 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2936 incomm = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2937 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2938 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2939 else if (/* cplpl && */ *lp == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2940 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2941 c = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2942 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2943 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2944 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2945 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2946 case '%':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2947 if ((c_ext & YACC) && *lp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2948 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2949 /* Entering or exiting rules section in yacc file. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2950 lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2951 definedef = dnone; fvdef = fvnone; fvextern = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2952 typdef = tnone; structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2953 midtoken = inquote = inchar = incomm = quotednl = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2954 cblev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2955 yacc_rules = !yacc_rules;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2956 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2957 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2958 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2959 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2960 case '#':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2961 if (definedef == dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2962 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2963 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2964 bool cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2965
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2966 /* Look back on this line. If all blanks, or nonblanks
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2967 followed by an end of comment, this is a preprocessor
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2968 token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2969 for (cp = newlb.buffer; cp < lp-1; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2970 if (!iswhite (*cp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2971 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2972 if (*cp == '*' && *(cp+1) == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2973 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2974 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2975 cpptoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2976 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2977 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2978 cpptoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2979 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2980 if (cpptoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2981 definedef = dsharpseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2982 } /* if (definedef == dnone) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2984 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2985 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2987
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2988 /* Consider token only if some involved conditions are satisfied. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2989 if (typdef != tignore
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2990 && definedef != dignorerest
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2991 && fvdef != finlist
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2992 && structdef != sintemplate
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2993 && (definedef != dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
2994 || structdef != scolonseen))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2995 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2996 if (midtoken)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2997 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2998 if (endtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2999 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3000 if (c == ':' && cplpl && *lp == ':' && begtoken (lp[1]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3001 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3002 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3003 * This handles :: in the middle, but not at the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3004 * beginning of an identifier. Also, space-separated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3005 * :: is not recognised.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3006 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3007 lp += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3008 toklen += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3009 c = lp[-1];
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3010 goto still_in_token;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3011 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3012 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3013 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3014 bool funorvar = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3015
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3016 if (yacc_rules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3017 || consider_token (newlb.buffer + tokoff, toklen, c,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3018 &c_ext, cblev, parlev, &funorvar))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3019 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3020 if (fvdef == foperator)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3021 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3022 char *oldlp = lp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3023 lp = skip_spaces (lp-1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3024 if (*lp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3025 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3026 while (*lp != '\0'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3027 && !iswhite (*lp) && *lp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3028 lp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3029 c = *lp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3030 toklen += lp - oldlp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3031 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3032 token.named = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3033 if ((c_ext & C_EXT) /* not pure C */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3034 && nestlev > 0 && definedef == dnone)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3035 /* in struct body */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3036 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3037 write_classname (&token_name, qualifier);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3038 linebuffer_setlen (&token_name,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3039 token_name.len+qlen+toklen);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3040 strcat (token_name.buffer, qualifier);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3041 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3042 newlb.buffer + tokoff, toklen);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3043 token.named = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3044 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3045 else if (objdef == ocatseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3046 /* Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3047 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3048 int len = strlen (objtag) + 2 + toklen;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3049 linebuffer_setlen (&token_name, len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3050 strcpy (token_name.buffer, objtag);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3051 strcat (token_name.buffer, "(");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3052 strncat (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3053 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3054 strcat (token_name.buffer, ")");
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3055 token.named = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3056 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3057 else if (objdef == omethodtag
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3058 || objdef == omethodparm)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3059 /* Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3060 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3061 token.named = TRUE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3062 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3063 else if (fvdef == fdefunname)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3064 /* GNU DEFUN and similar macros */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3065 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3066 bool defun = (newlb.buffer[tokoff] == 'F');
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3067 int off = tokoff;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3068 int len = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3069
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3070 /* Rewrite the tag so that emacs lisp DEFUNs
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3071 can be found by their elisp name */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3072 if (defun)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3073 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3074 off += 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3075 len -= 1;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3076 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3077 len = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3078 linebuffer_setlen (&token_name, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3079 strncpy (token_name.buffer,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3080 newlb.buffer + off, len);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3081 token_name.buffer[len] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3082 if (defun)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3083 while (--len >= 0)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3084 if (token_name.buffer[len] == '_')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3085 token_name.buffer[len] = '-';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3086 token.named = defun;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3087 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3088 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3089 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3090 linebuffer_setlen (&token_name, toklen);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3091 strncpy (token_name.buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3092 newlb.buffer + tokoff, toklen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3093 token_name.buffer[toklen] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3094 /* Name macros and members. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3095 token.named = (structdef == stagseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3096 || typdef == ttypeseen
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3097 || typdef == tend
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3098 || (funorvar
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3099 && definedef == dignorerest)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3100 || (funorvar
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3101 && definedef == dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3102 && structdef == snone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3103 && cblev > 0));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3104 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3105 token.lineno = lineno;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3106 token.offset = tokoff;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3107 token.length = toklen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3108 token.line = newlb.buffer;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3109 token.linepos = newlinepos;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3110 token.valid = TRUE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3111
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3112 if (definedef == dnone
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3113 && (fvdef == fvnameseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3114 || fvdef == foperator
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3115 || structdef == stagseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3116 || typdef == tend
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3117 || typdef == ttypeseen
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3118 || objdef != onone))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3119 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3120 if (current_lb_is_new)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3121 switch_line_buffers ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3122 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3123 else if (definedef != dnone
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3124 || fvdef == fdefunname
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3125 || instruct)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3126 make_C_tag (funorvar);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3127 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3128 midtoken = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3130 } /* if (endtoken (c)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3131 else if (intoken (c))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3132 still_in_token:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3133 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3134 toklen++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3135 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3136 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3137 } /* if (midtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3138 else if (begtoken (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3139 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3140 switch (definedef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3141 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3142 case dnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3143 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3144 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3145 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3146 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3147 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3148 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3149 make_C_tag (TRUE); /* a function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3150 fvdef = fignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3151 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3152 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3153 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3154 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3155 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3156 if (structdef == stagseen && !cjava)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3157 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3158 popclass_above (cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3159 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3160 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3161 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3162 case dsharpseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3163 savetoken = token;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3165 if (!yacc_rules || lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3166 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3167 tokoff = lp - 1 - newlb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3168 toklen = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3169 midtoken = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3170 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3171 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3172 } /* if (begtoken) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3173 } /* if must look at token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3174
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3176 /* Detect end of line, colon, comma, semicolon and various braces
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3177 after having handled a token.*/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3178 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3179 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3180 case ':':
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3181 if (yacc_rules && token.offset == 0 && token.valid)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3182 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3183 make_C_tag (FALSE); /* a yacc function */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3184 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3185 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3186 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3187 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3188 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3189 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3190 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3191 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3192 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3193 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3194 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3195 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3196 objdef = omethodcolon;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3197 linebuffer_setlen (&token_name, token_name.len + 1);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3198 strcat (token_name.buffer, ":");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3199 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3200 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3201 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3202 structdef = scolonseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3203 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3204 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3205 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3206 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3207 switch (typdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3208 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3209 case tend:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3210 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3211 make_C_tag (FALSE); /* a typedef */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3212 typdef = tnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3213 fvdef = fvnone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3214 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3215 case tnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3216 case tinbody:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3217 case tignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3218 switch (fvdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3219 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3220 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3221 if (typdef == tignore)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3222 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3223 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3224 case fvnameseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3225 if ((globals && cblev == 0 && (!fvextern || declarations))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3226 || (members && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3227 make_C_tag (FALSE); /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3228 fvextern = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3229 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3230 token.valid = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3231 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3232 case flistseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3233 if ((declarations && typdef == tnone && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3234 || (members && typdef != tignore && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3235 make_C_tag (TRUE); /* a function declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3236 /* FALLTHRU */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3237 default:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3238 fvextern = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3239 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3240 if (declarations
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3241 && structdef == stagseen && (c_ext & C_PLPL))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3242 make_C_tag (FALSE); /* forward declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3243 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3244 /* The following instruction invalidates the token.
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3245 Probably the token should be invalidated in all other
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3246 cases where some state machine is reset prematurely. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3247 token.valid = FALSE;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3248 } /* switch (fvdef) */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3249 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3250 default:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3251 if (!instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3252 typdef = tnone;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3253 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3254 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3255 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3256 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3257 case ',':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3258 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3259 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3260 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3261 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3262 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3263 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3264 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3265 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3266 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3267 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3268 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3269 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3270 case fdefunkey:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3271 case foperator:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3272 case fstartlist:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3273 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3274 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3275 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3276 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3277 case fdefunname:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3278 fvdef = fignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3279 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3280 case fvnameseen: /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3281 if ((globals && cblev == 0 && (!fvextern || declarations))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3282 || (members && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3283 make_C_tag (FALSE);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3284 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3285 case flistseen: /* a function */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3286 if ((declarations && typdef == tnone && !instruct)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3287 || (members && typdef != tignore && instruct))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3288 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3289 make_C_tag (TRUE); /* a function declaration */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3290 fvdef = fvnameseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3291 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3292 else if (!declarations)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3293 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3294 token.valid = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3295 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3296 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3297 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3298 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3299 if (structdef == stagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3300 structdef = snone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3301 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3302 case '[':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3303 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3304 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3305 if (structdef == stagseen)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3306 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3307 switch (typdef)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3308 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3309 case ttypeseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3310 case tend:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3311 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3312 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3313 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3314 case tnone:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3315 case tinbody:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3316 switch (fvdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3317 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3318 case foperator:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3319 case finlist:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3320 case fignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3321 case vignore:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3322 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3323 case fvnameseen:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3324 if ((members && cblev == 1)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3325 || (globals && cblev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3326 && (!fvextern || declarations)))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3327 make_C_tag (FALSE); /* a variable */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3328 /* FALLTHRU */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3329 default:
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3330 fvdef = fvnone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3331 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3332 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3333 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3334 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3335 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3336 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3337 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3338 if (objdef == otagseen && parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3339 objdef = oparenseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3340 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3341 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3342 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3343 if (typdef == ttypeseen
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3344 && *lp != '*'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3345 && !instruct)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3346 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3347 /* This handles constructs like:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3348 typedef void OperatorFun (int fun); */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3349 make_C_tag (FALSE);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3350 typdef = tignore;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3351 fvdef = fignore;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3352 break;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3353 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3354 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3355 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3356 fvdef = fstartlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3357 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3358 case flistseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3359 fvdef = finlist;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3360 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3361 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3362 parlev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3363 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3364 case ')':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3365 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3366 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3367 if (objdef == ocatseen && parlev == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3368 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3369 make_C_tag (TRUE); /* an Objective C category */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3370 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3371 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3372 if (--parlev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3374 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3375 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3376 case fstartlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3377 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3378 fvdef = flistseen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3379 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3380 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3381 if (!instruct
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3382 && (typdef == tend
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3383 || typdef == ttypeseen))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3384 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3385 typdef = tignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3386 make_C_tag (FALSE); /* a typedef */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3387 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3388 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3389 else if (parlev < 0) /* can happen due to ill-conceived #if's. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3390 parlev = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3391 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3392 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3393 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3394 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3395 if (typdef == ttypeseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3396 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3397 /* Whenever typdef is set to tinbody (currently only
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3398 here), typdefcblev should be set to cblev. */
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3399 typdef = tinbody;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3400 typdefcblev = cblev;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3401 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3402 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3403 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3404 case flistseen:
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3405 make_C_tag (TRUE); /* a function */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3406 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3407 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3408 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3409 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3410 case fvnone:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3411 switch (objdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3412 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3413 case otagseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3414 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3415 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3416 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3417 case omethodtag:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3418 case omethodparm:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3419 make_C_tag (TRUE); /* an Objective C method */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3420 objdef = oinbody;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3421 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3422 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3423 /* Neutralize `extern "C" {' grot. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3424 if (cblev == 0 && structdef == snone && nestlev == 0
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3425 && typdef == tnone)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3426 cblev = -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3427 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3428 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3429 switch (structdef)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3430 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3431 case skeyseen: /* unnamed struct */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3432 pushclass_above (cblev, NULL, 0);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3433 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3434 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3435 case stagseen: /* named struct or enum */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3436 case scolonseen: /* a class */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3437 pushclass_above (cblev, token.line+token.offset, token.length);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3438 structdef = snone;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3439 make_C_tag (FALSE); /* a struct or enum */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3440 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3441 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3442 cblev++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3443 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3444 case '*':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3445 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3446 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3447 if (fvdef == fstartlist)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3448 fvdef = fvnone; /* avoid tagging `foo' in `foo (*bar()) ()' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3449 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3450 case '}':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3451 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3452 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3453 if (!noindentypedefs && lp == newlb.buffer + 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3454 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3455 cblev = 0; /* reset curly brace level if first column */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3456 parlev = 0; /* also reset paren level, just in case... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3457 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3458 else if (cblev > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3459 cblev--;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3460 popclass_above (cblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3461 structdef = snone;
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
3462 /* Only if typdef == tinbody is typdefcblev significant. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3463 if (typdef == tinbody && cblev <= typdefcblev)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3464 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3465 assert (cblev == typdefcblev);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3466 typdef = tend;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3468 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3469 case '=':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3470 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3471 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3472 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3473 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3474 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3475 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3476 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3477 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3478 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3479 case fvnameseen:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3480 if ((members && cblev == 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3481 || (globals && cblev == 0 && (!fvextern || declarations)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3482 make_C_tag (FALSE); /* a variable */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3483 /* FALLTHRU */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3484 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3485 fvdef = vignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3486 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3487 break;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3488 case '<':
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3489 if (cplpl && structdef == stagseen)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3490 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3491 structdef = sintemplate;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3492 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3493 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3494 goto resetfvdef;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3495 case '>':
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3496 if (structdef == sintemplate)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3497 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3498 structdef = stagseen;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3499 break;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3500 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3501 goto resetfvdef;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3502 case '+':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3503 case '-':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3504 if (objdef == oinbody && cblev == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3505 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3506 objdef = omethodsign;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3507 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3508 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3509 /* FALLTHRU */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3510 resetfvdef:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3511 case '#': case '~': case '&': case '%': case '/': case '|':
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3512 case '^': case '!': case '.': case '?': case ']':
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3513 if (definedef != dnone)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3514 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3515 /* These surely cannot follow a function tag in C. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3516 switch (fvdef)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3517 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3518 case foperator:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3519 case finlist:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3520 case fignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3521 case vignore:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3522 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3523 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3524 fvdef = fvnone;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3525 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3526 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3527 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3528 if (objdef == otagseen)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3529 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3530 make_C_tag (TRUE); /* an Objective C class */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3531 objdef = oignore;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3532 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3533 /* If a macro spans multiple lines don't reset its state. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3534 if (quotednl)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3535 CNL_SAVE_DEFINEDEF ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3536 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3537 CNL ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3538 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3539 } /* switch (c) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3540
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3541 } /* while not eof */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3542
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3543 free (token_name.buffer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3544 free (lbs[0].lb.buffer);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3545 free (lbs[1].lb.buffer);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3546 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3548 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3549 * Process either a C++ file or a C file depending on the setting
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3550 * of a global flag.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3551 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3552 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3553 default_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3554 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3555 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3556 C_entries (cplusplus ? C_PLPL : C_AUTO, inf);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3557 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3558
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3559 /* Always do plain C. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3560 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3561 plain_C_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3562 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3563 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3564 C_entries (0, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3565 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3567 /* Always do C++. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3568 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3569 Cplusplus_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3570 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3571 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3572 C_entries (C_PLPL, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3573 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3574
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3575 /* Always do Java. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3576 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3577 Cjava_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3578 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3579 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3580 C_entries (C_JAVA, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3581 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3583 /* Always do C*. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3584 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3585 Cstar_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3586 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3587 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3588 C_entries (C_STAR, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3589 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3590
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3591 /* Always do Yacc. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3592 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3593 Yacc_entries (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3594 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3596 C_entries (YACC, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3597 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3598
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3599
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3600 /* Useful macros. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3601 #define LOOP_ON_INPUT_LINES(file_pointer, line_buffer, char_pointer) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3602 for (lineno = charno = 0; /* loop initialization */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3603 !feof (file_pointer) /* loop test */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3604 && (lineno++, /* instructions at start of loop */ \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3605 linecharno = charno, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3606 charno += readline (&line_buffer, file_pointer), \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3607 char_pointer = lb.buffer, \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3608 TRUE); \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3609 )
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3610 #define LOOKING_AT(cp, keyword) /* keyword is a constant string */ \
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3611 (strneq ((cp), keyword, sizeof(keyword)-1) /* cp points at kyword */ \
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3612 && iswhite((cp)[sizeof(keyword)-1]) /* followed by a blank */ \
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3613 && ((cp) = skip_spaces((cp)+sizeof(keyword)-1))) /* skip blanks */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3614
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3615 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3616 * Read a file, but do no processing. This is used to do regexp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3617 * matching on files that have no language defined.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3618 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3619 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3620 just_read_file (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3621 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3622 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3623 register char *dummy;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3624
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3625 LOOP_ON_INPUT_LINES (inf, lb, dummy)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3626 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3627 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3628
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3630 /* Fortran parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3631
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3632 static bool tail __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3633 static void takeprec __P((void));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3634 static void getit __P((FILE *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3635
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3636 static bool
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3637 tail (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3638 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3639 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3640 register int len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3641
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3642 while (*cp != '\0' && lowcase (*cp) == lowcase (dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3643 cp++, len++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3644 if (*cp == '\0' && !intoken (dbp[len]))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3645 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3646 dbp += len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3647 return TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3648 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3649 return FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3650 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3651
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3652 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3653 takeprec ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3654 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3655 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3656 if (*dbp != '*')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3657 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3658 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3659 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3660 if (strneq (dbp, "(*)", 3))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3661 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3662 dbp += 3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3663 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3664 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3665 if (!ISDIGIT (*dbp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3666 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3667 --dbp; /* force failure */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3668 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3669 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3670 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3671 dbp++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3672 while (ISDIGIT (*dbp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3673 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3674
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3675 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3676 getit (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3677 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3678 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3679 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3681 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3682 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3683 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3684 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3685 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3686 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3687 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3688 if (dbp[5] != '&')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3689 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3690 dbp += 6;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3691 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3692 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3693 if (!ISALPHA (*dbp) && *dbp != '_' && *dbp != '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3694 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3695 for (cp = dbp + 1; *cp != '\0' && intoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3696 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3697 pfnote (savenstr (dbp, cp-dbp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3698 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3701
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3702 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3703 Fortran_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3704 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3705 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3706 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3707 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3708 if (*dbp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3709 dbp++; /* Ratfor escape to fortran */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3710 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3711 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3712 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3713 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3714 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3715 case 'i':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3716 if (tail ("integer"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3717 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3718 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3719 case 'r':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3720 if (tail ("real"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3721 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3722 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3723 case 'l':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3724 if (tail ("logical"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3725 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3726 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3727 case 'c':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3728 if (tail ("complex") || tail ("character"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3729 takeprec ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3730 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3731 case 'd':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3732 if (tail ("double"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3733 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3734 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3735 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3736 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3737 if (tail ("precision"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3738 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3739 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3740 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3741 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3742 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3743 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3744 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3745 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3746 switch (lowcase (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3747 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3748 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3749 if (tail ("function"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3750 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3751 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3752 case 's':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3753 if (tail ("subroutine"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3754 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3755 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3756 case 'e':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3757 if (tail ("entry"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3758 getit (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3759 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3760 case 'b':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3761 if (tail ("blockdata") || tail ("block data"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3762 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3763 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3764 if (*dbp == '\0') /* assume un-named */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3765 pfnote (savestr ("blockdata"), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3766 lb.buffer, dbp - lb.buffer, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3767 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3768 getit (inf); /* look for name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3769 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3770 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3771 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3772 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3773 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3774
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3776 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3777 * Ada parsing
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3778 * Philippe Waroquiers <philippe.waroquiers@eurocontrol.be> (1998)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3779 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3780
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3781 static void adagetit __P((FILE *, char *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3782
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3783 /* Once we are positioned after an "interesting" keyword, let's get
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3784 the real tag value necessary. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3785 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3786 adagetit (inf, name_qualifier)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3787 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3788 char *name_qualifier;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3789 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3790 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3791 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3792 char c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3793
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3794 while (!feof (inf))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3795 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3796 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3797 if (*dbp == '\0'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3798 || (dbp[0] == '-' && dbp[1] == '-'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3799 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3800 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3801 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3802 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3803 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3804 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3805 switch (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3806 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3807 case 'b':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3808 case 'B':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3809 if (tail ("body"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3810 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3811 /* Skipping body of procedure body or package body or ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3812 resetting qualifier to body instead of spec. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3813 name_qualifier = "/b";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3814 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3815 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3816 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3817 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3818 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3819 /* Skipping type of task type or protected type ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3820 if (tail ("type"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3821 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3822 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3823 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3824 if (*dbp == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3825 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3826 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3827 for (cp = dbp; *cp != '\0' && *cp != '"'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3828 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3829 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3830 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3831 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3832 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3833 for (cp = dbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3834 (*cp != '\0'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3835 && (ISALPHA (*cp) || ISDIGIT (*cp) || *cp == '_' || *cp == '.'));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3836 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3837 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3838 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3839 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3840 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3841 c = *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3842 *cp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3843 name = concat (dbp, name_qualifier, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3844 *cp = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3845 pfnote (name, TRUE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3846 if (c == '"')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3847 dbp = cp + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3848 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3849 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3850 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3851
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3852 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3853 Ada_funcs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3854 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3855 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3856 bool inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3857
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3858 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3859 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3860 while (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3861 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3862 /* Skip a string i.e. "abcd". */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3863 if (inquote || (*dbp == '"'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3864 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3865 dbp = etags_strchr ((inquote) ? dbp : dbp+1, '"');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3866 if (dbp != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3867 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3868 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3869 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3870 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3871 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3872 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3873 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3874 inquote = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3875 break; /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3876 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3877 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3878
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3879 /* Skip comments. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3880 if (dbp[0] == '-' && dbp[1] == '-')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3881 break; /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3882
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3883 /* Skip character enclosed in single quote i.e. 'a'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3884 and skip single quote starting an attribute i.e. 'Image. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3885 if (*dbp == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3886 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3887 dbp++ ;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3888 if (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3889 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3890 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3891 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3892
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3893 /* Search for beginning of a token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3894 if (!begtoken (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3895 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3896 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3897 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3898 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3899
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3900 /* We are at the beginning of a token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3901 switch (*dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3902 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3903 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3904 case 'F':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3905 if (!packages_only && tail ("function"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3906 adagetit (inf, "/f");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3907 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3908 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3909 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3910 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3911 case 'P':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3912 if (!packages_only && tail ("procedure"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3913 adagetit (inf, "/p");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3914 else if (tail ("package"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3915 adagetit (inf, "/s");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3916 else if (tail ("protected")) /* protected type */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3917 adagetit (inf, "/t");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3918 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3919 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3920 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3921 case 't':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3922 case 'T':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3923 if (!packages_only && tail ("task"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3924 adagetit (inf, "/k");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3925 else if (typedefs && !packages_only && tail ("type"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3926 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3927 adagetit (inf, "/t");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3928 while (*dbp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3929 dbp += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3930 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3931 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3932 break; /* from switch */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3933 continue; /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3934 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3935
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3936 /* Look for the end of the token. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3937 while (!endtoken (*dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3938 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3939
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3940 } /* advance char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3941 } /* advance line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3942 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3943
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3944
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3945 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3946 * Bob Weiner, Motorola Inc., 4/3/94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3947 * Unix and microcontroller assembly tag handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3948 * look for '^[a-zA-Z_.$][a-zA_Z0-9_.$]*[: ^I^J]'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3949 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3950 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3951 Asm_labels (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3952 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3953 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3954 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3955
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3956 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3957 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3958 /* If first char is alphabetic or one of [_.$], test for colon
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3959 following identifier. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3960 if (ISALPHA (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3961 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3962 /* Read past label. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3963 cp++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3964 while (ISALNUM (*cp) || *cp == '_' || *cp == '.' || *cp == '$')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3965 cp++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3966 if (*cp == ':' || iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3967 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3968 /* Found end of label, so copy it and add it to the table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3969 pfnote (savenstr(lb.buffer, cp-lb.buffer), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3970 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3971 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3972 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3973 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3974 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3975
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3976
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3977 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3978 * Perl support
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3979 * Perl sub names: look for /^sub[ \t\n]+[^ \t\n{]+/
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3980 * Perl variable names: /^(my|local).../
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3981 * Bart Robinson <lomew@cs.utah.edu> (1995)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
3982 * Michael Ernst <mernst@alum.mit.edu> (1997)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3983 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3984 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3985 Perl_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3986 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3987 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3988 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3989
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3990 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3991 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
3992 if (LOOKING_AT (cp, "sub"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3993 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3994 if (*cp != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3995 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3996 char *sp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3997 while (*cp != '\0'
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
3998 && !iswhite (*cp) && *cp != '{' && *cp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3999 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4000 pfnote (savenstr (sp, cp-sp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4001 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4002 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4003 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4004 else if (globals /* only if tagging global vars is enabled */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4005 && ((strneq (cp, "my", 2) && (cp+=2))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4006 || (strneq (cp, "local", 5) && (cp+=5)))
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4007 && (*cp == '(' || iswhite (*cp)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4008 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4009 /* After "my" or "local", but before any following paren or space. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4010 char *varname = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4011
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4012 cp = skip_spaces (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4013 if (*cp == '$' || *cp == '@' || *cp == '%')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4014 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4015 char* varstart = ++cp;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4016 while (ISALNUM (*cp) || *cp == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4017 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4018 varname = savenstr (varstart, cp-varstart);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4019 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4020 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4021 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4022 /* Should be examining a variable list at this point;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4023 could insist on seeing an open parenthesis. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4024 while (*cp != '\0' && *cp != ';' && *cp != '=' && *cp != ')')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4025 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4026 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4027
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4028 /* Perhaps I should back cp up one character, so the TAGS table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4029 doesn't mention (and so depend upon) the following char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4030 pfnote ((CTAGS) ? savenstr (lb.buffer, cp-lb.buffer) : varname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4031 FALSE, lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4032 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4033 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4034 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4035
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4036
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4037 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4038 * Python support
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4039 * Look for /^def[ \t\n]+[^ \t\n(:]+/ or /^class[ \t\n]+[^ \t\n(:]+/
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4040 * Eric S. Raymond <esr@thyrsus.com> (1997)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4041 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4042 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4043 Python_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4044 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4045 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4046 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4047
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4048 LOOP_ON_INPUT_LINES (inf, lb, cp)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4049 if (LOOKING_AT (cp, "def") || LOOKING_AT (cp, "class"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4050 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4051 while (*cp != '\0' && !iswhite (*cp) && *cp != '(' && *cp != ':')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4052 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4053 pfnote (NULL, TRUE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4054 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4055 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4056 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4057
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4058
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4059 /*
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4060 * PHP support
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4061 * Look for:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4062 * - /^[ \t]*function[ \t\n]+[^ \t\n(]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4063 * - /^[ \t]*class[ \t\n]+[^ \t\n]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4064 * - /^[ \t]*define\(\"[^\"]+/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4065 * Only with --members:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4066 * - /^[ \t]*var[ \t\n]+\$[^ \t\n=;]/
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4067 * originally by Diez B. Roggisch 2001-06-06
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4068 */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4069 static void
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4070 PHP_functions (inf)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4071 FILE *inf;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4072 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4073 register char *cp;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4074 bool search_identifier = FALSE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4075
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4076 LOOP_ON_INPUT_LINES (inf, lb, cp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4077 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4078 cp = skip_spaces (cp);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4079 if (search_identifier
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4080 && *cp != '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4081 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4082 while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4083 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4084 pfnote (NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4085 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4086 search_identifier = FALSE;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4087 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4088 else if (LOOKING_AT (cp, "function"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4089 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4090 if(*cp == '&')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4091 cp = skip_spaces (cp+1);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4092 if(*cp != '\0')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4093 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4094 while (*cp != '\0' && !iswhite (*cp) && *cp != '(')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4095 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4096 pfnote (NULL, TRUE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4097 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4098 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4099 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4100 search_identifier = TRUE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4101 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4102 else if (LOOKING_AT (cp, "class"))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4103 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4104 if (*cp != '\0')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4105 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4106 while (*cp != '\0' && !iswhite (*cp))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4107 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4108 pfnote (NULL, FALSE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4109 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4110 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4111 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4112 search_identifier = TRUE;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4113 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4114 else if (strneq (cp, "define", 6)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4115 && (cp = skip_spaces (cp+6))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4116 && *cp++ == '('
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4117 && (*cp == '"' || *cp == '\''))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4118 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4119 char quote = *cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4120 while (*cp != quote && *cp != '\0')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4121 cp++;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4122 pfnote (NULL, FALSE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4123 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4124 }
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4125 else if (members
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4126 && LOOKING_AT (cp, "var")
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4127 && *cp == '$')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4128 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4129 while (*cp != '=' && *cp != ';' && *cp != '\0' && !iswhite(*cp))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4130 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4131 pfnote (NULL, FALSE,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4132 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4133 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4134 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4135 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4136
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4138 /* Idea by Corny de Souza
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4139 * Cobol tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4140 * We could look for anything that could be a paragraph name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4141 * i.e. anything that starts in column 8 is one word and ends in a full stop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4142 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4143 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4144 Cobol_paragraphs (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4145 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4147 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4149 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4150 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4151 if (lb.len < 9)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4152 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4153 bp += 8;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4155 /* If eoln, compiler option or comment ignore whole line. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4156 if (bp[-1] != ' ' || !ISALNUM (bp[0]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4157 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4158
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4159 for (ep = bp; ISALNUM (*ep) || *ep == '-'; ep++)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4160 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4161 if (*ep++ == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4162 pfnote (savenstr (bp, ep-bp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4163 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4164 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4165 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4166
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4167
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4168 /*
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4169 * Makefile support
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4170 * Idea by Assar Westerlund <assar@sics.se> (2001)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4171 */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4172 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4173 Makefile_targets (inf)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4174 FILE *inf;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4175 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4176 register char *bp;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4177
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4178 LOOP_ON_INPUT_LINES (inf, lb, bp)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4179 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4180 if (*bp == '\t' || *bp == '#')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4181 continue;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4182 while (*bp != '\0' && *bp != '=' && *bp != ':')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4183 bp++;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4184 if (*bp == ':')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4185 pfnote (savenstr (lb.buffer, bp - lb.buffer), TRUE,
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4186 lb.buffer, bp - lb.buffer + 1, lineno, linecharno);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4187 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4188 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4189
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4190
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4191 /* Added by Mosur Mohan, 4/22/88 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4192 /* Pascal parsing */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4193
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4194 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4195 * Locates tags for procedures & functions. Doesn't do any type- or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4196 * var-definitions. It does look for the keyword "extern" or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4197 * "forward" immediately following the procedure statement; if found,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4198 * the tag is skipped.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4199 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4200 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4201 Pascal_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4202 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4203 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4204 linebuffer tline; /* mostly copied from C_entries */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4205 long save_lcno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4206 int save_lineno, save_len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4207 char c, *cp, *namebuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4208
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4209 bool /* each of these flags is TRUE iff: */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4210 incomment, /* point is inside a comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4211 inquote, /* point is inside '..' string */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4212 get_tagname, /* point is after PROCEDURE/FUNCTION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4213 keyword, so next item = potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4214 found_tag, /* point is after a potential tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4215 inparms, /* point is within parameter-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4216 verify_tag; /* point has passed the parm-list, so the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4217 next token will determine whether this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4218 is a FORWARD/EXTERN to be ignored, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4219 whether it is a real tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4221 save_lcno = save_lineno = save_len = 0; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4222 namebuf = NULL; /* keep compiler quiet */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4223 lineno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4224 charno = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4225 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4226 *dbp = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4227 initbuffer (&tline);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4228
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4229 incomment = inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4230 found_tag = FALSE; /* have a proc name; check if extern */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4231 get_tagname = FALSE; /* have found "procedure" keyword */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4232 inparms = FALSE; /* found '(' after "proc" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4233 verify_tag = FALSE; /* check if "extern" is ahead */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4235
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4236 while (!feof (inf)) /* long main loop to get next char */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4237 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4238 c = *dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4239 if (c == '\0') /* if end of line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4240 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4241 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4242 linecharno = charno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4243 charno += readline (&lb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4244 dbp = lb.buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4245 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4246 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4247 if (!((found_tag && verify_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4248 || get_tagname))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4249 c = *dbp++; /* only if don't need *dbp pointing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4250 to the beginning of the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4251 the procedure or function */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4253 if (incomment)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4254 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4255 if (c == '}') /* within { } comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4256 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4257 else if (c == '*' && *dbp == ')') /* within (* *) comments */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4258 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4259 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4260 incomment = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4261 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4262 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4263 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4264 else if (inquote)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4265 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4266 if (c == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4267 inquote = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4268 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4269 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4270 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4271 switch (c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4272 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4273 case '\'':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4274 inquote = TRUE; /* found first quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4275 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4276 case '{': /* found open { comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4277 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4278 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4279 case '(':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4280 if (*dbp == '*') /* found open (* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4281 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4282 incomment = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4283 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4284 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4285 else if (found_tag) /* found '(' after tag, i.e., parm-list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4286 inparms = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4287 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4288 case ')': /* end of parms list */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4289 if (inparms)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4290 inparms = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4291 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4292 case ';':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4293 if (found_tag && !inparms) /* end of proc or fn stmt */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4294 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4295 verify_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4296 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4297 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4298 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4299 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4300 if (found_tag && verify_tag && (*dbp != ' '))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4301 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4302 /* check if this is an "extern" declaration */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4303 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4304 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4305 if (lowcase (*dbp == 'e'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4306 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4307 if (tail ("extern")) /* superfluous, really! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4308 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4309 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4310 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4311 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4312 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4313 else if (lowcase (*dbp) == 'f')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4314 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4315 if (tail ("forward")) /* check for forward reference */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4316 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4317 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4318 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4319 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4320 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4321 if (found_tag && verify_tag) /* not external proc, so make tag */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4322 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4323 found_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4324 verify_tag = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4325 pfnote (namebuf, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4326 tline.buffer, save_len, save_lineno, save_lcno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4327 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4328 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4329 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4330 if (get_tagname) /* grab name of proc or fn */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4331 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4332 if (*dbp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4333 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4335 /* save all values for later tagging */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4336 linebuffer_setlen (&tline, lb.len);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4337 strcpy (tline.buffer, lb.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4338 save_lineno = lineno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4339 save_lcno = linecharno;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4340
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4341 /* grab block name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4342 for (cp = dbp + 1; *cp != '\0' && !endtoken (*cp); cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4343 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4344 namebuf = savenstr (dbp, cp-dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4345 dbp = cp; /* set dbp to e-o-token */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4346 save_len = dbp - lb.buffer + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4347 get_tagname = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4348 found_tag = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4349 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4351 /* and proceed to check for "extern" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4352 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4353 else if (!incomment && !inquote && !found_tag)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4354 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4355 /* check for proc/fn keywords */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4356 switch (lowcase (c))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4357 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4358 case 'p':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4359 if (tail ("rocedure")) /* c = 'p', dbp has advanced */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4360 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4361 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4362 case 'f':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4363 if (tail ("unction"))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4364 get_tagname = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4365 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4366 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4367 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4368 } /* while not eof */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4370 free (tline.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4371 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4372
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4373
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4374 /*
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4375 * Lisp tag functions
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4376 * look for (def or (DEF, quote or QUOTE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4377 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4378
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4379 static int L_isdef __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4380 static int L_isquote __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4381 static void L_getit __P((void));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4382
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4383 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4384 L_isdef (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4385 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4386 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4387 return ((strp[1] == 'd' || strp[1] == 'D')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4388 && (strp[2] == 'e' || strp[2] == 'E')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4389 && (strp[3] == 'f' || strp[3] == 'F'));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4390 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4391
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4392 static int
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4393 L_isquote (strp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4394 register char *strp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4395 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4396 return ((*++strp == 'q' || *strp == 'Q')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4397 && (*++strp == 'u' || *strp == 'U')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4398 && (*++strp == 'o' || *strp == 'O')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4399 && (*++strp == 't' || *strp == 'T')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4400 && (*++strp == 'e' || *strp == 'E')
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4401 && iswhite (*++strp));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4402 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4403
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4404 static void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4405 L_getit ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4406 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4407 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4408
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4409 if (*dbp == '\'') /* Skip prefix quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4410 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4411 else if (*dbp == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4412 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4413 if (L_isquote (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4414 dbp += 7; /* Skip "(quote " */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4415 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4416 dbp += 1; /* Skip "(" before name in (defstruct (foo)) */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4417 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4420 for (cp = dbp /*+1*/;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4421 *cp != '\0' && *cp != '(' && !iswhite(*cp) && *cp != ')';
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4422 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4423 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4424 if (cp == dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4425 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4426
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4427 pfnote (savenstr (dbp, cp-dbp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4428 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4429 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4430
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4431 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4432 Lisp_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4433 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4434 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4435 LOOP_ON_INPUT_LINES (inf, lb, dbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4436 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4437 if (dbp[0] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4439 if (L_isdef (dbp))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4440 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4441 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4442 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4443 L_getit ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4444 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4445 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4446 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4447 /* Check for (foo::defmumble name-defined ... */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4448 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4449 dbp++;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4450 while (*dbp != '\0' && !iswhite (*dbp)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4451 && *dbp != ':' && *dbp != '(' && *dbp != ')');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4452 if (*dbp == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4453 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4454 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4455 dbp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4456 while (*dbp == ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4458 if (L_isdef (dbp - 1))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4459 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4460 dbp = skip_non_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4461 dbp = skip_spaces (dbp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4462 L_getit ();
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4463 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4464 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4465 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4466 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4467 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4468 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4469
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4471 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4472 * Postscript tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4473 * Just look for lines where the first character is '/'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4474 * Also look at "defineps" for PSWrap
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4475 * Richard Mlynarik <mly@adoc.xerox.com> (1997)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4476 * Ideas by Masatake Yamato <masata-y@is.aist-nara.ac.jp> (1999)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4477 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4478 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4479 Postscript_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4480 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4481 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4482 register char *bp, *ep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4483
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4484 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4485 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4486 if (bp[0] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4487 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4488 for (ep = bp+1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4489 *ep != '\0' && *ep != ' ' && *ep != '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4490 ep++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4491 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4492 pfnote (savenstr (bp, ep-bp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4493 lb.buffer, ep - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4494 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4495 else if (strneq (bp, "defineps", 8))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4496 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4497 bp = skip_non_spaces (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4498 bp = skip_spaces (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4499 get_tag (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4500 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4501 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4502 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4504
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4505 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4506 * Scheme tag functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4507 * look for (def... xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4508 * look for (def... (xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4509 * look for (def ... ((...(xyzzy ....
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4510 * look for (set! xyzzy
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4511 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4512
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4513 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4514 Scheme_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4515 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4516 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4517 register char *bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4519 LOOP_ON_INPUT_LINES (inf, lb, bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4520 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4521 if (bp[0] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4522 && (bp[1] == 'D' || bp[1] == 'd')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4523 && (bp[2] == 'E' || bp[2] == 'e')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4524 && (bp[3] == 'F' || bp[3] == 'f'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4525 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4526 bp = skip_non_spaces (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4527 /* Skip over open parens and white space */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4528 while (iswhite (*bp) || *bp == '(')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4529 bp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4530 get_tag (bp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4531 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4532 if (LOOKING_AT (bp, "(SET!") || LOOKING_AT (bp, "(set!"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4533 get_tag (bp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4534 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4535 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4536
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4537
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4538 /* Find tags in TeX and LaTeX input files. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4539
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4540 /* TEX_toktab is a table of TeX control sequences that define tags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4541 Each TEX_tabent records one such control sequence.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4542 CONVERT THIS TO USE THE Stab TYPE!! */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4543 struct TEX_tabent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4544 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4545 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4546 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4547 };
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4548
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4549 struct TEX_tabent *TEX_toktab = NULL; /* Table with tag tokens */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4550
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4551 /* Default set of control sequences to put into TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4552 The value of environment var TEXTAGS is prepended to this. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4554 char *TEX_defenv = "\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4555 :chapter:section:subsection:subsubsection:eqno:label:ref:cite:bibitem\
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4556 :part:appendix:entry:index";
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4557
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4558 static void TEX_mode __P((FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4559 static struct TEX_tabent *TEX_decode_env __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4560 static int TEX_Token __P((char *));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4562 char TEX_esc = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4563 char TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4564 char TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4565
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4566 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4567 * TeX/LaTeX scanning loop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4568 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4569 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4570 TeX_commands (inf)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4571 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4572 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4573 char *cp, *lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4574 register int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4575
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4576 /* Select either \ or ! as escape character. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4577 TEX_mode (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4579 /* Initialize token table once from environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4580 if (!TEX_toktab)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4581 TEX_toktab = TEX_decode_env ("TEXTAGS", TEX_defenv);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4583 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4584 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4585 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4586 /* Look at each esc in line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4587 while ((cp = etags_strchr (cp, TEX_esc)) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4588 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4589 if (*++cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4590 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4591 linecharno += cp - lasthit;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4592 lasthit = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4593 i = TEX_Token (lasthit);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4594 if (i >= 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4595 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4596 /* We seem to include the TeX command in the tag name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4597 register char *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4598 for (p = lasthit + TEX_toktab[i].len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4599 *p != '\0' && *p != TEX_clgrp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4600 p++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4601 continue; */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4602 pfnote (/*savenstr (lasthit, p-lasthit)*/ (char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4603 lb.buffer, lb.len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4604 break; /* We only tag a line once */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4605 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4606 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4607 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4608 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4609
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4610 #define TEX_LESC '\\'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4611 #define TEX_SESC '!'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4612 #define TEX_cmt '%'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4613
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4614 /* Figure out whether TeX's escapechar is '\\' or '!' and set grouping
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4615 chars accordingly. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4616 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4617 TEX_mode (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4618 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4619 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4620 int c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4622 while ((c = getc (inf)) != EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4623 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4624 /* Skip to next line if we hit the TeX comment char. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4625 if (c == TEX_cmt)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4626 while (c != '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4627 c = getc (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4628 else if (c == TEX_LESC || c == TEX_SESC )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4629 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4630 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4631
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4632 if (c == TEX_LESC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4633 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4634 TEX_esc = TEX_LESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4635 TEX_opgrp = '{';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4636 TEX_clgrp = '}';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4637 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4638 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4639 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4640 TEX_esc = TEX_SESC;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4641 TEX_opgrp = '<';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4642 TEX_clgrp = '>';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4643 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4644 /* If the input file is compressed, inf is a pipe, and rewind may fail.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4645 No attempt is made to correct the situation. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4646 rewind (inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4647 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4649 /* Read environment and prepend it to the default string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4650 Build token table. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4651 static struct TEX_tabent *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4652 TEX_decode_env (evarname, defenv)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4653 char *evarname;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4654 char *defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4655 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4656 register char *env, *p;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4657
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4658 struct TEX_tabent *tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4659 int size, i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4661 /* Append default string to environment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4662 env = getenv (evarname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4663 if (!env)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4664 env = defenv;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4665 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4666 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4667 char *oldenv = env;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4668 env = concat (oldenv, defenv, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4669 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4670
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4671 /* Allocate a token table */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4672 for (size = 1, p = env; p;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4673 if ((p = etags_strchr (p, ':')) && *++p != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4674 size++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4675 /* Add 1 to leave room for null terminator. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4676 tab = xnew (size + 1, struct TEX_tabent);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4678 /* Unpack environment string into token table. Be careful about */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4679 /* zero-length strings (leading ':', "::" and trailing ':') */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4680 for (i = 0; *env;)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4681 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4682 p = etags_strchr (env, ':');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4683 if (!p) /* End of environment string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4684 p = env + strlen (env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4685 if (p - env > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4686 { /* Only non-zero strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4687 tab[i].name = savenstr (env, p - env);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4688 tab[i].len = strlen (tab[i].name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4689 i++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4690 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4691 if (*p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4692 env = p + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4693 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4694 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4695 tab[i].name = NULL; /* Mark end of table. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4696 tab[i].len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4697 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4698 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4699 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4700 return tab;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4701 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4703 /* If the text at CP matches one of the tag-defining TeX command names,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4704 return the pointer to the first occurrence of that command in TEX_toktab.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4705 Otherwise return -1.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4706 Keep the capital `T' in `token' for dumb truncating compilers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4707 (this distinguishes it from `TEX_toktab' */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4708 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4709 TEX_Token (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4710 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4711 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4712 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4713
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4714 for (i = 0; TEX_toktab[i].len > 0; i++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4715 if (strneq (TEX_toktab[i].name, cp, TEX_toktab[i].len))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4716 return i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4717 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4718 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4719
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4720
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4721 /* Texinfo support. Dave Love, Mar. 2000. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4722 static void
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4723 Texinfo_nodes (inf)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4724 FILE * inf;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4725 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4726 char *cp, *start;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4727 LOOP_ON_INPUT_LINES (inf, lb, cp)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4728 if (LOOKING_AT (cp, "@node"))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4729 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4730 start = cp;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4731 while (*cp != '\0' && *cp != ',')
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4732 cp++;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4733 pfnote (savenstr (start, cp - start), TRUE,
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4734 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4735 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4736 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4737
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4738
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4739 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4740 * Prolog support (rewritten) by Anders Lindgren, Mar. 96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4741 *
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4742 * Assumes that the predicate or rule starts at column 0.
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4743 * Only the first clause of a predicate or rule is added.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4744 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4745 static int prolog_pr __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4746 static void prolog_skip_comment __P((linebuffer *, FILE *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4747 static int prolog_atom __P((char *, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4748
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4749 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4750 Prolog_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4751 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4752 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4753 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4754 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4755 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4756
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4757 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4758 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4759 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4760
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4761 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4762 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4763 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4764 continue;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4765 else if (iswhite (cp[0])) /* Not a predicate */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4766 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4767 else if (cp[0] == '/' && cp[1] == '*') /* comment. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4768 prolog_skip_comment (&lb, inf);
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4769 else if ((len = prolog_pr (cp, last)) > 0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4770 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4771 /* Predicate or rule. Store the function name so that we
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4772 only generate a tag for the first clause. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4773 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4774 last = xnew(len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4775 else if (len + 1 > allocated)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4776 xrnew (last, len + 1, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4777 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4778 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4779 last[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4780 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4781 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4782 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4783
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4784
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4785 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4786 prolog_skip_comment (plb, inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4787 linebuffer *plb;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4788 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4789 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4790 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4791
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4792 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4793 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4794 for (cp = plb->buffer; *cp != '\0'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4795 if (cp[0] == '*' && cp[1] == '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4796 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4797 lineno++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4798 linecharno += readline (plb, inf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4799 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4800 while (!feof(inf));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4801 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4802
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4803 /*
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4804 * A predicate or rule definition is added if it matches:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4805 * <beginning of line><Prolog Atom><whitespace>(
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4806 * or <beginning of line><Prolog Atom><whitespace>:-
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4807 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4808 * It is added to the tags database if it doesn't match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4809 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4810 *
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4811 * Return the size of the name of the predicate or rule, or 0 if no
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4812 * header was found.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4813 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4814 static int
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4815 prolog_pr (s, last)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4816 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4817 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4818 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4819 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4820 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4822 pos = prolog_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4823 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4824 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4825
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4826 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4827 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4828
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4829 if ((s[pos] == '.'
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4830 || (s[pos] == '(' && (pos += 1))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4831 || (s[pos] == ':' && s[pos + 1] == '-' && (pos += 2)))
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4832 && (last == NULL /* save only the first clause */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4833 || len != strlen (last)
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4834 || !strneq (s, last, len)))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4835 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4836 pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4837 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4838 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4839 else
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4840 return 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4841 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4843 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4844 * Consume a Prolog atom.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4845 * Return the number of bytes consumed, or -1 if there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4846 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4847 * A prolog atom, in this context, could be one of:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4848 * - An alphanumeric sequence, starting with a lower case letter.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4849 * - A quoted arbitrary string. Single quotes can escape themselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4850 * Backslash quotes everything.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4851 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4852 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4853 prolog_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4854 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4855 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4856 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4857 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4859 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4860
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4861 if (ISLOWER(s[pos]) || (s[pos] == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4862 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4863 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4864 pos++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4865 while (ISALNUM(s[pos]) || (s[pos] == '_'))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4866 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4867 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4868 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4869 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4870 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4871 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4872 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4873 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4875 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4876 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4877 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4878 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4879 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4880 if (s[pos] != '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4881 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4882 pos++; /* A double quote */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4883 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4884 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4885 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4886 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4887 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4888 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4889 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4890 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4891 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4892 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4893 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4894 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4895 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4896 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4897 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4898 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4899 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4900 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4901
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4903 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4904 * Support for Erlang -- Anders Lindgren, Feb 1996.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4905 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4906 * Generates tags for functions, defines, and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4907 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4908 * Assumes that Erlang functions start at column 0.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4909 */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4910 static int erlang_func __P((char *, char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4911 static void erlang_attribute __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
4912 static int erlang_atom __P((char *, int));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4913
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4914 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4915 Erlang_functions (inf)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4916 FILE *inf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4917 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4918 char *cp, *last;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4919 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4920 int allocated;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4921
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4922 allocated = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4923 len = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4924 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4925
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4926 LOOP_ON_INPUT_LINES (inf, lb, cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4927 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4928 if (cp[0] == '\0') /* Empty line */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4929 continue;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4930 else if (iswhite (cp[0])) /* Not function nor attribute */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4931 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4932 else if (cp[0] == '%') /* comment */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4933 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4934 else if (cp[0] == '"') /* Sometimes, strings start in column one */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4935 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4936 else if (cp[0] == '-') /* attribute, e.g. "-define" */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4937 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4938 erlang_attribute (cp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4939 last = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4940 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4941 else if ((len = erlang_func (cp, last)) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4942 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4943 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4944 * Function. Store the function name so that we only
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4945 * generates a tag for the first clause.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4946 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4947 if (last == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4948 last = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4949 else if (len + 1 > allocated)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
4950 xrnew (last, len + 1, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4951 allocated = len + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4952 strncpy (last, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4953 last[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4954 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4955 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4956 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4958
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4959 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4960 * A function definition is added if it matches:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4961 * <beginning of line><Erlang Atom><whitespace>(
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4962 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4963 * It is added to the tags database if it doesn't match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4964 * name of the previous clause header.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4965 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4966 * Return the size of the name of the function, or 0 if no function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4967 * was found.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4968 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
4969 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4970 erlang_func (s, last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4971 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4972 char *last; /* Name of last clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4973 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4974 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4975 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4976
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4977 pos = erlang_atom (s, 0);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4978 if (pos < 1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4979 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4980
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4981 len = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4982 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4983
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4984 /* Save only the first clause. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4985 if (s[pos++] == '('
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4986 && (last == NULL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4987 || len != (int)strlen (last)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4988 || !strneq (s, last, len)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4989 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4990 pfnote (savenstr (s, len), TRUE, s, pos, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4991 return len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4992 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4993
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4994 return 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4995 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4996
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4997
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4998 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4999 * Handle attributes. Currently, tags are generated for defines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5000 * and records.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5001 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5002 * They are on the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5003 * -define(foo, bar).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5004 * -define(Foo(M, N), M+N).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5005 * -record(graph, {vtab = notable, cyclic = true}).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5006 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5007 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5008 erlang_attribute (s)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5009 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5010 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5011 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5012 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5013
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5014 if (strneq (s, "-define", 7) || strneq (s, "-record", 7))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5015 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5016 pos = skip_spaces (s + 7) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5017 if (s[pos++] == '(')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5018 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5019 pos = skip_spaces (s + pos) - s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5020 len = erlang_atom (s, pos);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5021 if (len != 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5022 pfnote (savenstr (& s[pos], len), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5023 s, pos + len, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5024 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5025 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5026 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5027 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5028
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5029
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5030 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5031 * Consume an Erlang atom (or variable).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5032 * Return the number of bytes consumed, or -1 if there was an error.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5033 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5034 static int
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5035 erlang_atom (s, pos)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5036 char *s;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5037 int pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5038 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5039 int origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5040
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5041 origpos = pos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5042
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5043 if (ISALPHA (s[pos]) || s[pos] == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5044 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5045 /* The atom is unquoted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5046 pos++;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5047 while (ISALNUM (s[pos]) || s[pos] == '_')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5048 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5049 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5050 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5051 else if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5052 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5053 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5055 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5056 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5057 if (s[pos] == '\'')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5058 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5059 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5060 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5061 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5062 else if (s[pos] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5063 /* Multiline quoted atoms are ignored. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5064 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5065 else if (s[pos] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5066 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5067 if (s[pos+1] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5068 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5069 pos += 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5070 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5071 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5072 pos++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5073 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5074 return pos - origpos;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5075 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5076 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5077 return -1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5078 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5079
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5080
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5081 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5082
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5083 static char *scan_separators __P((char *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5084 static void analyse_regex __P((char *, bool));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5085 static void add_regex __P((char *, bool, language *));
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5086 static char *substitute __P((char *, char *, struct re_registers *));
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5087
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5088 /* Take a string like "/blah/" and turn it into "blah", making sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5089 that the first and last characters are the same, and handling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5090 quoted separator characters. Actually, stops on the occurrence of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5091 an unquoted separator. Also turns "\t" into a Tab character.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5092 Returns pointer to terminating separator. Works in place. Null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5093 terminates name string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5094 static char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5095 scan_separators (name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5096 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5097 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5098 char sep = name[0];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5099 char *copyto = name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5100 bool quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5101
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5102 for (++name; *name != '\0'; ++name)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5103 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5104 if (quoted)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5105 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5106 if (*name == 't')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5107 *copyto++ = '\t';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5108 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5109 *copyto++ = sep;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5110 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5111 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5112 /* Something else is quoted, so preserve the quote. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5113 *copyto++ = '\\';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5114 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5115 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5116 quoted = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5117 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5118 else if (*name == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5119 quoted = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5120 else if (*name == sep)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5121 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5122 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5123 *copyto++ = *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5124 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5125
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5126 /* Terminate copied string. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5127 *copyto = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5128 return name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5129 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5131 /* Look at the argument of --regex or --no-regex and do the right
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5132 thing. Same for each line of a regexp file. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5133 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5134 analyse_regex (regex_arg, ignore_case)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5135 char *regex_arg;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5136 bool ignore_case;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5137 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5138 if (regex_arg == NULL)
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5139 {
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5140 free_patterns (); /* --no-regex: remove existing regexps */
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5141 return;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5142 }
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5144 /* A real --regexp option or a line in a regexp file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5145 switch (regex_arg[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5146 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5147 /* Comments in regexp file or null arg to --regex. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5148 case '\0':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5149 case ' ':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5150 case '\t':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5151 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5152
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5153 /* Read a regex file. This is recursive and may result in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5154 loop, which will stop when the file descriptors are exhausted. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5155 case '@':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5156 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5157 FILE *regexfp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5158 linebuffer regexbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5159 char *regexfile = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5160
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5161 /* regexfile is a file containing regexps, one per line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5162 regexfp = fopen (regexfile, "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5163 if (regexfp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5164 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5165 pfatal (regexfile);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5166 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5167 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5168 initbuffer (&regexbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5169 while (readline_internal (&regexbuf, regexfp) > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5170 analyse_regex (regexbuf.buffer, ignore_case);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5171 free (regexbuf.buffer);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5172 fclose (regexfp);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5173 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5174 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5176 /* Regexp to be used for a specific language only. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5177 case '{':
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5178 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5179 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5180 char *lang_name = regex_arg + 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5181 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5183 for (cp = lang_name; *cp != '}'; cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5184 if (*cp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5185 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5186 error ("unterminated language name in regex: %s", regex_arg);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5187 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5188 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5189 *cp = '\0';
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5190 lang = get_language_from_langname (lang_name);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5191 if (lang == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5192 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5193 add_regex (cp + 1, ignore_case, lang);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5194 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5195 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5196
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5197 /* Regexp to be used for any language. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5198 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5199 add_regex (regex_arg, ignore_case, NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5200 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5201 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5202 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5203
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5204 /* Turn a name, which is an ed-style (but Emacs syntax) regular
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5205 expression, into a real regular expression by compiling it. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5206 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5207 add_regex (regexp_pattern, ignore_case, lang)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5208 char *regexp_pattern;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5209 bool ignore_case;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5210 language *lang;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5211 {
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5212 static struct re_pattern_buffer zeropattern;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5213 char *name;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5214 const char *err;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5215 struct re_pattern_buffer *patbuf;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5216 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5217
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5218
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5219 if (regexp_pattern[strlen(regexp_pattern)-1] != regexp_pattern[0])
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5220 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5221 error ("%s: unterminated regexp", regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5222 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5223 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5224 name = scan_separators (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5225 if (regexp_pattern[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5226 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5227 error ("null regexp", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5228 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5229 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5230 (void) scan_separators (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5231
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5232 patbuf = xnew (1, struct re_pattern_buffer);
531
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5233 *patbuf = zeropattern;
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5234 if (ignore_case)
0493e9f3c27f [xemacs-hg @ 2001-05-12 11:16:12 by ben]
ben
parents: 523
diff changeset
5235 patbuf->translate = lc_trans; /* translation table to fold case */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5236
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5237 err = re_compile_pattern (regexp_pattern, strlen (regexp_pattern), patbuf);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5238 if (err != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5239 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5240 error ("%s while compiling pattern", err);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5241 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5242 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5243
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5244 pp = p_head;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5245 p_head = xnew (1, pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5246 p_head->regex = savestr (regexp_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5247 p_head->p_next = pp;
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5248 p_head->lang = lang;
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5249 p_head->pat = patbuf;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5250 p_head->name_pattern = savestr (name);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5251 p_head->error_signaled = FALSE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5252 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5253
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5254 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5255 * Do the substitutions indicated by the regular expression and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5256 * arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5257 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5258 static char *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5259 substitute (in, out, regs)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5260 char *in, *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5261 struct re_registers *regs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5262 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5263 char *result, *t;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5264 int size, dig, diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5265
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5266 result = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5267 size = strlen (out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5269 /* Pass 1: figure out how much to allocate by finding all \N strings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5270 if (out[size - 1] == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5271 fatal ("pattern error in \"%s\"", out);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5272 for (t = etags_strchr (out, '\\');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5273 t != NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5274 t = etags_strchr (t + 2, '\\'))
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5275 if (ISDIGIT (t[1]))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5276 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5277 dig = t[1] - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5278 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5279 size += diglen - 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5280 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5281 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5282 size -= 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5283
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5284 /* Allocate space and do the substitutions. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5285 result = xnew (size + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5287 for (t = result; *out != '\0'; out++)
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5288 if (*out == '\\' && ISDIGIT (*++out))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5289 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5290 dig = *out - '0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5291 diglen = regs->end[dig] - regs->start[dig];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5292 strncpy (t, in + regs->start[dig], diglen);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5293 t += diglen;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5294 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5295 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5296 *t++ = *out;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5297 *t = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5298
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5299 assert (t <= result + size && t - result == (int)strlen (result));
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5300
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5301 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5302 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5304 /* Deallocate all patterns. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5305 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5306 free_patterns ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5307 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5308 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5309 while (p_head != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5310 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5311 pp = p_head->p_next;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5312 free (p_head->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5313 free (p_head->name_pattern);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5314 free (p_head);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5315 p_head = pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5316 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5317 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5318 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5319 #endif /* ETAGS_REGEXPS */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5320
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5321
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5322 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5323 get_tag (bp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5324 register char *bp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5325 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5326 register char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5328 if (*bp == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5329 return;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5330 /* Go till you get to white space or a syntactic break */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5331 for (cp = bp + 1;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5332 *cp != '\0' && *cp != '(' && *cp != ')' && !iswhite (*cp);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5333 cp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5334 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5335 pfnote (savenstr (bp, cp-bp), TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5336 lb.buffer, cp - lb.buffer + 1, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5337 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5338
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5339 /* Initialize a linebuffer for use */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5340 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5341 initbuffer (lbp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5342 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5343 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5344 lbp->size = (DEBUG) ? 3 : 200;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5345 lbp->buffer = xnew (lbp->size, char);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5346 lbp->buffer[0] = '\0';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5347 lbp->len = 0;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5348 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5349
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5350 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5351 * Read a line of text from `stream' into `lbp', excluding the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5352 * newline or CR-NL, if any. Return the number of characters read from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5353 * `stream', which is the length of the line including the newline.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5354 *
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5355 * On DOS or Windows we do not count the CR character, if any, before the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5356 * NL, in the returned length; this mirrors the behavior of emacs on those
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5357 * platforms (for text files, it translates CR-NL to NL as it reads in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5358 * file).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5359 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5360 static long
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5361 readline_internal (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5362 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5363 register FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5364 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5365 char *buffer = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5366 register char *p = lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5367 register char *pend;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5368 int chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5369
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5370 pend = p + lbp->size; /* Separate to avoid 386/IX compiler bug. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5371
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5372 while (1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5373 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5374 register int c = getc (stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5375 if (p == pend)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5376 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5377 /* We're at the end of linebuffer: expand it. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5378 lbp->size *= 2;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5379 xrnew (buffer, lbp->size, char);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5380 p += buffer - lbp->buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5381 pend = buffer + lbp->size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5382 lbp->buffer = buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5383 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5384 if (c == EOF)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5385 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5386 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5387 chars_deleted = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5388 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5389 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5390 if (c == '\n')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5391 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5392 if (p > buffer && p[-1] == '\r')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5393 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5394 p -= 1;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5395 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5396 /* Assume CRLF->LF translation will be performed by Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5397 when loading this file, so CRs won't appear in the buffer.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5398 It would be cleaner to compensate within Emacs;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5399 however, Emacs does not know how many CRs were deleted
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5400 before any given point in the file. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5401 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5402 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5403 chars_deleted = 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5404 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5405 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5406 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5407 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5408 chars_deleted = 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5409 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5410 *p = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5411 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5412 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5413 *p++ = c;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5414 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5415 lbp->len = p - buffer;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5416
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5417 return lbp->len + chars_deleted;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5418 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5419
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5420 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5421 * Like readline_internal, above, but in addition try to match the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5422 * input line against relevant regular expressions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5423 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5424 static long
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5425 readline (lbp, stream)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5426 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5427 FILE *stream;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5428 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5429 /* Read new line. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5430 long result = readline_internal (lbp, stream);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5431 #ifdef ETAGS_REGEXPS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5432 int match;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5433 pattern *pp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5434
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5435 /* Match against relevant patterns. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5436 if (lbp->len > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5437 for (pp = p_head; pp != NULL; pp = pp->p_next)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5438 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5439 /* Only use generic regexps or those for the current language. */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5440 if (pp->lang != NULL && pp->lang != curlang)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5441 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5442
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5443 match = re_match (pp->pat, lbp->buffer, lbp->len, 0, &pp->regs);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5444 switch (match)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5445 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5446 case -2:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5447 /* Some error. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5448 if (!pp->error_signaled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5449 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5450 error ("error while matching \"%s\"", pp->regex);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5451 pp->error_signaled = TRUE;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5452 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5453 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5454 case -1:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5455 /* No match. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5456 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5457 default:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5458 /* Match occurred. Construct a tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5459 if (pp->name_pattern[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5460 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5461 /* Make a named tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5462 char *name = substitute (lbp->buffer,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5463 pp->name_pattern, &pp->regs);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5464 if (name != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5465 pfnote (name, TRUE, lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5466 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5467 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5468 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5469 /* Make an unnamed tag. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5470 pfnote ((char *)NULL, TRUE,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5471 lbp->buffer, match, lineno, linecharno);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5472 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5473 break;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5474 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5475 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5476 #endif /* ETAGS_REGEXPS */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5478 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5479 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5480
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5481
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5482 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5483 * Return a pointer to a space of size strlen(cp)+1 allocated
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5484 * with xnew where the string CP has been copied.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5485 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5486 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5487 savestr (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5488 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5489 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5490 return savenstr (cp, strlen (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5491 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5492
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5493 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5494 * Return a pointer to a space of size LEN+1 allocated with xnew where
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5495 * the string CP has been copied for at most the first LEN characters.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5496 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5497 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5498 savenstr (cp, len)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5499 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5500 int len;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5501 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5502 register char *dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5504 dp = xnew (len + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5505 strncpy (dp, cp, len);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5506 dp[len] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5507 return dp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5508 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5509
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5510 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5511 * Return the ptr in sp at which the character c last
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5512 * appears; NULL if not found
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5513 *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5514 * Identical to POSIX strrchr, included for portability.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5515 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5516 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5517 etags_strrchr (sp, c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5518 register const char *sp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5519 register int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5520 {
438
84b14dcb0985 Import from CVS: tag r21-2-27
cvs
parents: 432
diff changeset
5521 register const char *r;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5522
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5523 r = NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5524 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5525 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5526 if (*sp == c)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5527 r = sp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5528 } while (*sp++);
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5529 return (char *)r;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5530 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5531
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5532
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5533 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5534 * Return the ptr in sp at which the character c first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5535 * appears; NULL if not found
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5536 *
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5537 * Identical to POSIX strchr, included for portability.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5538 */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5539 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5540 etags_strchr (sp, c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5541 register const char *sp;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5542 register int c;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5543 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5544 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5545 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5546 if (*sp == c)
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5547 return (char *)sp;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5548 } while (*sp++);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5549 return NULL;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5550 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5552 /* Skip spaces, return new pointer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5553 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5554 skip_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5555 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5556 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5557 while (iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5558 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5559 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5560 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5561
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5562 /* Skip non spaces, return new pointer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5563 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5564 skip_non_spaces (cp)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5565 char *cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5566 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5567 while (*cp != '\0' && !iswhite (*cp))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5568 cp++;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5569 return cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5570 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5572 /* Print error message and exit. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5573 void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5574 fatal (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5575 char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5576 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5577 error (s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5578 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5579 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5580
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5581 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5582 pfatal (s1)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5583 char *s1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5584 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5585 perror (s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5586 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5587 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5588
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5589 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5590 suggest_asking_for_help ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5591 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5592 fprintf (stderr, "\tTry `%s %s' for a complete list of options.\n",
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5593 progname,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5594 #ifdef LONG_OPTIONS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5595 "--help"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5596 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5597 "-h"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5598 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5599 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5600 exit (BAD);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5601 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5602
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5603 /* Print error message. `s1' is printf control string, `s2' is arg for it. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5604 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5605 error (s1, s2)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5606 const char *s1, *s2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5607 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5608 fprintf (stderr, "%s: ", progname);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5609 fprintf (stderr, s1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5610 fprintf (stderr, "\n");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5611 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5613 /* Return a newly-allocated string whose contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5614 concatenate those of s1, s2, s3. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5615 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5616 concat (s1, s2, s3)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5617 char *s1, *s2, *s3;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5618 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5619 int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5620 char *result = xnew (len1 + len2 + len3 + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5621
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5622 strcpy (result, s1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5623 strcpy (result + len1, s2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5624 strcpy (result + len1 + len2, s3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5625 result[len1 + len2 + len3] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5626
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5627 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5628 }
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5629
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5630
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5631 /* Does the same work as the system V getcwd, but does not need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5632 guess the buffer size in advance. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5633 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5634 etags_getcwd ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5635 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5636 #ifdef HAVE_GETCWD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5637 int bufsize = 200;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5638 char *path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5640 while (getcwd (path, bufsize) == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5641 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5642 if (errno != ERANGE)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5643 pfatal ("getcwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5644 bufsize *= 2;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5645 free (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5646 path = xnew (bufsize, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5647 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5648
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5649 canonicalize_filename (path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5650 return path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5652 #else /* not HAVE_GETCWD */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5653 #if MSDOS
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5654
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5655 char *p, path[MAXPATHLEN + 1]; /* Fixed size is safe on MSDOS. */
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5656
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5657 getwd (path);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5658
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5659 for (p = path; *p != '\0'; p++)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5660 if (*p == '\\')
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5661 *p = '/';
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5662 else
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5663 *p = lowcase (*p);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5664
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5665 return strdup (path);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5666 #else /* not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5667 linebuffer path;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5668 FILE *pipe;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5670 initbuffer (&path);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5671 pipe = (FILE *) popen ("pwd 2>/dev/null", "r");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5672 if (pipe == NULL || readline_internal (&path, pipe) == 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5673 pfatal ("pwd");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5674 pclose (pipe);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5675
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5676 return path.buffer;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5677 #endif /* not MSDOS */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5678 #endif /* not HAVE_GETCWD */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5679 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5681 /* Return a newly allocated string containing the file name of FILE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5682 relative to the absolute directory DIR (which should end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5683 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5684 relative_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5685 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5686 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5687 char *fp, *dp, *afn, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5688 int i;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5690 /* Find the common root of file and dir (with a trailing slash). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5691 afn = absolute_filename (file, cwd);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5692 fp = afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5693 dp = dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5694 while (*fp++ == *dp++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5695 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5696 fp--, dp--; /* back to the first differing char */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5697 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5698 if (fp == afn && afn[0] != '/') /* cannot build a relative name */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5699 return afn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5700 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5701 do /* look at the equal chars until '/' */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5702 fp--, dp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5703 while (*fp != '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5704
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5705 /* Build a sequence of "../" strings for the resulting relative file name. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5706 i = 0;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5707 while ((dp = etags_strchr (dp + 1, '/')) != NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5708 i += 1;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5709 res = xnew (3*i + strlen (fp + 1) + 1, char);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5710 res[0] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5711 while (i-- > 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5712 strcat (res, "../");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5713
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5714 /* Add the file name relative to the common root of file and dir. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5715 strcat (res, fp + 1);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5716 free (afn);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5717
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5718 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5719 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5720
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5721 /* Return a newly allocated string containing the absolute file name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5722 of FILE given DIR (which should end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5723 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5724 absolute_filename (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5725 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5726 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5727 char *slashp, *cp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5728
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5729 if (filename_is_absolute (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5730 res = savestr (file);
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5731 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5732 /* We don't support non-absolute file names with a drive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5733 letter, like `d:NAME' (it's too much hassle). */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5734 else if (file[1] == ':')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5735 fatal ("%s: relative file names with drive letters not supported", file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5736 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5737 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5738 res = concat (dir, file, "");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5739
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5740 /* Delete the "/dirname/.." and "/." substrings. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5741 slashp = etags_strchr (res, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5742 while (slashp != NULL && slashp[0] != '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5743 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5744 if (slashp[1] == '.')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5745 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5746 if (slashp[2] == '.'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5747 && (slashp[3] == '/' || slashp[3] == '\0'))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5748 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5749 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5750 do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5751 cp--;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5752 while (cp >= res && !filename_is_absolute (cp));
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5753 if (cp < res)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5754 cp = slashp; /* the absolute name begins with "/.." */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5755 #ifdef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5756 /* Under MSDOS and NT we get `d:/NAME' as absolute
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5757 file name, so the luser could say `d:/../NAME'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5758 We silently treat this as `d:/NAME'. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5759 else if (cp[0] != '/')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5760 cp = slashp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5761 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5762 strcpy (cp, slashp + 3);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5763 slashp = cp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5764 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5765 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5766 else if (slashp[2] == '/' || slashp[2] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5767 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5768 strcpy (slashp, slashp + 2);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5769 continue;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5770 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5771 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5772
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5773 slashp = etags_strchr (slashp + 1, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5774 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5775
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5776 if (res[0] == '\0')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5777 return savestr ("/");
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5778 else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5779 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5780 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5781
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5782 /* Return a newly allocated string containing the absolute
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5783 file name of dir where FILE resides given DIR (which should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5784 end with a slash). */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5785 static char *
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5786 absolute_dirname (file, dir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5787 char *file, *dir;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5788 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5789 char *slashp, *res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5790 char save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5791
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5792 canonicalize_filename (file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5793 slashp = etags_strrchr (file, '/');
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5794 if (slashp == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5795 return savestr (dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5796 save = slashp[1];
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5797 slashp[1] = '\0';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5798 res = absolute_filename (file, dir);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5799 slashp[1] = save;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5801 return res;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5802 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5803
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5804 /* Whether the argument string is an absolute file name. The argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5805 string must have been canonicalized with canonicalize_filename. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5806 static bool
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5807 filename_is_absolute (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5808 char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5809 {
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5810 return (fn[0] == '/'
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5811 #ifdef DOS_NT
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5812 || (ISALPHA(fn[0]) && fn[1] == ':' && fn[2] == '/')
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5813 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5814 );
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5815 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5816
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5817 /* Translate backslashes into slashes. Works in place. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5818 static void
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5819 canonicalize_filename (fn)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5820 register char *fn;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5821 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5822 #ifdef DOS_NT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5823 /* Canonicalize drive letter case. */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5824 if (fn[0] != '\0' && fn[1] == ':' && ISLOWER (fn[0]))
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5825 fn[0] = upcase (fn[0]);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5826 /* Convert backslashes to slashes. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5827 for (; *fn != '\0'; fn++)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5828 if (*fn == '\\')
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5829 *fn = '/';
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5830 #else
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5831 /* No action. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5832 fn = NULL; /* shut up the compiler */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5833 #endif
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5834 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5835
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5836 /* Set the minimum size of a string contained in a linebuffer. */
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 438
diff changeset
5837 static void
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5838 linebuffer_setlen (lbp, toksize)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5839 linebuffer *lbp;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5840 int toksize;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5841 {
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5842 while (lbp->size <= toksize)
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5843 {
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5844 lbp->size *= 2;
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5845 xrnew (lbp->buffer, lbp->size, char);
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5846 }
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
5847 lbp->len = toksize;
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5848 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5849
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5850 /* Like malloc but get fatal error if memory is exhausted. */
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5851 PTR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5852 xmalloc (size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5853 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5854 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5855 PTR result = (PTR) malloc (size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5856 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5857 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5858 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5859 }
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5860
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5861 PTR
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5862 xrealloc (ptr, size)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5863 char *ptr;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5864 unsigned int size;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5865 {
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5866 PTR result = (PTR) realloc (ptr, size);
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5867 if (result == NULL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5868 fatal ("virtual memory exhausted", (char *)NULL);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5869 return result;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5870 }
709
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5871
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5872 /*
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5873 * Local Variables:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5874 * c-indentation-style: gnu
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5875 * indent-tabs-mode: t
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5876 * tab-width: 8
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5877 * c-font-lock-extra-types: ("FILE" "bool" "language" "linebuffer")
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5878 * End:
1df7a5cfb04a [xemacs-hg @ 2001-12-20 07:58:18 by yoshiki]
yoshiki
parents: 531
diff changeset
5879 */